gobjectification: 4bd61921: Rename PurpleMD5Cipher to PurpleMD5Hash.

qulogic at pidgin.im qulogic at pidgin.im
Sun Jul 11 04:05:47 EDT 2010


----------------------------------------------------------------------
Revision: 4bd61921736d7d77fd48049ff66e974cae1c6b7c
Parent:   6669489d1ef1ccf26310034c65ef9788429e8fbe
Author:   qulogic at pidgin.im
Date:     07/11/10 00:14:53
Branch:   im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/4bd61921736d7d77fd48049ff66e974cae1c6b7c

Changelog: 

Rename PurpleMD5Cipher to PurpleMD5Hash.

Changes against parent 6669489d1ef1ccf26310034c65ef9788429e8fbe

  renamed  libpurple/cipher/md5cipher.c
       to  libpurple/cipher/md5hash.c
  renamed  libpurple/cipher/md5cipher.h
       to  libpurple/cipher/md5hash.h
  patched  libpurple/Makefile.am
  patched  libpurple/Makefile.mingw
  patched  libpurple/cipher/md5hash.c
  patched  libpurple/cipher/md5hash.h
  patched  libpurple/plugins/ciphertest.c
  patched  libpurple/plugins/perl/common/Cipher.xs
  patched  libpurple/plugins/perl/common/module.h
  patched  libpurple/protocols/jabber/auth.c
  patched  libpurple/protocols/jabber/auth_digest_md5.c
  patched  libpurple/protocols/jabber/caps.c
  patched  libpurple/protocols/jabber/jutil.c
  patched  libpurple/protocols/msn/msn.h
  patched  libpurple/protocols/msn/msnutils.c
  patched  libpurple/protocols/msn/nexus.c
  patched  libpurple/protocols/msn/notification.c
  patched  libpurple/protocols/oscar/family_auth.c
  patched  libpurple/protocols/oscar/family_oservice.c
  patched  libpurple/protocols/oscar/oscar.c
  patched  libpurple/protocols/qq/utils.c
  patched  libpurple/protocols/yahoo/libymsg.c
  patched  libpurple/proxy.c
  patched  libpurple/tests/test_cipher.c
  patched  libpurple/util.c

-------------- next part --------------
============================================================
--- libpurple/proxy.c	c4a1eb2cbc8e7409593b7e9af93fcd3a420e8f7b
+++ libpurple/proxy.c	addf0227267518e206f9027bcd67d099119e7f8b
@@ -33,7 +33,7 @@
 #include "internal.h"
 #include "debug.h"
 #include "dnsquery.h"
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 #include "notify.h"
 #include "ntlm.h"
 #include "prefs.h"
@@ -1613,21 +1613,21 @@ hmacmd5_chap(const unsigned char * chall
 static void
 hmacmd5_chap(const unsigned char * challenge, int challen, const char * passwd, unsigned char * response)
 {
-	PurpleCipher *cipher;
+	PurpleHash *hash;
 	int i;
 	unsigned char Kxoripad[65];
 	unsigned char Kxoropad[65];
 	size_t pwlen;
 
-	cipher = purple_md5_cipher_new();
+	hash = purple_md5_hash_new();
 
 	memset(Kxoripad,0,sizeof(Kxoripad));
 	memset(Kxoropad,0,sizeof(Kxoropad));
 
 	pwlen=strlen(passwd);
 	if (pwlen>64) {
-		purple_cipher_append(cipher, (const guchar *)passwd, strlen(passwd));
-		purple_cipher_digest(cipher, sizeof(Kxoripad), Kxoripad, NULL);
+		purple_hash_append(hash, (const guchar *)passwd, strlen(passwd));
+		purple_hash_digest(hash, sizeof(Kxoripad), Kxoripad, NULL);
 		pwlen=16;
 	} else {
 		memcpy(Kxoripad, passwd, pwlen);
@@ -1639,17 +1639,17 @@ hmacmd5_chap(const unsigned char * chall
 		Kxoropad[i]^=0x5c;
 	}
 
-	purple_cipher_reset(cipher);
-	purple_cipher_append(cipher, Kxoripad, 64);
-	purple_cipher_append(cipher, challenge, challen);
-	purple_cipher_digest(cipher, sizeof(Kxoripad), Kxoripad, NULL);
+	purple_hash_reset(hash);
+	purple_hash_append(hash, Kxoripad, 64);
+	purple_hash_append(hash, challenge, challen);
+	purple_hash_digest(hash, sizeof(Kxoripad), Kxoripad, NULL);
 
-	purple_cipher_reset(cipher);
-	purple_cipher_append(cipher, Kxoropad, 64);
-	purple_cipher_append(cipher, Kxoripad, 16);
-	purple_cipher_digest(cipher, 16, response, NULL);
+	purple_hash_reset(hash);
+	purple_hash_append(hash, Kxoropad, 64);
+	purple_hash_append(hash, Kxoripad, 16);
+	purple_hash_digest(hash, 16, response, NULL);
 
-	g_object_unref(G_OBJECT(cipher));
+	g_object_unref(G_OBJECT(hash));
 }
 
 static void
============================================================
--- libpurple/util.c	4012ec42e1c07a76bf786350ef1b626729dfe0d4
+++ libpurple/util.c	04ec97862710a85b62ef43a574f27e5fc167605c
@@ -26,7 +26,7 @@
 #include "conversation.h"
 #include "core.h"
 #include "debug.h"
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 #include "cipher/sha1cipher.h"
 #include "notify.h"
 #include "ntlm.h"
@@ -5029,8 +5029,8 @@ gchar *purple_http_digest_calculate_sess
 		const gchar *nonce,
 		const gchar *client_nonce)
 {
-	PurpleCipher *cipher;
-	gchar hash[33]; /* We only support MD5. */
+	PurpleHash *hash;
+	gchar digest[33]; /* We only support MD5. */
 
 	g_return_val_if_fail(username != NULL, NULL);
 	g_return_val_if_fail(realm    != NULL, NULL);
@@ -5043,38 +5043,36 @@ gchar *purple_http_digest_calculate_sess
 						 g_ascii_strcasecmp(algorithm, "MD5") ||
 						 g_ascii_strcasecmp(algorithm, "MD5-sess"), NULL);
 
-	cipher = purple_md5_cipher_new();
-	purple_cipher_append(cipher, (guchar *)username, strlen(username));
-	purple_cipher_append(cipher, (guchar *)":", 1);
-	purple_cipher_append(cipher, (guchar *)realm, strlen(realm));
-	purple_cipher_append(cipher, (guchar *)":", 1);
-	purple_cipher_append(cipher, (guchar *)password, strlen(password));
+	hash = purple_md5_hash_new();
+	purple_hash_append(hash, (guchar *)username, strlen(username));
+	purple_hash_append(hash, (guchar *)":", 1);
+	purple_hash_append(hash, (guchar *)realm, strlen(realm));
+	purple_hash_append(hash, (guchar *)":", 1);
+	purple_hash_append(hash, (guchar *)password, strlen(password));
 
 	if (algorithm != NULL && !g_ascii_strcasecmp(algorithm, "MD5-sess"))
 	{
-		guchar digest[16];
-
 		if (client_nonce == NULL)
 		{
-			g_object_unref(G_OBJECT(cipher));
+			g_object_unref(G_OBJECT(hash));
 			purple_debug_error("cipher", "Required client_nonce missing for MD5-sess digest calculation.\n");
 			return NULL;
 		}
 
-		purple_cipher_digest(cipher, sizeof(digest), digest, NULL);
-		purple_cipher_reset(cipher);
+		purple_hash_digest(hash, sizeof(digest), (guchar *)digest, NULL);
+		purple_hash_reset(hash);
 
-		purple_cipher_append(cipher, digest, sizeof(digest));
-		purple_cipher_append(cipher, (guchar *)":", 1);
-		purple_cipher_append(cipher, (guchar *)nonce, strlen(nonce));
-		purple_cipher_append(cipher, (guchar *)":", 1);
-		purple_cipher_append(cipher, (guchar *)client_nonce, strlen(client_nonce));
+		purple_hash_append(hash, (guchar *)digest, sizeof(digest));
+		purple_hash_append(hash, (guchar *)":", 1);
+		purple_hash_append(hash, (guchar *)nonce, strlen(nonce));
+		purple_hash_append(hash, (guchar *)":", 1);
+		purple_hash_append(hash, (guchar *)client_nonce, strlen(client_nonce));
 	}
 
-	purple_cipher_digest_to_str(cipher, sizeof(hash), hash, NULL);
-	g_object_unref(G_OBJECT(cipher));
+	purple_hash_digest_to_str(hash, sizeof(digest), digest, NULL);
+	g_object_unref(G_OBJECT(digest));
 
-	return g_strdup(hash);
+	return g_strdup(digest);
 }
 
 gchar *purple_http_digest_calculate_response(
@@ -5088,7 +5086,7 @@ gchar *purple_http_digest_calculate_resp
 		const gchar *client_nonce,
 		const gchar *session_key)
 {
-	PurpleCipher *cipher;
+	PurpleHash *hash;
 	static gchar hash2[33]; /* We only support MD5. */
 
 	g_return_val_if_fail(method      != NULL, NULL);
@@ -5108,70 +5106,70 @@ gchar *purple_http_digest_calculate_resp
 						 g_ascii_strcasecmp(qop, "auth") ||
 						 g_ascii_strcasecmp(qop, "auth-int"), NULL);
 
