changeset 10687:b256ce6b85b8

[gaim-migrate @ 12235] grim says this is really fixed this time. committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Sat, 12 Mar 2005 01:10:37 +0000
parents 212946f774c0
children 7818a5e9e3a2
files plugins/ciphertest.c src/cipher.c src/cipher.h src/protocols/jabber/auth.c src/protocols/jabber/buddy.c src/protocols/jabber/presence.c src/protocols/jabber/si.c src/protocols/msn/notification.c src/protocols/msn/user.c src/protocols/yahoo/crypt.c src/protocols/yahoo/yahoo.c src/proxy.c
diffstat 12 files changed, 119 insertions(+), 80 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/ciphertest.c	Fri Mar 11 22:45:41 2005 +0000
+++ b/plugins/ciphertest.c	Sat Mar 12 01:10:37 2005 +0000
@@ -65,6 +65,7 @@
 	GaimCipher *cipher;
 	GaimCipherContext *context;
 	gchar digest[32];
+	gboolean ret;
 	gint i = 0;
 
 	cipher = gaim_ciphers_find_cipher("md5");
@@ -85,10 +86,16 @@
 		gaim_cipher_context_append(context, md5_tests[i].question,
 								   strlen(md5_tests[i].question));
 
-		gaim_cipher_context_digest_to_str(context, NULL, digest);
+		ret = gaim_cipher_context_digest_to_str(context, sizeof(digest),
+												digest, NULL);
 
-		gaim_debug_info("cipher-test", "\tGot:    %s\n", digest);
-		gaim_debug_info("cipher-test", "\tWanted: %s\n", md5_tests[i].answer);
+		if(!ret) {
+			gaim_debug_info("cipher-test", "failed\n");
+		} else {
+			gaim_debug_info("cipher-test", "\tGot:    %s\n", digest);
+			gaim_debug_info("cipher-test", "\tWanted: %s\n",
+							md5_tests[i].answer);
+		}
 
 		gaim_cipher_context_reset(context, NULL);
 		i++;
@@ -116,6 +123,7 @@
 	GaimCipherContext *context;
 	gchar digest[40];
 	gint i = 0;
+	gboolean ret;
 
 	cipher = gaim_ciphers_find_cipher("sha1");
 	if(!cipher) {
@@ -147,10 +155,16 @@
 				gaim_cipher_context_append(context, buff, 1000);
 		}
 
-		gaim_cipher_context_digest_to_str(context, NULL, digest);
+		ret = gaim_cipher_context_digest_to_str(context, sizeof(digest),
+												digest, NULL);
 
-		gaim_debug_info("cipher-test", "\tGot:    %s\n", digest);
-		gaim_debug_info("cipher-test", "\tWanted: %s\n", sha1_tests[i].answer);
+		if(!ret) {
+			gaim_debug_info("cipher-test", "failed\n");
+		} else {
+			gaim_debug_info("cipher-test", "\tGot:    %s\n", digest);
+			gaim_debug_info("cipher-test", "\tWanted: %s\n",
+							sha1_tests[i].answer);
+		}
 
 		gaim_cipher_context_reset(context, NULL);
 		i++;
--- a/src/cipher.c	Fri Mar 11 22:45:41 2005 +0000
+++ b/src/cipher.c	Sat Mar 12 01:10:37 2005 +0000
@@ -254,7 +254,9 @@
 }
 
 static gboolean
-md5_digest(GaimCipherContext *context, size_t *len, guint8 digest[16]) {
+md5_digest(GaimCipherContext *context, size_t in_len, guint8 digest[16],
+		   size_t *out_len)
+{
 	struct MD5Context *md5_context = NULL;
 	guint32 last, pad;
 	guint32 high, low;
@@ -266,8 +268,7 @@
 		   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
 	};
 
-	g_return_val_if_fail(len, FALSE);
-	g_return_val_if_fail(*len >= 16, FALSE);
+	g_return_val_if_fail(in_len >= 16, FALSE);
 
 	md5_context = gaim_cipher_context_get_data(context);
 
@@ -289,6 +290,9 @@
 	MD5_PUT_GUINT32(md5_context->state[2], digest, 8);
 	MD5_PUT_GUINT32(md5_context->state[3], digest, 12);
 
+	if(out_len)
+		*out_len = 16;
+
 	return TRUE;
 }
 
