Mercurial > pidgin
changeset 12389:e024601d45c7
[gaim-migrate @ 14695]
How about we allow callers to pass in the entity body, rather than forcing them to hash it themselves?
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Wed, 07 Dec 2005 11:01:49 +0000 |
parents | 4e045668b9d0 |
children | dca3779701a7 |
files | plugins/ciphertest.c src/cipher.c src/cipher.h src/protocols/simple/simple.c |
diffstat | 4 files changed, 22 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/ciphertest.c Wed Dec 07 10:38:52 2005 +0000 +++ b/plugins/ciphertest.c Wed Dec 07 11:01:49 2005 +0000 @@ -184,12 +184,11 @@ const gchar *realm = "testrealm@host.com"; const gchar *password = "Circle Of Life"; const gchar *algorithm = "md5"; - const gchar nonce_count[] = "00000001"; + const gchar *nonce_count = "00000001"; const gchar *method = "GET"; const gchar *qop = "auth"; const gchar *digest_uri = "/dir/index.html"; - const gchar *hashed_entity = ""; - size_t hashed_entity_len = 0; + const gchar *entity = NULL; gchar *session_key; @@ -212,9 +211,8 @@ gaim_debug_info("cipher-test", "\tsession_key: Wanted: %s\n", "939e7578ed9e3c518a452acee763bce9"); response = gaim_cipher_http_digest_calculate_response( - algorithm, method, digest_uri, qop, - hashed_entity, hashed_entity_len, nonce, - nonce_count, client_nonce, session_key); + algorithm, method, digest_uri, qop, entity, + nonce, nonce_count, client_nonce, session_key); g_free(session_key);
--- a/src/cipher.c Wed Dec 07 10:38:52 2005 +0000 +++ b/src/cipher.c Wed Dec 07 11:01:49 2005 +0000 @@ -1849,8 +1849,7 @@ const gchar *method, const gchar *digest_uri, const gchar *qop, - const gchar *hashed_entity, - size_t hashed_entity_len, + const gchar *entity, const gchar *nonce, const gchar *nonce_count, const gchar *client_nonce, @@ -1888,15 +1887,23 @@ if (qop != NULL && !strcasecmp(qop, "auth-int")) { - if (hashed_entity == NULL) + GaimCipherContext *context2; + gchar entity_hash[33]; + + if (entity == NULL) { gaim_cipher_context_destroy(context); - gaim_debug_error("cipher", "Required hashed_entity missing for auth-int digest calculation."); + gaim_debug_error("cipher", "Required entity missing for auth-int digest calculation."); return NULL; } + context2 = gaim_cipher_context_new(cipher, NULL); + gaim_cipher_context_append(context2, (guchar *)entity, strlen(entity)); + gaim_cipher_context_digest_to_str(context2, sizeof(entity_hash), entity_hash, NULL); + gaim_cipher_context_destroy(context2); + gaim_cipher_context_append(context, (guchar *)":", 1); - gaim_cipher_context_append(context, (guchar *)hashed_entity, hashed_entity_len); + gaim_cipher_context_append(context, (guchar *)entity_hash, strlen(entity_hash)); } gaim_cipher_context_digest_to_str(context, sizeof(hash2), hash2, NULL);
--- a/src/cipher.h Wed Dec 07 10:38:52 2005 +0000 +++ b/src/cipher.h Wed Dec 07 11:01:49 2005 +0000 @@ -419,8 +419,7 @@ * @param method The HTTP method in use * @param digest_uri The URI from the initial request * @param qop The "quality of protection" - * @param hashed_entity The hashed entity body - * @param hashed_entity_len The length of the data in @a hashed_entity + * @param entity The entity body * @param nonce The nonce provided by the server * @param nonce_count The nonce count * @param client_nonce The nonce provided by the client @@ -431,9 +430,9 @@ gchar *gaim_cipher_http_digest_calculate_response( const gchar *algorithm, const gchar *method, const gchar *digest_uri, const gchar *qop, - const gchar *hashed_entity, size_t hashed_entity_len, - const gchar *nonce, const gchar *nonce_count, - const gchar *client_nonce, const gchar *session_key); + const gchar *entity, const gchar *nonce, + const gchar *nonce_count, const gchar *client_nonce, + const gchar *session_key); /*@}*/
--- a/src/protocols/simple/simple.c Wed Dec 07 10:38:52 2005 +0000 +++ b/src/protocols/simple/simple.c Wed Dec 07 11:01:49 2005 +0000 @@ -267,7 +267,7 @@ if(auth->type == 1) { /* Digest */ sprintf(noncecount, "%08d", auth->nc++); response = gaim_cipher_http_digest_calculate_response( - "md5", method, target, NULL, NULL, 0, + "md5", method, target, NULL, NULL, auth->nonce, noncecount, NULL, auth->digest_session_key); gaim_debug(GAIM_DEBUG_MISC, "simple", "response %s\n", response); @@ -289,7 +289,7 @@ sprintf(noncecount, "%08d", auth->nc++); response = gaim_cipher_http_digest_calculate_response( - "md5", method, target, NULL, NULL, 0, + "md5", method, target, NULL, NULL, auth->nonce, noncecount, NULL, auth->digest_session_key); gaim_debug(GAIM_DEBUG_MISC, "simple", "response %s\n", response);