-	cipher = purple_md5_cipher_new();
+	hash = purple_md5_hash_new();
 
-	purple_cipher_append(cipher, (guchar *)method, strlen(method));
-	purple_cipher_append(cipher, (guchar *)":", 1);
-	purple_cipher_append(cipher, (guchar *)digest_uri, strlen(digest_uri));
+	purple_hash_append(hash, (guchar *)method, strlen(method));
+	purple_hash_append(hash, (guchar *)":", 1);
+	purple_hash_append(hash, (guchar *)digest_uri, strlen(digest_uri));
 
 	if (qop != NULL && !g_ascii_strcasecmp(qop, "auth-int"))
 	{
-		PurpleCipher *cipher2;
+		PurpleHash *hash2;
 		gchar entity_hash[33];
 
 		if (entity == NULL)
 		{
-			g_object_unref(G_OBJECT(cipher));
+			g_object_unref(G_OBJECT(hash));
 			purple_debug_error("cipher", "Required entity missing for auth-int digest calculation.\n");
 			return NULL;
 		}
 
-		cipher2 = purple_md5_cipher_new();
-		purple_cipher_append(cipher2, (guchar *)entity, strlen(entity));
-		purple_cipher_digest_to_str(cipher2, sizeof(entity_hash), entity_hash, NULL);
-		g_object_unref(G_OBJECT(cipher2));
+		hash2 = purple_md5_hash_new();
+		purple_hash_append(hash2, (guchar *)entity, strlen(entity));
+		purple_hash_digest_to_str(hash2, sizeof(entity_hash), entity_hash, NULL);
+		g_object_unref(G_OBJECT(hash2));
 
-		purple_cipher_append(cipher, (guchar *)":", 1);
-		purple_cipher_append(cipher, (guchar *)entity_hash, strlen(entity_hash));
+		purple_hash_append(hash, (guchar *)":", 1);
+		purple_hash_append(hash, (guchar *)entity_hash, strlen(entity_hash));
 	}
 
-	purple_cipher_digest_to_str(cipher, sizeof(hash2), hash2, NULL);
-	purple_cipher_reset(cipher);
+	purple_hash_digest_to_str(hash, sizeof(hash2), hash2, NULL);
+	purple_hash_reset(hash);
 
-	purple_cipher_append(cipher, (guchar *)session_key, strlen(session_key));
-	purple_cipher_append(cipher, (guchar *)":", 1);
-	purple_cipher_append(cipher, (guchar *)nonce, strlen(nonce));
-	purple_cipher_append(cipher, (guchar *)":", 1);
+	purple_hash_append(hash, (guchar *)session_key, strlen(session_key));
+	purple_hash_append(hash, (guchar *)":", 1);
+	purple_hash_append(hash, (guchar *)nonce, strlen(nonce));
+	purple_hash_append(hash, (guchar *)":", 1);
 
 	if (qop != NULL && *qop != '\0')
 	{
 		if (nonce_count == NULL)
 		{
-			g_object_unref(G_OBJECT(cipher));
+			g_object_unref(G_OBJECT(hash));
 			purple_debug_error("cipher", "Required nonce_count missing for digest calculation.\n");
 			return NULL;
 		}
 
 		if (client_nonce == NULL)
 		{
-			g_object_unref(G_OBJECT(cipher));
+			g_object_unref(G_OBJECT(hash));
 			purple_debug_error("cipher", "Required client_nonce missing for digest calculation.\n");
 			return NULL;
 		}
 
-		purple_cipher_append(cipher, (guchar *)nonce_count, strlen(nonce_count));
-		purple_cipher_append(cipher, (guchar *)":", 1);
-		purple_cipher_append(cipher, (guchar *)client_nonce, strlen(client_nonce));
-		purple_cipher_append(cipher, (guchar *)":", 1);
+		purple_hash_append(hash, (guchar *)nonce_count, strlen(nonce_count));
+		purple_hash_append(hash, (guchar *)":", 1);
+		purple_hash_append(hash, (guchar *)client_nonce, strlen(client_nonce));
+		purple_hash_append(hash, (guchar *)":", 1);
 
-		purple_cipher_append(cipher, (guchar *)qop, strlen(qop));
+		purple_hash_append(hash, (guchar *)qop, strlen(qop));
 
-		purple_cipher_append(cipher, (guchar *)":", 1);
+		purple_hash_append(hash, (guchar *)":", 1);
 	}
 
-	purple_cipher_append(cipher, (guchar *)hash2, strlen(hash2));
-	purple_cipher_digest_to_str(cipher, sizeof(hash2), hash2, NULL);
-	g_object_unref(G_OBJECT(cipher));
+	purple_hash_append(hash, (guchar *)hash2, strlen(hash2));
+	purple_hash_digest_to_str(hash, sizeof(hash2), hash2, NULL);
+	g_object_unref(G_OBJECT(hash));
 
 	return g_strdup(hash2);
 }
============================================================
--- libpurple/protocols/jabber/jutil.c	7cde7df61a0b93f0a7bf7061414fa96063ba90e4
+++ libpurple/protocols/jabber/jutil.c	08f8ab25684de99acf0fbeb3e8180f867b2c6769
@@ -26,7 +26,7 @@
 #include "debug.h"
 #include "server.h"
 #include "cipher/md4hash.h"
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 #include "cipher/sha1cipher.h"
 #include "util.h"
 #include "xmlnode.h"