@@ -490,14 +494,15 @@
 }
 
 static gboolean
-sha1_digest(GaimCipherContext *context, size_t *len, guint8 digest[20]) {
+sha1_digest(GaimCipherContext *context, size_t in_len, guint8 digest[20],
+			size_t *out_len)
+{
 	struct SHA1Context *sha1_ctx;
 	guint8 pad0x80 = 0x80, pad0x00 = 0x00;
 	guint8 padlen[8];
 	gint i;
 
-	g_return_val_if_fail(len, FALSE);
-	g_return_val_if_fail(*len <= 20, FALSE);
+	g_return_val_if_fail(in_len >= 20, FALSE);
 
 	sha1_ctx = gaim_cipher_context_get_data(context);
 
@@ -525,6 +530,9 @@
 
 	gaim_cipher_context_reset(context, NULL);
 
+	if(out_len)
+		*out_len = 20;
+
 	return TRUE;
 }
 
@@ -616,31 +624,35 @@
 	return caps;
 }
 
-void
+gboolean
 gaim_cipher_digest_region(const gchar *name, const guint8 *data,
-						  size_t data_len, guint8 digest[], size_t *digest_len)
+						  size_t data_len, size_t in_len,
+						  guint8 digest[], size_t *out_len)
 {
 	GaimCipher *cipher;
 	GaimCipherContext *context;
+	gboolean ret = FALSE;
 
-	g_return_if_fail(name);
-	g_return_if_fail(data);
+	g_return_val_if_fail(name, FALSE);
+	g_return_val_if_fail(data, FALSE);
 
 	cipher = gaim_ciphers_find_cipher(name);
 
-	g_return_if_fail(cipher);
+	g_return_val_if_fail(cipher, FALSE);
 
 	if(!cipher->ops->append || !cipher->ops->digest) {
 		gaim_debug_info("cipher", "gaim_cipher_region failed: "
 						"the %s cipher does not support appending and or "
 						"digesting.", cipher->name);
-		return;	
+		return FALSE;
 	}
 
 	context = gaim_cipher_context_new(cipher, NULL);
 	gaim_cipher_context_append(context, data, data_len);
-	gaim_cipher_context_digest(context, digest_len, digest);
-	gaim_cipher_context_destroy(context);
+	ret = gaim_cipher_context_digest(context, in_len, digest, out_len);
+ 	gaim_cipher_context_destroy(context);
+
+	return ret;
 }
 
 /******************************************************************************
@@ -891,8 +903,8 @@
 }
 
 gboolean
-gaim_cipher_context_digest(GaimCipherContext *context, size_t *len,
-						   guint8 digest[])
+gaim_cipher_context_digest(GaimCipherContext *context, size_t in_len,
+						   guint8 digest[], size_t *out_len)
 {
 	GaimCipher *cipher = NULL;
 
@@ -902,7 +914,7 @@
 	g_return_val_if_fail(context, FALSE);
 
 	if(cipher->ops && cipher->ops->digest)
-		return cipher->ops->digest(context, len, digest);
+		return cipher->ops->digest(context, in_len, digest, out_len);
 	else {
 		gaim_debug_info("cipher", "the %s cipher does not support the digest "
 						"operation\n", cipher->name);
@@ -911,10 +923,10 @@
 }
 
 gboolean
-gaim_cipher_context_digest_to_str(GaimCipherContext *context, size_t *len,
-								   gchar digest_s[])
+gaim_cipher_context_digest_to_str(GaimCipherContext *context, size_t in_len,
+								   gchar digest_s[], size_t *out_len)
 {
-	/* 16k is a bit excessive, will tweak later. */
+	/* 8k is a bit excessive, will tweak later. */
 	guint8 digest[BUF_LEN * 4];
 	gint n = 0;
 	size_t dlen = 0;
@@ -922,19 +934,20 @@
 	g_return_val_if_fail(context, FALSE);
 	g_return_val_if_fail(digest_s, FALSE);
 
-	if(!gaim_cipher_context_digest(context, &dlen, digest))
+	if(!gaim_cipher_context_digest(context, sizeof(digest), digest, &dlen))
 		return FALSE;
 
