diff src/cipher.c @ 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 c01aa6ea4947
line wrap: on
line diff
--- 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);