@@ -745,7 +745,7 @@ jabber_calculate_data_hash(gconstpointer
 	else if (g_str_equal(hash_algo, "md4"))
 		cipher = purple_md4_hash_new();
 	else if (g_str_equal(hash_algo, "md5"))
-		cipher = purple_md5_cipher_new();
+		cipher = purple_md5_hash_new();
 	if (cipher == NULL)
 	{
 		purple_debug_error("jabber", "Could not find %s cipher\n", hash_algo);
============================================================
--- libpurple/protocols/oscar/oscar.c	c2b83ea7743a8bb85f500ab84fc142f04639f495
+++ libpurple/protocols/oscar/oscar.c	965032a50dc9c4a7b80702915391cb2eb0ddd18e
@@ -37,7 +37,7 @@
 #include "core.h"
 #include "debug.h"
 #include "imgstore.h"
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 #include "network.h"
 #include "notify.h"
 #include "privacy.h"
@@ -6817,15 +6817,15 @@ void oscar_set_icon(PurpleConnection *gc
 	if (img == NULL) {
 		aim_ssi_delicon(od);
 	} else {
-		PurpleCipher *cipher;
+		PurpleHash *hash;
 		guchar md5[16];
 		gconstpointer data = purple_imgstore_get_data(img);
 		size_t len = purple_imgstore_get_size(img);
 
-		cipher = purple_md5_cipher_new();
-		purple_cipher_append(cipher, data, len);
-		purple_cipher_digest(cipher, sizeof(md5), md5, NULL);
-		g_object_unref(G_OBJECT(cipher));
+		hash = purple_md5_hash_new();
+		purple_hash_append(hash, data, len);
+		purple_hash_digest(hash, sizeof(md5), md5, NULL);
+		g_object_unref(G_OBJECT(hash));
 
 		aim_ssi_seticon(od, md5, 16);
 	}
============================================================
--- libpurple/protocols/yahoo/libymsg.c	f7b29a2a619446bf6799589347192a518f4a77a9
+++ libpurple/protocols/yahoo/libymsg.c	0826522ecf38c06a9d803c97a2dc8c72160b9543
@@ -30,7 +30,7 @@
 #include "core.h"
 #include "debug.h"
 #include "network.h"
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 #include "notify.h"
 #include "privacy.h"
 #include "prpl.h"
@@ -1699,16 +1699,16 @@ static void yahoo_auth16_stage3(PurpleCo
 	YahooData *yd = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	PurpleAccount *account = purple_connection_get_account(gc);
 	const char *name = purple_normalize(account, purple_account_get_username(account));
-	PurpleCipher *md5_cipher;
+	PurpleHash *md5_hash;
 	guchar md5_digest[16];
 	gchar base64_string[25];
 	struct yahoo_packet *pkt;
 
 	purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage3\n");
 
-	md5_cipher = purple_md5_cipher_new();
-	purple_cipher_append(md5_cipher, (guchar *)crypt, strlen(crypt));
-	purple_cipher_digest(md5_cipher, sizeof(md5_digest), md5_digest, NULL);
+	md5_hash = purple_md5_hash_new();
+	purple_hash_append(md5_hash, (guchar *)crypt, strlen(crypt));
+	purple_hash_digest(md5_hash, sizeof(md5_digest), md5_digest, NULL);
 
 	to_y64(base64_string, md5_digest, 16);
 
@@ -1746,7 +1746,7 @@ static void yahoo_auth16_stage3(PurpleCo
 		yahoo_packet_hash_int(pkt, 192, yd->picture_checksum);
 	yahoo_packet_send_and_free(pkt, yd);
 
-	g_object_unref(G_OBJECT(md5_cipher));
+	g_object_unref(G_OBJECT(md5_hash));
 }
 
 static gchar *yahoo_auth16_get_cookie_b(gchar *headers)
============================================================
--- libpurple/protocols/msn/msn.h	21b7bbd838e3e6e23aebf470bbb17c9eacb394e9
+++ libpurple/protocols/msn/msn.h	9228d80b5383dc7729d4eda50be29adc9ff36702
@@ -89,7 +89,7 @@ typedef enum
 #include "connection.h"
 #include "conversation.h"
 #include "debug.h"
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 #include "notify.h"
 #include "privacy.h"
 #include "proxy.h"
============================================================
--- libpurple/protocols/msn/notification.c	899d0ff83dacd78d89c3b63813c32f32045db9da
+++ libpurple/protocols/msn/notification.c	ad34a155186ac338bdbdbae941694a0b2b8d0c8b
@@ -33,7 +33,7 @@
 #include "sync.h"
 #include "slplink.h"
 
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 
 static MsnTable *cbs_table;
 
@@ -1335,7 +1335,7 @@ url_cmd(MsnCmdProc *cmdproc, MsnCommand 
 	PurpleAccount *account;
 	const char *rru;
 	const char *url;
-	PurpleCipher *cipher;
+	PurpleHash *hash;
 	gchar creds[33];
 	char *buf;
 
@@ -1356,10 +1356,10 @@ url_cmd(MsnCmdProc *cmdproc, MsnCommand 
 	                      tmp_timestamp,
 	                      purple_connection_get_password(gc));
 
-	cipher = purple_md5_cipher_new();
-	purple_cipher_append(cipher, (const guchar *)buf, strlen(buf));
-	purple_cipher_digest_to_str(cipher, sizeof(creds), creds, NULL);
-	g_object_unref(G_OBJECT(cipher));
+	hash = purple_md5_hash_new();
+	purple_hash_append(hash, (const guchar *)buf, strlen(buf));
+	purple_hash_digest_to_str(hash, sizeof(creds), creds, NULL);
+	g_object_unref(G_OBJECT(hash));
 
 	g_free(buf);
 
============================================================
--- libpurple/protocols/msn/msnutils.c	8accc7885ad970c9b867ad6db05ea464e3c98fbf
+++ libpurple/protocols/msn/msnutils.c	b60d6f9f031786b42bb3bc70b43d002f3d3f3af1
@@ -24,7 +24,7 @@
 #include "msn.h"
 #include "msnutils.h"
 
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 
 char *rand_guid(void);
 
@@ -489,7 +489,7 @@ msn_handle_chl(char *input, char *output
 void
 msn_handle_chl(char *input, char *output)
 {
-	PurpleCipher *cipher;
+	PurpleHash *hash;
 	const guchar productKey[] = MSNP15_WLM_PRODUCT_KEY;
 	const guchar productID[]  = MSNP15_WLM_PRODUCT_ID;
 	const char hexChars[]     = "0123456789abcdef";
@@ -506,11 +506,11 @@ msn_handle_chl(char *input, char *output
 	int i;
 
 	/* Create the MD5 hash by using Purple MD5 algorithm */
-	cipher = purple_md5_cipher_new();
-	purple_cipher_append(cipher, (guchar *)input, strlen(input));
-	purple_cipher_append(cipher, productKey, sizeof(productKey) - 1);
-	purple_cipher_digest(cipher, sizeof(md5Hash), md5Hash, NULL);
-	g_object_unref(G_OBJECT(cipher));
+	hash = purple_md5_hash_new();
+	purple_hash_append(hash, (guchar *)input, strlen(input));
+	purple_hash_append(hash, productKey, sizeof(productKey) - 1);
+	purple_hash_digest(hash, sizeof(md5Hash), md5Hash, NULL);
+	g_object_unref(G_OBJECT(hash));
 
 	/* Split it into four integers */
 	md5Parts = (unsigned int *)md5Hash;
============================================================
--- libpurple/plugins/perl/common/module.h	833154df8e6e5425374240621cc1031c0982aeec
+++ libpurple/plugins/perl/common/module.h	ea150d92f475bb6579b2aced7e3012c7acd8abad
@@ -46,7 +46,7 @@ typedef struct group *Purple__Group;
 #include "cipher/hmaccipher.h"
 #include "imgstore.h"
 #include "cipher/md4hash.h"
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 #include "network.h"
 #include "notify.h"
 #include "plugin.h"
============================================================
--- libpurple/protocols/jabber/auth.c	e8c2264437f99db88273d134fc74e84aebdeabbd
+++ libpurple/protocols/jabber/auth.c	b7f59e3ea4da57fca61ed73e7bef17fffc7144d0
@@ -27,7 +27,7 @@
 #include "core.h"
 #include "conversation.h"
 #include "cipher/hmaccipher.h"
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 #include "request.h"
 #include "sslconn.h"
 #include "util.h"
@@ -283,11 +283,12 @@ static void auth_old_cb(JabberStream *js
 		} else if(js->stream_id && (x = xmlnode_get_child(query, "crammd5"))) {
 			const char *challenge;
 			guchar digest[33];
-			PurpleCipher *hmac, *md5;
+			PurpleCipher *hmac;
+			PurpleHash *md5;
 
 			/* Calculate the MHAC-MD5 digest */
 			challenge = xmlnode_get_attrib(x, "challenge");
-			md5 = purple_md5_cipher_new();
+			md5 = purple_md5_hash_new();
 			hmac = purple_hmac_cipher_new(md5);
 			g_object_unref(G_OBJECT(md5));
 			purple_cipher_set_key(hmac, (guchar *)pw);
============================================================
--- libpurple/protocols/msn/nexus.c	6b84597034f305313180420bbb9c1f634988858f
+++ libpurple/protocols/msn/nexus.c	01975e5880430920bf54a14ea171d5ef9839acf1
@@ -28,7 +28,6 @@
 
 #include "cipher/des3cipher.h"
 #include "cipher/hmaccipher.h"
-#include "cipher/md5cipher.h"
 #include "cipher/sha1cipher.h"
 
 /**************************************************************************
============================================================
--- libpurple/plugins/ciphertest.c	f62d5f00de77d42b125aac543d87bdea41b2764c
+++ libpurple/plugins/ciphertest.c	1633a2f7ef6a6fabae06fd219c5f6cd4b497e40f
@@ -34,7 +34,7 @@
 
 #include "cipher/cipher.h"
 #include "debug.h"
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 #include "plugin.h"
 #include "cipher/sha1cipher.h"
 #include "util.h"
@@ -70,7 +70,7 @@ cipher_test_md5(void) {
 	gboolean ret;
 	gint i = 0;
 
-	cipher = purple_md5_cipher_new();
+	cipher = purple_md5_hash_new();
 
 	purple_debug_info("cipher-test", "Running md5 tests\n");
 
============================================================
--- libpurple/plugins/perl/common/Cipher.xs	1144fc8411a80aa32117323818d49377de87fefd
+++ libpurple/plugins/perl/common/Cipher.xs	1fc94db89c77224460ea2af358c88de6aef5b055
@@ -165,11 +165,11 @@ purple_des_cipher_new()
 Purple::Cipher
 purple_des_cipher_new()
 
-MODULE = Purple::Cipher PACKAGE = Purple::MD5Cipher PREFIX = purple_md5_cipher_
+MODULE = Purple::Cipher PACKAGE = Purple::MD5Hash PREFIX = purple_md5_hash_
 PROTOTYPES: ENABLE
 
 Purple::Cipher
-purple_md5_cipher_new()
+purple_md5_hash_new()
 
 MODULE = Purple::Cipher PACKAGE = Purple::SHA1Cipher PREFIX = purple_sha1_cipher_
 PROTOTYPES: ENABLE
============================================================
--- libpurple/protocols/oscar/family_auth.c	7bd324dee54af9f0bc3a2fb675a0c36ab89930f7
+++ libpurple/protocols/oscar/family_auth.c	1b3429e9f6a2e1682818fa1da9c3dd8ce0ea2724
@@ -30,7 +30,7 @@
 
 #include <ctype.h>
 
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 
 /* #define USE_XOR_FOR_ICQ */
 
@@ -96,21 +96,21 @@ aim_encode_password_md5(const char *pass
 static int
 aim_encode_password_md5(const char *password, size_t password_len, const char *key, guint8 *digest)
 {
-	PurpleCipher *cipher;
+	PurpleHash *hash;
 	guchar passdigest[16];
 
-	cipher = purple_md5_cipher_new();
-	purple_cipher_append(cipher, (const guchar *)password, password_len);
-	purple_cipher_digest(cipher, 16, passdigest, NULL);
+	hash = purple_md5_hash_new();
+	purple_hash_append(hash, (const guchar *)password, password_len);
+	purple_hash_digest(hash, 16, passdigest, NULL);
 
-	purple_cipher_reset(cipher);
+	purple_hash_reset(hash);
 
-	purple_cipher_append(cipher, (const guchar *)key, strlen(key));
-	purple_cipher_append(cipher, passdigest, 16);
-	purple_cipher_append(cipher, (const guchar *)AIM_MD5_STRING, strlen(AIM_MD5_STRING));
-	purple_cipher_digest(cipher, 16, digest, NULL);
+	purple_hash_append(hash, (const guchar *)key, strlen(key));
+	purple_hash_append(hash, passdigest, 16);
+	purple_hash_append(hash, (const guchar *)AIM_MD5_STRING, strlen(AIM_MD5_STRING));
+	purple_hash_digest(hash, 16, digest, NULL);
 
-	g_object_unref(G_OBJECT(cipher));
+	g_object_unref(G_OBJECT(hash));
 
 	return 0;
 }
============================================================
--- libpurple/protocols/oscar/family_oservice.c	127346519e71a9ae95014c876c757cbcb7a760cd
+++ libpurple/protocols/oscar/family_oservice.c	7a606ac371d3d2ae8492ff941481553184336ffc
@@ -25,7 +25,7 @@
 
 #include "oscar.h"
 
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 
 /*
  * Each time we make a FLAP connection to an oscar server the server gives
@@ -1022,18 +1022,18 @@ aim_sendmemblock(OscarData *od, FlapConn
 		byte_stream_putraw(&bs, buf, 0x10);
 
 	} else if (buf && (len > 0)) { /* use input buffer */
-		PurpleCipher *cipher;
+		PurpleHash *hash;
 		guchar digest[16];
 
-		cipher = purple_md5_cipher_new();
-		purple_cipher_append(cipher, buf, len);
-		purple_cipher_digest(cipher, sizeof(digest), digest, NULL);
-		g_object_unref(G_OBJECT(cipher));
+		hash = purple_md5_hash_new();
+		purple_hash_append(hash, buf, len);
+		purple_hash_digest(hash, sizeof(digest), digest, NULL);
+		g_object_unref(G_OBJECT(hash));
 
 		byte_stream_putraw(&bs, digest, 0x10);
 
 	} else if (len == 0) { /* no length, just hash NULL (buf is optional) */
-		PurpleCipher *cipher;
+		PurpleHash *hash;
 		guchar digest[16];
 		guint8 nil = '\0';
 
@@ -1041,10 +1041,10 @@ aim_sendmemblock(OscarData *od, FlapConn
 		 * I'm not sure if we really need the empty append with the
 		 * new MD5 functions, so I'll leave it in, just in case.
 		 */
-		cipher = purple_md5_cipher_new();
-		purple_cipher_append(cipher, &nil, 0);
-		purple_cipher_digest(cipher, sizeof(digest), digest, NULL);
-		g_object_unref(G_OBJECT(cipher));
+		hash = purple_md5_hash_new();
+		purple_hash_append(hash, &nil, 0);
+		purple_hash_digest(hash, sizeof(digest), digest, NULL);
+		g_object_unref(G_OBJECT(hash));
 
 		byte_stream_putraw(&bs, digest, 0x10);
 
============================================================
--- libpurple/protocols/qq/utils.c	38a6f1f66f8f500303a73bfa4490e95c6661be8f
+++ libpurple/protocols/qq/utils.c	8b22fa6a932c402ab93a44a4448ed7665c1e0cd5
@@ -32,7 +32,7 @@
 #include "win32dep.h"
 #endif
 
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 
 #include "char_conv.h"
 #include "debug.h"
@@ -54,15 +54,15 @@ void qq_get_md5(guint8 *md5, gint md5_le
 
 void qq_get_md5(guint8 *md5, gint md5_len, const guint8* const src, gint src_len)
 {
-	PurpleCipher *cipher;
+	PurpleHash *hash;
 
 	g_return_if_fail(md5 != NULL && md5_len > 0);
 	g_return_if_fail(src != NULL && src_len > 0);
 
-	cipher = purple_md5_cipher_new();
-	purple_cipher_append(cipher, src, src_len);
-	purple_cipher_digest(cipher, md5_len, md5, NULL);
-	g_object_unref(G_OBJECT(cipher));
+	hash = purple_md5_hash_new();
+	purple_hash_append(hash, src, src_len);
+	purple_hash_digest(hash, md5_len, md5, NULL);
+	g_object_unref(G_OBJECT(hash));
 }
 
 gchar *get_name_by_index_str(gchar **array, const gchar *index_str, gint amount)
============================================================
--- libpurple/Makefile.am	87bbf9b68cb8ed415128e22dda844382d421cbd8
+++ libpurple/Makefile.am	32c07ea463333ff79fcfa581df903ab8852a3a8b
@@ -52,7 +52,7 @@ purple_coresources = \
 	cipher/hash.c \
 	cipher/hmaccipher.c \
 	cipher/md4hash.c \
-	cipher/md5cipher.c \
+	cipher/md5hash.c \
 	cipher/rc4cipher.c \
 	cipher/sha1cipher.c \
 	cipher/sha256cipher.c \
@@ -135,7 +135,7 @@ purple_coreheaders = \
 	cipher/hash.h \
 	cipher/hmaccipher.h \
 	cipher/md4hash.h \
-	cipher/md5cipher.h \
+	cipher/md5hash.h \
 	cipher/rc4cipher.h \
 	cipher/sha1cipher.h \
 	cipher/sha256cipher.h \
============================================================
--- libpurple/Makefile.mingw	9705a14a3466c3db1fe5c69b26564866f27ddce7
+++ libpurple/Makefile.mingw	9ce4ff44aa68cede477aaef0bf922eed14e29724
@@ -42,7 +42,7 @@ C_SRC =	\
 			cipher/hash.c \
 			cipher/hmaccipher.c \
 			cipher/md4hash.c \
-			cipher/md5cipher.c \
+			cipher/md5hash.c \
 			cipher/rc4cipher.c \
 			cipher/sha1cipher.c \
 			cipher/sha256cipher.c \
============================================================
--- libpurple/tests/test_cipher.c	5064c6b9326da2fa8789e6332bba33d84efc0a4e
+++ libpurple/tests/test_cipher.c	40bf7024b099e3cac9bf026a994bedf425e68e43
@@ -8,9 +8,9 @@
 
 #include "tests.h"
 
-#include "../md4cipher.h"
-#include "../md5cipher.h"
-#include "../sha1cipher.h"
+#include "../cipher/md4hash.h"
+#include "../cipher/md5hash.h"
+#include "../cipher/sha1cipher.h"
 
 /******************************************************************************
  * MD4 Tests
@@ -20,7 +20,7 @@
 	gchar cdigest[33]; \
 	gboolean ret = FALSE; \
 	\
-	cipher = purple_md4_cipher_new(); \
+	cipher = purple_md4_hash_new(); \
 	purple_cipher_append(cipher, (guchar *)(data), strlen((data))); \
 	\
 	ret = purple_cipher_digest_to_str(cipher, sizeof(cdigest), cdigest, \
@@ -81,7 +81,7 @@ END_TEST
 	gchar cdigest[33]; \
 	gboolean ret = FALSE; \
 	\
-	cipher = purple_md5_cipher_new(); \
+	cipher = purple_md5_hash_new(); \
 	purple_cipher_append(cipher, (guchar *)(data), strlen((data))); \
 	\
 	ret = purple_cipher_digest_to_str(cipher, sizeof(cdigest), cdigest, \
@@ -197,16 +197,14 @@ END_TEST
  *****************************************************************************/
 #define SHA256_TEST(data, digest) { \
 	PurpleCipher *cipher = NULL; \
-	PurpleCipherContext *context = NULL; \
 	gchar cdigest[65]; \
 	gboolean ret = FALSE; \
 	gchar *input = data; \
 	\
-	cipher = purple_ciphers_find_cipher("sha256"); \
-	context = purple_cipher_context_new(cipher, NULL); \
+	cipher = purple_sha256_cipher_new(); \
 	\
 	if (input) { \
-		purple_cipher_context_append(context, (guchar *)input, strlen(input)); \
+		purple_cipher_append(cipher, (guchar *)input, strlen(input)); \
 	} else { \
 		gint j; \
 		guchar buff[1000]; \
@@ -214,17 +212,17 @@ END_TEST
 		memset(buff, 'a', 1000); \
 		\
 		for(j = 0; j < 1000; j++) \
-			purple_cipher_context_append(context, buff, 1000); \
+			purple_cipher_append(cipher, buff, 1000); \
 	} \
 	\
-	ret = purple_cipher_context_digest_to_str(context, sizeof(cdigest), cdigest, \
+	ret = purple_cipher_digest_to_str(cipher, sizeof(cdigest), cdigest, \
 	                                        NULL); \
 	\
 	fail_unless(ret == TRUE, NULL); \
 	\
 	fail_unless(strcmp((digest), cdigest) == 0, NULL); \
 	\
-	purple_cipher_context_destroy(context); \
+	g_object_unref(G_OBJECT(cipher)); \
 }
 
 START_TEST(test_sha256_empty_string) {
@@ -498,7 +496,7 @@ START_TEST(test_hmac_md5_Hi) {
 	          8,
 	          "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
 	          16,
-	          purple_md5_cipher_new(),
+	          purple_md5_hash_new(),
 	          "9294727a3638bb1c13f48ef8158bfc9d");
 }
 END_TEST
@@ -508,7 +506,7 @@ START_TEST(test_hmac_md5_what) {
 	          28,
 	          "Jefe",
 	          4,
-	          purple_md5_cipher_new(),
+	          purple_md5_hash_new(),
 	          "750c783e6ab0b503eaa86e310a5db738");
 }
 END_TEST
@@ -522,7 +520,7 @@ START_TEST(test_hmac_md5_dd) {
 	          50,
 	          "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
 	          16,
-	          purple_md5_cipher_new(),
+	          purple_md5_hash_new(),
 	          "56be34521d144c88dbb8c733f0e8b3f6");
 }
 END_TEST
@@ -538,7 +536,7 @@ START_TEST(test_hmac_md5_cd) {
 	          "\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
 	          "\x15\x16\x17\x18\x19",
 	          25,
-	          purple_md5_cipher_new(),
+	          purple_md5_hash_new(),
 	          "697eaf0aca3a3aea3a75164746ffaa79");
 }
 END_TEST
@@ -548,7 +546,7 @@ START_TEST(test_hmac_md5_truncation) {
 	          20,
 	          "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
 	          16,
-	          purple_md5_cipher_new(),
+	          purple_md5_hash_new(),
 	          "56461ef2342edc00f9bab995690efd4c");
 }
 END_TEST
@@ -565,7 +563,7 @@ START_TEST(test_hmac_md5_large_key) {
 	          "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
 	          "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
 	          80,
-	          purple_md5_cipher_new(),
+	          purple_md5_hash_new(),
 	          "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd");
 }
 END_TEST
@@ -582,7 +580,7 @@ START_TEST(test_hmac_md5_large_key_and_d
 	          "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
 	          "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
 	          80,
-	          purple_md5_cipher_new(),
+	          purple_md5_hash_new(),
 	          "6f630fad67cda0ee1fb1f562db3aa53e");
 }
 END_TEST
@@ -593,7 +591,7 @@ START_TEST(test_hmac_md5_null_key) {
 	          "\x0a\x0b\x00\x0d\x0e\x0f\x1a\x2f\x0b\x0b"
 	          "\x0b\x00\x00\x0b\x0b\x49\x5f\x6e\x0b\x0b",
 	          20,
-	          purple_md5_cipher_new(),
+	          purple_md5_hash_new(),
 	          "597bfd644b797a985561eeb03a169e59");
 }
 END_TEST
@@ -604,7 +602,7 @@ START_TEST(test_hmac_md5_null_text) {
 	          "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
 	          "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
 	          20,
-	          purple_md5_cipher_new(),
+	          purple_md5_hash_new(),
 	          "70be8e1b7b50dfcc335d6cd7992c564f");
 }
 END_TEST
@@ -615,7 +613,7 @@ START_TEST(test_hmac_md5_null_key_and_te
 	          "\x0c\x0d\x00\x0f\x10\x1a\x3a\x3a\xe6\x34"
 	          "\x0b\x00\x00\x0b\x0b\x49\x5f\x6e\x0b\x0b",
 	          20,
-	          purple_md5_cipher_new(),
+	          purple_md5_hash_new(),
 	          "b31bcbba35a33a067cbba9131cba4889");
 }
 END_TEST
============================================================
--- libpurple/cipher/md5cipher.c	cf8dd3e4e61e04ce1bc723dd10db38a83b447c2c
+++ libpurple/cipher/md5hash.c	a0065a58b8d7dbbc7b625d6625161c73beabfdda
@@ -2,21 +2,30 @@
  * Original md5
  * Copyright (C) 2001-2003  Christophe Devine <c.devine at cr0.net>
  */
-#include "md5cipher.h"
+#include "md5hash.h"
+#include "hmaccipher.h"
 
 #include <string.h>
 
+#undef GLIB_MINOR_VERSION
+#define GLIB_MINOR_VERSION 1
+
 #define MD5_HMAC_BLOCK_SIZE	64
 
+#if !GLIB_CHECK_VERSION(2,16,0)
+#define PURPLE_MD5_HASH_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_MD5_HASH, PurpleMD5HashPrivate))
+#endif
+
 /******************************************************************************
  * Structs
  *****************************************************************************/
 #if !GLIB_CHECK_VERSION(2,16,0)
-struct _PurpleMD5CipherPriv {
+typedef struct {
 	guint32 total[2];
 	guint32 state[4];
 	guchar buffer[64];
-};
+} PurpleMD5HashPrivate;
 #endif
 /******************************************************************************
  * Globals
@@ -41,32 +50,32 @@ static GObjectClass *parent_class = NULL
 }
 
 /******************************************************************************
- * Cipher Stuff
+ * Hash Stuff
  *****************************************************************************/
 #if !GLIB_CHECK_VERSION(2,16,0)
 static void
-purple_md5_cipher_reset(PurpleCipher *cipher) {
-	PurpleMD5Cipher *md5_cipher = PURPLE_MD5_CIPHER(cipher);
+purple_md5_hash_reset(PurpleHash *hash) {
+	PurpleMD5HashPrivate *priv = PURPLE_MD5_HASH_GET_PRIVATE(hash);
 
-	md5_cipher->priv->total[0] = 0;
-	md5_cipher->priv->total[1] = 0;
+	priv->total[0] = 0;
+	priv->total[1] = 0;
 
-	md5_cipher->priv->state[0] = 0x67452301;
-	md5_cipher->priv->state[1] = 0xEFCDAB89;
-	md5_cipher->priv->state[2] = 0x98BADCFE;
-	md5_cipher->priv->state[3] = 0x10325476;
+	priv->state[0] = 0x67452301;
+	priv->state[1] = 0xEFCDAB89;
+	priv->state[2] = 0x98BADCFE;
+	priv->state[3] = 0x10325476;
 
-	memset(md5_cipher->priv->buffer, 0, sizeof(md5_cipher->priv->buffer));
+	memset(priv->buffer, 0, sizeof(priv->buffer));
 }
 
 static void
-purple_md5_cipher_process(PurpleMD5Cipher *md5_cipher, const guchar data[64]) {
+purple_md5_hash_process(PurpleMD5HashPrivate *priv, const guchar data[64]) {
 	guint32 X[16], A, B, C, D;
 
-	A = md5_cipher->priv->state[0];
-	B = md5_cipher->priv->state[1];
-	C = md5_cipher->priv->state[2];
-	D = md5_cipher->priv->state[3];
+	A = priv->state[0];
+	B = priv->state[1];
+	C = priv->state[2];
+	D = priv->state[3];
 
 	MD5_GET_GUINT32(X[ 0], data,  0);
 	MD5_GET_GUINT32(X[ 1], data,  4);
@@ -173,52 +182,52 @@ purple_md5_cipher_process(PurpleMD5Ciphe
 	#undef P
 	#undef S
 
-	md5_cipher->priv->state[0] += A;
-	md5_cipher->priv->state[1] += B;
-	md5_cipher->priv->state[2] += C;
-	md5_cipher->priv->state[3] += D;
+	priv->state[0] += A;
+	priv->state[1] += B;
+	priv->state[2] += C;
+	priv->state[3] += D;
 }
 
 static void
-purple_md5_cipher_append(PurpleCipher *cipher, const guchar *data,
+purple_md5_hash_append(PurpleHash *hash, const guchar *data,
 						 size_t len)
 {
-	PurpleMD5Cipher *md5_cipher = PURPLE_MD5_CIPHER(cipher);
+	PurpleMD5HashPrivate *priv = PURPLE_MD5_HASH_GET_PRIVATE(hash);
 	guint32 left = 0, fill = 0;
 
-	left = md5_cipher->priv->total[0] & 0x3F;
+	left = priv->total[0] & 0x3F;
 	fill = 64 - left;
 
-	md5_cipher->priv->total[0] += len;
-	md5_cipher->priv->total[0] &= 0xFFFFFFFF;
+	priv->total[0] += len;
+	priv->total[0] &= 0xFFFFFFFF;
 
-	if(md5_cipher->priv->total[0] < len)
-		md5_cipher->priv->total[1]++;
+	if(priv->total[0] < len)
+		priv->total[1]++;
 
 	if(left && len >= fill) {
-		memcpy((md5_cipher->priv->buffer + left), data, fill);
-		purple_md5_cipher_process(md5_cipher, md5_cipher->priv->buffer);
+		memcpy((priv->buffer + left), data, fill);
+		purple_md5_hash_process(priv, priv->buffer);
 		len -= fill;
 		data += fill;
 		left = 0;
 	}
 
 	while(len >= 64) {
-		purple_md5_cipher_process(md5_cipher, data);
+		purple_md5_hash_process(priv, data);
 		len -= 64;
 		data += 64;
 	}
 
 	if(len) {
-		memcpy((md5_cipher->priv->buffer + left), data, len);
+		memcpy((priv->buffer + left), data, len);
 	}
 }
 
 static gboolean
-purple_md5_cipher_digest(PurpleCipher *cipher, size_t in_len,
+purple_md5_hash_digest(PurpleHash *hash, size_t in_len,
 						 guchar digest[16], size_t *out_len)
 {
-	PurpleMD5Cipher *md5_cipher = PURPLE_MD5_CIPHER(cipher);
+	PurpleMD5HashPrivate *priv = PURPLE_MD5_HASH_GET_PRIVATE(hash);
 	guint32 last, pad;
 	guint32 high, low;
 	guchar message[8];
@@ -231,23 +240,23 @@ purple_md5_cipher_digest(PurpleCipher *c
 
 	g_return_val_if_fail(in_len >= 16, FALSE);
 
-	high = (md5_cipher->priv->total[0] >> 23)
-		 | (md5_cipher->priv->total[1] << 3);
-	low = (md5_cipher->priv->total[0] << 3);
+	high = (priv->total[0] >> 23)
+		 | (priv->total[1] << 3);
+	low = (priv->total[0] << 3);
 
 	MD5_PUT_GUINT32(low, message, 0);
 	MD5_PUT_GUINT32(high, message, 4);
 
-	last = md5_cipher->priv->total[0] & 0x3F;
+	last = priv->total[0] & 0x3F;
 	pad = (last < 56) ? (56 - last) : (120 - last);
 
-	purple_md5_cipher_append(cipher, padding, pad);
-	purple_md5_cipher_append(cipher, message, 8);
+	purple_md5_hash_append(hash, padding, pad);
+	purple_md5_hash_append(hash, message, 8);
 
-	MD5_PUT_GUINT32(md5_cipher->priv->state[0], digest, 0);
-	MD5_PUT_GUINT32(md5_cipher->priv->state[1], digest, 4);
-	MD5_PUT_GUINT32(md5_cipher->priv->state[2], digest, 8);
-	MD5_PUT_GUINT32(md5_cipher->priv->state[3], digest, 12);
+	MD5_PUT_GUINT32(priv->state[0], digest, 0);
+	MD5_PUT_GUINT32(priv->state[1], digest, 4);
+	MD5_PUT_GUINT32(priv->state[2], digest, 8);
+	MD5_PUT_GUINT32(priv->state[3], digest, 12);
 
 	if(out_len)
 		*out_len = 16;
@@ -256,101 +265,116 @@ purple_md5_cipher_digest(PurpleCipher *c
 }
 #endif /* !GLIB_CHECK_VERSION(2,16,0) */
 
-static size_t
-purple_md5_cipher_get_block_size(PurpleCipher *cipher)
-{
-	return MD5_HMAC_BLOCK_SIZE;
-}
-
 /******************************************************************************
  * Object Stuff
  *****************************************************************************/
 #if !GLIB_CHECK_VERSION(2,16,0)
 static void
-purple_md5_cipher_finalize(GObject *obj) {
-	PurpleCipher *cipher = PURPLE_CIPHER(obj);
-	PurpleMD5Cipher *md5_cipher = PURPLE_MD5_CIPHER(obj);
+purple_md5_hash_finalize(GObject *obj) {
+	PurpleHash *hash = PURPLE_HASH(obj);
+	PurpleMD5HashPrivate *priv = PURPLE_MD5_HASH_GET_PRIVATE(obj);
 
-	/* reset the cipher so we don't leave any data around... */
-	purple_md5_cipher_reset(cipher);
+	/* reset the hash so we don't leave any data around... */
+	purple_md5_hash_reset(hash);
 
-	g_free(md5_cipher->priv);
+	g_free(priv);
 }
 #endif /* GLIB_CHECK_VERSION(2,16,0) */
 
 static void
-purple_md5_cipher_class_init(PurpleMD5CipherClass *klass) {
+purple_md5_hash_class_init(PurpleMD5HashClass *klass) {
 #if !GLIB_CHECK_VERSION(2,16,0)
 	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
 #endif
-	PurpleCipherClass *cipher_class = PURPLE_CIPHER_CLASS(klass);
+	PurpleHashClass *hash_class = PURPLE_HASH_CLASS(klass);
 
 	parent_class = g_type_class_peek_parent(klass);
 
+	g_type_class_add_private(klass, sizeof(PurpleMD5HashPrivate));
+
 #if !GLIB_CHECK_VERSION(2,16,0)
-	obj_class->finalize = purple_md5_cipher_finalize;
+	obj_class->finalize = purple_md5_hash_finalize;
 
-	cipher_class->reset = purple_md5_cipher_reset;
-	cipher_class->append = purple_md5_cipher_append;
-	cipher_class->digest = purple_md5_cipher_digest;
+	hash_class->reset = purple_md5_hash_reset;
+	hash_class->append = purple_md5_hash_append;
+	hash_class->digest = purple_md5_hash_digest;
 #endif
-	cipher_class->get_block_size = purple_md5_cipher_get_block_size;
 }
 
 static void
-purple_md5_cipher_init(PurpleCipher *cipher) {
+purple_md5_hash_init(PurpleHash *hash) {
 #if !GLIB_CHECK_VERSION(2,16,0)
-	PurpleMD5Cipher *md5_cipher = PURPLE_MD5_CIPHER(cipher);
+	PurpleMD5HashPrivate *priv = PURPLE_MD5_HASH_GET_PRIVATE(hash);
 
-	md5_cipher->priv = g_new0(PurpleMD5CipherPriv, 1);
+	priv = g_new0(PurpleMD5HashPrivate, 1);
 
-	purple_md5_cipher_reset(cipher);
+	purple_md5_hash_reset(hash);
 #endif
 }
 
 /******************************************************************************
+ * HMACFunction Stuff
+ *****************************************************************************/
+static size_t
+purple_md5_hash_get_block_size(const PurpleHMACFunction *function) {
+	return MD5_HMAC_BLOCK_SIZE;
+}
+
+static void
+purple_md5_hash_hmac_function_init(PurpleHMACFunctionIface *iface) {
+	iface->get_block_size = purple_md5_hash_get_block_size;
+}
+
+/******************************************************************************
  * API
  *****************************************************************************/
 GType
-purple_md5_cipher_get_gtype(void) {
+purple_md5_hash_get_gtype(void) {
 	static GType type = 0;
 
 	if(type == 0) {
 		static const GTypeInfo info = {
-			sizeof(PurpleMD5CipherClass),
+			sizeof(PurpleMD5HashClass),
 			NULL,
 			NULL,
-			(GClassInitFunc)purple_md5_cipher_class_init,
+			(GClassInitFunc)purple_md5_hash_class_init,
 			NULL,
 			NULL,
-			sizeof(PurpleMD5Cipher),
+			sizeof(PurpleMD5Hash),
 			0,
-			(GInstanceInitFunc)purple_md5_cipher_init,
+			(GInstanceInitFunc)purple_md5_hash_init,
 			NULL,
 		};
+		static const GInterfaceInfo hmac_info = {
+			(GInterfaceInitFunc)purple_md5_hash_hmac_function_init,
+			NULL,
+			NULL
+		};
 
 		GType parent = G_TYPE_INVALID;
 #if GLIB_CHECK_VERSION(2,16,0)
 		parent = PURPLE_TYPE_G_HASH;
 #else
-		parent = PURPLE_TYPE_CIPHER;
+		parent = PURPLE_TYPE_HASH;
 #endif
 
 		type = g_type_register_static(parent,
-									  "PurpleMD5Cipher",
+									  "PurpleMD5Hash",
 									  &info, 0);
+
+		g_type_add_interface_static(type, PURPLE_TYPE_HMAC_FUNCTION, &hmac_info);
 	}
 
 	return type;
 }
 
-PurpleCipher *
-purple_md5_cipher_new(void) {
+PurpleHash *
+purple_md5_hash_new(void) {
 #if GLIB_CHECK_VERSION(2,16,0)
-	return g_object_new(PURPLE_TYPE_MD5_CIPHER,
+	return g_object_new(PURPLE_TYPE_MD5_HASH,
 		"checksum_type", G_CHECKSUM_MD5,
 		NULL);
 #else
-	return g_object_new(PURPLE_TYPE_MD5_CIPHER);
+	return g_object_new(PURPLE_TYPE_MD5_HASH, NULL);
 #endif
 }
============================================================
--- libpurple/cipher/md5cipher.h	69d3380069f6b9ec0368978235a24b8ecdfba624
+++ libpurple/cipher/md5hash.h	8229b24d7e77db32f393f64f3570d656663aaa80
@@ -1,5 +1,5 @@
 /**
- * @file cipher.h Purple Cipher API
+ * @file hash.h Purple Hash API
  * @ingroup core
  *
  * purple
@@ -22,31 +22,34 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#ifndef PURPLE_MD5_CIPHER_H
-#define PURPLE_MD5_CIPHER_H
+#ifndef PURPLE_MD5_HASH_H
+#define PURPLE_MD5_HASH_H
 
-#include <cipher/cipher.h>
 #include <cipher/ghash.h>
+#include <cipher/hash.h>
 
-#define PURPLE_TYPE_MD5_CIPHER				(purple_md5_cipher_get_gtype())
-#define PURPLE_MD5_CIPHER(obj)				(G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MD5_CIPHER, PurpleMD5Cipher))
-#define PURPLE_MD5_CIPHER_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MD5_CIPHER, PurpleMD5CipherClass))
-#define PURPLE_IS_MD5_CIPHER(obj)			(G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MD5_CIPHER))
-#define PURPLE_IS_MD5_CIPHER_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE((obj), PURPLE_TYPE_MD5_CIPHER))
-#define PURPLE_MD5_CIPHER_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MD5_CIPHER, PurpleMD5CipherClass))
+#undef GLIB_MINOR_VERSION
+#define GLIB_MINOR_VERSION 1
 
-typedef struct _PurpleMD5Cipher				PurpleMD5Cipher;
-typedef struct _PurpleMD5CipherPriv			PurpleMD5CipherPriv;
-typedef struct _PurpleMD5CipherClass		PurpleMD5CipherClass;
+#define PURPLE_TYPE_MD5_HASH				(purple_md5_hash_get_gtype())
+#define PURPLE_MD5_HASH(obj)				(G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MD5_HASH, PurpleMD5Hash))
+#define PURPLE_MD5_HASH_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MD5_HASH, PurpleMD5HashClass))
+#define PURPLE_IS_MD5_HASH(obj)			(G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MD5_HASH))
+#define PURPLE_IS_MD5_HASH_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE((obj), PURPLE_TYPE_MD5_HASH))
+#define PURPLE_MD5_HASH_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MD5_HASH, PurpleMD5HashClass))
 
-struct _PurpleMD5Cipher {
+typedef struct _PurpleMD5Hash				PurpleMD5Hash;
+typedef struct _PurpleMD5HashPriv			PurpleMD5HashPriv;
+typedef struct _PurpleMD5HashClass		PurpleMD5HashClass;
+
+struct _PurpleMD5Hash {
 #if GLIB_CHECK_VERSION(2,16,0)
 	PurpleGHash parent;
 #else
-	PurpleCipher parent;
+	PurpleHash parent;
 #endif
 
-	PurpleMD5CipherPriv *priv;
+	PurpleMD5HashPriv *priv;
 
 	void (*_purple_reserved1)(void);
 	void (*_purple_reserved2)(void);
@@ -54,11 +57,11 @@ struct _PurpleMD5Cipher {
 	void (*_purple_reserved4)(void);
 };
 
-struct _PurpleMD5CipherClass {
+struct _PurpleMD5HashClass {
 #if GLIB_CHECK_VERSION(2,16,0)
 	PurpleGHashClass parent;
 #else
-	PurpleCipherClass parent;
+	PurpleHashClass parent;
 #endif
 
 	void (*_purple_reserved1)(void);
@@ -69,10 +72,11 @@ G_BEGIN_DECLS
 
 G_BEGIN_DECLS
 
-GType purple_md5_cipher_get_gtype(void);
+GType purple_md5_hash_get_gtype(void);
 
-PurpleCipher *purple_md5_cipher_new(void);
+PurpleHash *purple_md5_hash_new(void);
 
 G_END_DECLS
 
-#endif /* PURPLE_MD5_CIPHER_H */
+#endif /* PURPLE_MD5_HASH_H */
+
============================================================
--- libpurple/protocols/jabber/caps.c	911bd02e2d590814c7a78191e1835eb62a609f4b
+++ libpurple/protocols/jabber/caps.c	bebbe2d313fce0d3bab731baaa0646a40bdf1a63
@@ -23,7 +23,7 @@
 
 #include "internal.h"
 #include "cipher/cipher.h"
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 #include "cipher/sha1cipher.h"
 
 #include "debug.h"
@@ -468,7 +468,7 @@ jabber_caps_client_iqcb(JabberStream *js
 		if (!strcmp(userdata->hash, "sha-1")) {
 			hash = jabber_caps_calculate_hash(info, PURPLE_CIPHER(purple_sha1_cipher_new()));
 		} else if (!strcmp(userdata->hash, "md5")) {
-			hash = jabber_caps_calculate_hash(info, PURPLE_CIPHER(purple_md5_cipher_new()));
+			hash = jabber_caps_calculate_hash(info, PURPLE_CIPHER(purple_md5_hash_new()));
 		}
 
 		if (!hash || strcmp(hash, userdata->ver)) {
============================================================
--- libpurple/protocols/jabber/auth_digest_md5.c	76be7e49505301e8ff4f156d81f6baa9abac2a65
+++ libpurple/protocols/jabber/auth_digest_md5.c	e1ff6072f49587a123c62cc464094fc0444d1526
@@ -23,7 +23,7 @@
 #include "internal.h"
 
 #include "debug.h"
-#include "cipher/md5cipher.h"
+#include "cipher/md5hash.h"
 #include "util.h"
 #include "xmlnode.h"
 
@@ -105,7 +105,7 @@ generate_response_value(JabberID *jid, c
 generate_response_value(JabberID *jid, const char *passwd, const char *nonce,
 		const char *cnonce, const char *a2, const char *realm)
 {
-	PurpleCipher *cipher;
+	PurpleHash *hash;
 	guchar result[16];
 	size_t a1len;
 
@@ -120,34 +120,34 @@ generate_response_value(JabberID *jid, c
 		convpasswd = g_strdup(passwd);
 	}
 
-	cipher = purple_md5_cipher_new();
+	hash = purple_md5_hash_new();
 
 	x = g_strdup_printf("%s:%s:%s", convnode, realm, convpasswd ? convpasswd : "");
-	purple_cipher_append(cipher, (const guchar *)x, strlen(x));
-	purple_cipher_digest(cipher, sizeof(result), result, NULL);
+	purple_hash_append(hash, (const guchar *)x, strlen(x));
+	purple_hash_digest(hash, sizeof(result), result, NULL);
 
 	a1 = g_strdup_printf("xxxxxxxxxxxxxxxx:%s:%s", nonce, cnonce);
 	a1len = strlen(a1);
 	g_memmove(a1, result, 16);
 
-	purple_cipher_reset(cipher);
-	purple_cipher_append(cipher, (const guchar *)a1, a1len);
-	purple_cipher_digest(cipher, sizeof(result), result, NULL);
+	purple_hash_reset(hash);
+	purple_hash_append(hash, (const guchar *)a1, a1len);
+	purple_hash_digest(hash, sizeof(result), result, NULL);
 
 	ha1 = purple_base16_encode(result, 16);
 
-	purple_cipher_reset(cipher);
-	purple_cipher_append(cipher, (const guchar *)a2, strlen(a2));
-	purple_cipher_digest(cipher, sizeof(result), result, NULL);
+	purple_hash_reset(hash);
+	purple_hash_append(hash, (const guchar *)a2, strlen(a2));
+	purple_hash_digest(hash, sizeof(result), result, NULL);
 
 	ha2 = purple_base16_encode(result, 16);
 
 	kd = g_strdup_printf("%s:%s:00000001:%s:auth:%s", ha1, nonce, cnonce, ha2);
 
-	purple_cipher_reset(cipher);
-	purple_cipher_append(cipher, (const guchar *)kd, strlen(kd));
-	purple_cipher_digest(cipher, sizeof(result), result, NULL);
-	g_object_unref(G_OBJECT(cipher));
+	purple_hash_reset(hash);
+	purple_hash_append(hash, (const guchar *)kd, strlen(kd));
+	purple_hash_digest(hash, sizeof(result), result, NULL);
+	g_object_unref(G_OBJECT(hash));
 
 	z = purple_base16_encode(result, 16);
 


More information about the Commits mailing list