-	dlen *= 2;
-
-	if(len)
-		*len = dlen;
+	if(in_len < dlen * 2)
+		return FALSE;
 
 	for(n = 0; n < dlen; n++)
 		sprintf(digest_s + (n * 2), "%02x", digest[n]);
 
 	digest_s[n * 2] = '\0';
 
+	if(out_len)
+		*out_len = dlen * 2;
+
 	return TRUE;
 }
 
--- a/src/cipher.h	Fri Mar 11 22:45:41 2005 +0000
+++ b/src/cipher.h	Sat Mar 12 01:10:37 2005 +0000
@@ -83,7 +83,7 @@
 	void (*append)(GaimCipherContext *context, const guint8 *data, size_t len);
 
 	/** The digest function */
-	gboolean (*digest)(GaimCipherContext *context, size_t *len, guint8 digest[]);
+	gboolean (*digest)(GaimCipherContext *context, size_t in_len, guint8 digest[], size_t *out_len);
 
 	/** The encrypt function */
 	int (*encrypt)(GaimCipherContext *context, const guint8 data[], size_t len, guint8 output[], size_t *outlen);
@@ -134,13 +134,16 @@
 /**
  * Gets a digest from a cipher
  *
- * @param name       The cipher's name
- * @param data       The data to hash
- * @param data_len   The length of the data
- * @param digest     The returned digest
- * @param digest_len The returned digest's length
+ * @param name     The cipher's name
+ * @param data     The data to hash
+ * @param data_len The length of the data
+ * @param in_len   The length of the buffer
+ * @param digest   The returned digest
+ * @param out_len  The length written
+ *
+ * @return @c TRUE if successful, @c FALSE otherwise
  */
-void gaim_cipher_digest_region(const gchar *name, const guint8 *data, size_t data_len, guint8 digest[], size_t *digest_len); 
+gboolean gaim_cipher_digest_region(const gchar *name, const guint8 *data, size_t data_len, size_t in_len, guint8 digest[], size_t *out_len); 
 
 /*@}*/
 /******************************************************************************/
@@ -290,19 +293,21 @@
  * Digests a context
  *
  * @param context The context to digest
- * @param len     The length of the returned value
+ * @param in_len  The length of the buffer
  * @param digest  The return buffer for the digest
+ * @param out_len The length of the returned value
  */
-gboolean gaim_cipher_context_digest(GaimCipherContext *context, size_t *len, guint8 digest[]);
+gboolean gaim_cipher_context_digest(GaimCipherContext *context, size_t in_len, guint8 digest[], size_t *out_len);
 
 /**
  * Converts a guint8 digest into a hex string
  *
  * @param context  The context to get a digest from
- * @param len      The length of the returned value
+ * @param in_len   The length of the buffer
  * @param digest_s The return buffer for the string digest
+ * @param out_len  The length of the returned value
  */
-gboolean gaim_cipher_context_digest_to_str(GaimCipherContext *context, size_t *len, gchar digest_s[]);
+gboolean gaim_cipher_context_digest_to_str(GaimCipherContext *context, size_t in_len, gchar digest_s[], size_t *out_len);
 
 /**
  * Encrypts data using the context
--- a/src/protocols/jabber/auth.c	Fri Mar 11 22:45:41 2005 +0000
+++ b/src/protocols/jabber/auth.c	Sat Mar 12 01:10:37 2005 +0000
@@ -228,7 +228,7 @@
 			s = g_strdup_printf("%s%s", js->stream_id, pw);
 
 			gaim_cipher_digest_region("sha1", (guint8 *)s, strlen(s),
-									  hashval, NULL);
+									  sizeof(hashval), hashval, NULL);
 
 			p = h;
 			for(i=0; i<20; i++, p+=2)
@@ -323,7 +323,7 @@
 
 	x = g_strdup_printf("%s:%s:%s", convnode, realm, convpasswd);
 	gaim_cipher_context_append(context, x, strlen(x));
-	gaim_cipher_context_digest(context, NULL, result);
+	gaim_cipher_context_digest(context, sizeof(result), result, NULL);
 
 	a1 = g_strdup_printf("xxxxxxxxxxxxxxxx:%s:%s", nonce, cnonce);
 	a1len = strlen(a1);
@@ -331,13 +331,13 @@
 
 	gaim_cipher_context_reset(context, NULL);
 	gaim_cipher_context_append(context, a1, a1len);
-	gaim_cipher_context_digest(context, NULL, result);
+	gaim_cipher_context_digest(context, sizeof(result), result, NULL);
 
 	ha1 = gaim_base16_encode(result, 16);
 
 	gaim_cipher_context_reset(context, NULL);
 	gaim_cipher_context_append(context, a2, strlen(a2));
-	gaim_cipher_context_digest(context, NULL, result);
+	gaim_cipher_context_digest(context, sizeof(result), result, NULL);
 
 	ha2 = gaim_base16_encode(result, 16);
 
@@ -345,7 +345,7 @@
 
 	gaim_cipher_context_reset(context, NULL);
 	gaim_cipher_context_append(context, kd, strlen(kd));
-	gaim_cipher_context_digest(context, NULL, result);
+	gaim_cipher_context_digest(context, sizeof(result), result, NULL);
 	gaim_cipher_context_destroy(context);
 
 	z = gaim_base16_encode(result, 16);
--- a/src/protocols/jabber/buddy.c	Fri Mar 11 22:45:41 2005 +0000
+++ b/src/protocols/jabber/buddy.c	Sat Mar 12 01:10:37 2005 +0000
@@ -394,7 +394,8 @@
 				enc = gaim_base64_encode(avatar_data, avatar_len);
 
 				gaim_cipher_digest_region("sha1", (guint8 *)avatar_data,
-										  avatar_len, hashval, NULL);
+										  avatar_len, sizeof(hashval),
+										  hashval, NULL);
 
 				p = hash;
 				for(i=0; i<20; i++, p+=2)
@@ -820,7 +821,7 @@
 						data, size);
 
 				gaim_cipher_digest_region("sha1", (guint8 *)data, size,
-										  hashval, NULL);
+										  sizeof(hashval), hashval, NULL);
 				p = hash;
 				for(i=0; i<20; i++, p+=2)
 					snprintf(p, 3, "%02x", hashval[i]);
--- a/src/protocols/jabber/presence.c	Fri Mar 11 22:45:41 2005 +0000
+++ b/src/protocols/jabber/presence.c	Sat Mar 12 01:10:37 2005 +0000
@@ -216,8 +216,8 @@
 					int i;
 
 					gaim_cipher_digest_region("sha1", (guint8 *)data, size,
-											  hashval, NULL);
-					p = hash;
+											  sizeof(hashval), hashval, NULL);
+ 					p = hash;
 					for(i=0; i<20; i++, p+=2)
 						snprintf(p, 3, "%02x", hashval[i]);
 					gaim_blist_node_set_string((GaimBlistNode*)b, "avatar_hash", hash);
--- a/src/protocols/jabber/si.c	Fri Mar 11 22:45:41 2005 +0000
+++ b/src/protocols/jabber/si.c	Sat Mar 12 01:10:37 2005 +0000
@@ -156,7 +156,7 @@
 			jsx->js->user->domain, jsx->js->user->resource);
 
 	gaim_cipher_digest_region("sha1", (guint8 *)dstaddr, strlen(dstaddr),
-							  hashval, NULL);
+							  sizeof(hashval), hashval, NULL);
 	g_free(dstaddr);
 	dstaddr = g_malloc(41);
 	p = dstaddr;
@@ -272,7 +272,7 @@
 			jsx->js->user->resource, xfer->who);
 
 	gaim_cipher_digest_region("sha1", (guint8 *)dstaddr, strlen(dstaddr),
-							  hashval, NULL);
+							  sizeof(hashval), hashval, NULL);
 	g_free(dstaddr);
 	dstaddr = g_malloc(41);
 	p = dstaddr;
--- a/src/protocols/msn/notification.c	Fri Mar 11 22:45:41 2005 +0000
+++ b/src/protocols/msn/notification.c	Sat Mar 12 01:10:37 2005 +0000
@@ -418,7 +418,7 @@
 
 	gaim_cipher_context_append(context, challenge_resp,
 							   strlen(challenge_resp));
-	gaim_cipher_context_digest(context, NULL, digest);
+	gaim_cipher_context_digest(context, sizeof(digest), digest, NULL);
 	gaim_cipher_context_destroy(context);
 
 	for (i = 0; i < 16; i++)
@@ -910,7 +910,7 @@
 	context = gaim_cipher_context_new(cipher, NULL);
 
 	gaim_cipher_context_append(context, buf, strlen(buf));
-	gaim_cipher_context_digest(context, NULL, digest);
+	gaim_cipher_context_digest(context, sizeof(digest), digest, NULL);
 	gaim_cipher_context_destroy(context);
 
 	memset(sendbuf, 0, sizeof(sendbuf));
--- a/src/protocols/msn/user.c	Fri Mar 11 22:45:41 2005 +0000
+++ b/src/protocols/msn/user.c	Sat Mar 12 01:10:37 2005 +0000
@@ -205,7 +205,7 @@
 
 		ctx = gaim_cipher_context_new_by_name("sha1", NULL);
 		gaim_cipher_context_append(ctx, buf, st.st_size);
-		gaim_cipher_context_digest(ctx, NULL, digest);
+		gaim_cipher_context_digest(ctx, sizeof(digest), digest, NULL);
 		g_free(buf);
 
 		base64 = gaim_base64_encode(digest, sizeof(digest));
@@ -228,7 +228,7 @@
 
 		gaim_cipher_context_reset(ctx, NULL);
 		gaim_cipher_context_append(ctx, buf, strlen(buf));
-		gaim_cipher_context_digest(ctx, NULL, digest);
+		gaim_cipher_context_digest(ctx, sizeof(digest), digest, NULL);
 		gaim_cipher_context_destroy(ctx);
 		g_free(buf);
 
--- a/src/protocols/yahoo/crypt.c	Fri Mar 11 22:45:41 2005 +0000
+++ b/src/protocols/yahoo/crypt.c	Sat Mar 12 01:10:37 2005 +0000
@@ -49,6 +49,7 @@
 	size_t salt_len;
 	size_t key_len;
 	size_t cnt;
+
 	char *cp;
 
 	if (buflen < needed) {
@@ -100,7 +101,7 @@
 	gaim_cipher_context_append(context2, key, key_len);
 
 	/* Now get result of this (16 bytes) and add it to the other context.  */
-	gaim_cipher_context_digest(context2, NULL, digest);
+	gaim_cipher_context_digest(context2, sizeof(digest), digest, NULL);
 
 	/* Add for any character in the key one byte of the alternate sum.  */
 	for (cnt = key_len; cnt > 16; cnt -= 16)
@@ -120,7 +121,7 @@
 								   (cnt & 1) != 0 ? digest : (guint8 *)key, 1);
 
 	/* Create intermediate result.  */
-	gaim_cipher_context_digest(context1, NULL, digest);
+	gaim_cipher_context_digest(context1, sizeof(digest), digest, NULL);
 
 	/* Now comes another weirdness.  In fear of password crackers here
 	 * comes a quite long loop which just processes the output of the
@@ -151,7 +152,7 @@
 			gaim_cipher_context_append(context2, key, key_len);
 
 		/* Create intermediate result.  */
-		gaim_cipher_context_digest(context2, NULL, digest);
+		gaim_cipher_context_digest(context2, sizeof(digest), digest, NULL);
 	}
 
 	/* Now we can construct the result string.  It consists of three parts. */
@@ -197,7 +198,7 @@
 	 * inside the MD5 implementation as well.
 	 */
 	gaim_cipher_context_reset(context1, NULL);
-	gaim_cipher_context_digest(context1, NULL, digest);
+	gaim_cipher_context_digest(context1, sizeof(digest), digest, NULL);
 	gaim_cipher_context_destroy(context1);
 	gaim_cipher_context_destroy(context2);
 
--- a/src/protocols/yahoo/yahoo.c	Fri Mar 11 22:45:41 2005 +0000
+++ b/src/protocols/yahoo/yahoo.c	Sat Mar 12 01:10:37 2005 +0000
@@ -958,7 +958,7 @@
 	context = gaim_cipher_context_new(cipher, NULL);
 
 	gaim_cipher_context_append(context, pass, strlen(pass));
-	gaim_cipher_context_digest(context, NULL, digest);
+	gaim_cipher_context_digest(context, sizeof(digest), digest, NULL);
 
 	to_y64(password_hash, digest, 16);
 
@@ -966,7 +966,7 @@
 
 	gaim_cipher_context_reset(context, NULL);
 	gaim_cipher_context_append(context, crypt_result, strlen(crypt_result));
-	gaim_cipher_context_digest(context, NULL, digest);
+	gaim_cipher_context_digest(context, sizeof(digest), digest, NULL);
 	to_y64(crypt_hash, digest, 16);
 
 	switch (sv) {
@@ -1012,12 +1012,12 @@
 
 	gaim_cipher_context_reset(context, NULL);
 	gaim_cipher_context_append(context, hash_string_p, strlen(hash_string_p));
-	gaim_cipher_context_digest(context, NULL, digest);
+	gaim_cipher_context_digest(context, sizeof(digest), digest, NULL);
 	to_y64(result6, digest, 16);
 
 	gaim_cipher_context_reset(context, NULL);
 	gaim_cipher_context_append(context, hash_string_c, strlen(hash_string_c));
-	gaim_cipher_context_digest(context, NULL, digest);
+	gaim_cipher_context_digest(context, sizeof(digest), digest, NULL);
 	gaim_cipher_context_destroy(context);
 	to_y64(result96, digest, 16);
 
@@ -1244,7 +1244,8 @@
 			gaim_cipher_context_reset(md5_ctx, NULL);
 			gaim_cipher_context_append(md5_ctx, magic_key_char, 4);
 			gaim_cipher_context_append(md5_ctx, test, 3);
-			gaim_cipher_context_digest(md5_ctx, NULL, md5_digest);
+			gaim_cipher_context_digest(md5_ctx, sizeof(md5_digest),
+									   md5_digest, NULL);
 			
 			if (!memcmp(md5_digest, comparison_src+4, 16)) {
 				leave = 1;
@@ -1275,13 +1276,15 @@
 	/* Get password and crypt hashes as per usual. */
 	gaim_cipher_context_reset(md5_ctx, NULL);
 	gaim_cipher_context_append(md5_ctx, pass, strlen(pass));
-	gaim_cipher_context_digest(md5_ctx, NULL, md5_digest);
+	gaim_cipher_context_digest(md5_ctx, sizeof(md5_digest),
+							   md5_digest, NULL);
 	to_y64(password_hash, md5_digest, 16);
 
 	crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$");  
 	gaim_cipher_context_reset(md5_ctx, NULL);
 	gaim_cipher_context_append(md5_ctx, crypt_result, strlen(crypt_result));
-	gaim_cipher_context_digest(md5_ctx, NULL, md5_digest);
+	gaim_cipher_context_digest(md5_ctx, sizeof(md5_digest),
+							   md5_digest, NULL);
 	to_y64(crypt_hash, md5_digest, 16);
 
 	/* Our first authentication response is based off of the password hash. */
@@ -1308,7 +1311,7 @@
 	if (y >= 3)
 		gaim_cipher_context_set_option(sha1_ctx1, "sizeLo", GINT_TO_POINTER(0x1ff));
 	gaim_cipher_context_append(sha1_ctx1, magic_key_char, 4);
-	gaim_cipher_context_digest(sha1_ctx1, NULL, digest1);
+	gaim_cipher_context_digest(sha1_ctx1, sizeof(digest1), digest1, NULL);
 	
 	/* 
 	 * The second context gets the password hash XORed with 0x5c plus the SHA-1 digest
@@ -1317,7 +1320,7 @@
 	
 	gaim_cipher_context_append(sha1_ctx2, pass_hash_xor2, 64);
 	gaim_cipher_context_append(sha1_ctx2, digest1, 20);
-	gaim_cipher_context_digest(sha1_ctx2, NULL, digest2);
+	gaim_cipher_context_digest(sha1_ctx2, sizeof(digest2), digest2, NULL);
 	
 	/* 
 	 * Now that we have digest2, use it to fetch characters from an alphabet to construct
@@ -1398,10 +1401,12 @@
 	 */
 	
 	gaim_cipher_context_append(sha1_ctx1, crypt_hash_xor1, 64);
-	if (y >= 3)
-		gaim_cipher_context_set_option(sha1_ctx1, "sizeLo", GINT_TO_POINTER(0x1ff));
+	if (y >= 3) {
+		gaim_cipher_context_set_option(sha1_ctx1, "sizeLo",
+									   GINT_TO_POINTER(0x1ff));
+	}
 	gaim_cipher_context_append(sha1_ctx1, magic_key_char, 4);
-	gaim_cipher_context_digest(sha1_ctx1, NULL, digest1);
+	gaim_cipher_context_digest(sha1_ctx1, sizeof(digest1), digest1, NULL);
 	
 	/* 
 	 * The second context gets the password hash XORed with 0x5c plus the SHA-1 digest
@@ -1410,7 +1415,7 @@
 	
 	gaim_cipher_context_append(sha1_ctx2, crypt_hash_xor2, 64);
 	gaim_cipher_context_append(sha1_ctx2, digest1, 20);
-	gaim_cipher_context_digest(sha1_ctx2, NULL, digest2);
+	gaim_cipher_context_digest(sha1_ctx2, sizeof(digest2), digest2, NULL);
 	
 	/* 
 	 * Now that we have digest2, use it to fetch characters from an alphabet to construct
@@ -2183,7 +2188,7 @@
 	context = gaim_cipher_context_new(cipher, NULL);
 
 	gaim_cipher_context_append(context, pass, strlen(pass));
-	gaim_cipher_context_digest(context, NULL, digest);
+	gaim_cipher_context_digest(context, sizeof(digest), digest, NULL);
 	for (i = 0; i < 16; ++i) {
 		g_snprintf(hashp, 3, "%02x", digest[i]);
 		hashp += 2;
@@ -2192,7 +2197,7 @@
 	chal = g_strconcat(md5, g_hash_table_lookup(hash, ".challenge"), NULL);
 	gaim_cipher_context_reset(context, NULL);
 	gaim_cipher_context_append(context, chal, strlen(chal));
-	gaim_cipher_context_digest(context, NULL, digest);
+	gaim_cipher_context_digest(context, sizeof(digest), digest, NULL);
 	hashp = md5;
 	for (i = 0; i < 16; ++i) {
 		g_snprintf(hashp, 3, "%02x", digest[i]);
@@ -2204,7 +2209,7 @@
 
 	gaim_cipher_context_reset(context, NULL);
 	gaim_cipher_context_append(context, md5, strlen(md5));
-	gaim_cipher_context_digest(context, NULL, digest);
+	gaim_cipher_context_digest(context, sizeof(digest), digest, NULL);
 	hashp = md5;
 	for (i = 0; i < 16; ++i) {
 		g_snprintf(hashp, 3, "%02x", digest[i]);
--- a/src/proxy.c	Fri Mar 11 22:45:41 2005 +0000
+++ b/src/proxy.c	Sat Mar 12 01:10:37 2005 +0000
@@ -1377,7 +1377,7 @@
 	pwlen=strlen(passwd);
 	if (pwlen>64) {
 		gaim_cipher_context_append(ctx, passwd, strlen(passwd));
-		gaim_cipher_context_digest(ctx, NULL, md5buf);
+		gaim_cipher_context_digest(ctx, sizeof(md5buf), md5buf, NULL);
 		pwinput=(char *)md5buf;
 		pwlen=16;
 	}
@@ -1394,12 +1394,12 @@
 	gaim_cipher_context_reset(ctx, NULL);
 	gaim_cipher_context_append(ctx, Kxoripad, 64);
 	gaim_cipher_context_append(ctx, challenge, challen);
-	gaim_cipher_context_digest(ctx, NULL, Kxoripad);
+	gaim_cipher_context_digest(ctx, sizeof(Kxoripad), Kxoripad, NULL);
 
 	gaim_cipher_context_reset(ctx, NULL);
 	gaim_cipher_context_append(ctx, Kxoropad, 64);
 	gaim_cipher_context_append(ctx, Kxoripad, 16);
-	gaim_cipher_context_digest(ctx, NULL, response);
+	gaim_cipher_context_digest(ctx, sizeof(response), response, NULL);
 
 	gaim_cipher_context_destroy(ctx);
 }