gobjectification: f4d7e788: Rename PurpleSHA1Cipher to PurpleSHA1Has...

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


----------------------------------------------------------------------
Revision: f4d7e788d24c94d725d95d65f21fe9e2c7afa78d
Parent:   1ea3fb9f6bbdd9ed212710c61f806308ebb3d8ac
Author:   qulogic at pidgin.im
Date:     07/11/10 01:37:03
Branch:   im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/f4d7e788d24c94d725d95d65f21fe9e2c7afa78d

Changelog: 

Rename PurpleSHA1Cipher to PurpleSHA1Hash.

Changes against parent 1ea3fb9f6bbdd9ed212710c61f806308ebb3d8ac

  renamed  libpurple/cipher/sha1cipher.c
       to  libpurple/cipher/sha1hash.c
  renamed  libpurple/cipher/sha1cipher.h
       to  libpurple/cipher/sha1hash.h
  patched  libpurple/Makefile.am
  patched  libpurple/Makefile.mingw
  patched  libpurple/cipher/sha1hash.c
  patched  libpurple/cipher/sha1hash.h
  patched  libpurple/plugins/perl/common/Cipher.xs
  patched  libpurple/plugins/perl/common/module.h
  patched  libpurple/protocols/bonjour/bonjour_ft.c
  patched  libpurple/protocols/jabber/auth_scram.c
  patched  libpurple/protocols/jabber/auth_scram.h
  patched  libpurple/protocols/jabber/caps.c
  patched  libpurple/protocols/jabber/caps.h
  patched  libpurple/protocols/jabber/jutil.c
  patched  libpurple/protocols/msn/directconn.c
  patched  libpurple/protocols/msn/msn.h
  patched  libpurple/protocols/msn/nexus.c
  patched  libpurple/protocols/msn/object.c
  patched  libpurple/protocols/msn/user.c
  patched  libpurple/protocols/myspace/myspace.c
  patched  libpurple/protocols/myspace/myspace.h
  patched  libpurple/protocols/yahoo/libymsg.c
  patched  libpurple/util.c

-------------- next part --------------
============================================================
--- libpurple/util.c	04ec97862710a85b62ef43a574f27e5fc167605c
+++ libpurple/util.c	29e3c18815ef7cf1a77c8175ee479dc2da07f5c6
@@ -27,7 +27,7 @@
 #include "core.h"
 #include "debug.h"
 #include "cipher/md5hash.h"
-#include "cipher/sha1cipher.h"
+#include "cipher/sha1hash.h"
 #include "notify.h"
 #include "ntlm.h"
 #include "prpl.h"
@@ -2754,19 +2754,19 @@ purple_util_get_image_checksum(gconstpoi
 char *
 purple_util_get_image_checksum(gconstpointer image_data, size_t image_len)
 {
-	PurpleCipher *cipher = NULL;
+	PurpleHash *hash = NULL;
 	gchar digest[41];
 
-	cipher = purple_sha1_cipher_new();
+	hash = purple_sha1_hash_new();
 
 	/* Hash the image data */
-	purple_cipher_append(cipher, image_data, image_len);
-	if (!purple_cipher_digest_to_str(cipher, sizeof(digest), digest, NULL))
+	purple_hash_append(hash, image_data, image_len);
+	if (!purple_hash_digest_to_str(hash, sizeof(digest), digest, NULL))
 	{
 		purple_debug_error("util", "Failed to get SHA-1 digest.\n");
 		g_return_val_if_reached(NULL);
 	}
-	g_object_unref(G_OBJECT(cipher));
+	g_object_unref(G_OBJECT(hash));
 
 	return g_strdup(digest);
 }
============================================================
--- libpurple/protocols/jabber/jutil.c	08f8ab25684de99acf0fbeb3e8180f867b2c6769
+++ libpurple/protocols/jabber/jutil.c	7be6b427f740455d67cb68139576a42b2ae15fbb
@@ -27,7 +27,7 @@
 #include "server.h"
 #include "cipher/md4hash.h"
 #include "cipher/md5hash.h"
-#include "cipher/sha1cipher.h"
+#include "cipher/sha1hash.h"
 #include "util.h"
 #include "xmlnode.h"
 
@@ -736,31 +736,31 @@ jabber_calculate_data_hash(gconstpointer
 jabber_calculate_data_hash(gconstpointer data, size_t len, 
     const gchar *hash_algo)
 {
-	PurpleCipher *cipher = NULL;
+	PurpleHash *hash = NULL;
 	static gchar digest[129]; /* 512 bits hex + \0 */
 
 	/* FIXME: Check the source of this change and what we need here... */
 	if (g_str_equal(hash_algo, "sha1"))
-		cipher = purple_sha1_cipher_new();
+		hash = purple_sha1_hash_new();
 	else if (g_str_equal(hash_algo, "md4"))
-		cipher = purple_md4_hash_new();
+		hash = purple_md4_hash_new();
 	else if (g_str_equal(hash_algo, "md5"))
-		cipher = purple_md5_hash_new();
-	if (cipher == NULL)
+		hash = purple_md5_hash_new();
+	if (hash == NULL)
 	{
 		purple_debug_error("jabber", "Could not find %s cipher\n", hash_algo);
 		g_return_val_if_reached(NULL);
 	}
 
 	/* Hash the data */
-	purple_cipher_append(cipher, data, len);
-	if (!purple_cipher_digest_to_str(cipher, sizeof(digest), digest, NULL))
+	purple_hash_append(hash, data, len);
+	if (!purple_hash_digest_to_str(hash, sizeof(digest), digest, NULL))
 	{
 		purple_debug_error("jabber", "Failed to get digest for %s cipher.\n",
 		    hash_algo);
 		g_return_val_if_reached(NULL);
 	}
-	g_object_unref(G_OBJECT(cipher));
+	g_object_unref(G_OBJECT(hash));
 
 	return g_strdup(digest);
 }
============================================================
--- libpurple/protocols/yahoo/libymsg.c	db7d60801fd7c7513a471b8f5f86171f750241d7
+++ libpurple/protocols/yahoo/libymsg.c	b8d42355b3fc14580407a40c74a364a48d81e891
@@ -37,7 +37,6 @@
 #include "proxy.h"
 #include "request.h"
 #include "server.h"
-#include "cipher/sha1cipher.h"
 #include "util.h"
 #include "version.h"
 #include "xmlnode.h"
============================================================
--- libpurple/protocols/msn/msn.h	9228d80b5383dc7729d4eda50be29adc9ff36702
+++ libpurple/protocols/msn/msn.h	a3642d5d3d4bc87fe106d2eee15bc03e373f9cc4
@@ -96,7 +96,7 @@ typedef enum
 #include "prpl.h"
 #include "request.h"
 #include "servconn.h"
-#include "cipher/sha1cipher.h"
+#include "cipher/sha1hash.h"
 #include "sslconn.h"
 #include "util.h"
 
============================================================
--- libpurple/protocols/msn/user.c	5874d0e7d20611151c691a00c02b70fac179e88d
+++ libpurple/protocols/msn/user.c	33765cbbbeac0db07651d510d0414a3b829ebb58
@@ -25,8 +25,6 @@
 #include "user.h"
 #include "slp.h"
 
-#include "cipher/sha1cipher.h"
-
 /*new a user object*/
 MsnUser *
 msn_user_new(MsnUserList *userlist, const char *passport,
============================================================
--- libpurple/plugins/perl/common/module.h	ea150d92f475bb6579b2aced7e3012c7acd8abad
+++ libpurple/plugins/perl/common/module.h	a42059a744aeaff7f1b43249493ab8ea5df93ed1
@@ -61,7 +61,7 @@ typedef struct group *Purple__Group;
 #include "roomlist.h"
 #include "savedstatuses.h"
 #include "server.h"
-#include "cipher/sha1cipher.h"
+#include "cipher/sha1hash.h"
 #include "signals.h"
 #include "smiley.h"
 #include "sound.h"
============================================================
--- libpurple/protocols/msn/nexus.c	01975e5880430920bf54a14ea171d5ef9839acf1
+++ libpurple/protocols/msn/nexus.c	17d6363a29b15b4217460b79f9912d150123fe60
@@ -28,7 +28,7 @@
 
 #include "cipher/des3cipher.h"
 #include "cipher/hmaccipher.h"
-#include "cipher/sha1cipher.h"
+#include "cipher/sha1hash.h"
 
 /**************************************************************************
  * Valid Ticket Tokens
@@ -99,11 +99,12 @@ rps_create_key(const char *key, int key_
 	const guchar magic[] = "WS-SecureConversation";
 	const int magic_len = sizeof(magic) - 1;
 
-	PurpleCipher *hmac, *sha1;
+	PurpleCipher *hmac;
+	PurpleHash *sha1;
 	guchar hash1[20], hash2[20], hash3[20], hash4[20];
 	char *result;
 
-	sha1 = purple_sha1_cipher_new();
+	sha1 = purple_sha1_hash_new();
 	hmac = purple_hmac_cipher_new(sha1);
 	g_object_unref(G_OBJECT(sha1));
 
@@ -172,7 +173,8 @@ msn_rps_encrypt(MsnNexus *nexus)
 	MsnUsrKey *usr_key;
 	const char magic1[] = "SESSION KEY HASH";
 	const char magic2[] = "SESSION KEY ENCRYPTION";
-	PurpleCipher *hmac, *sha1;
+	PurpleCipher *hmac;
+	PurpleHash *sha1;
 	size_t len;
 	guchar hash[20];
 	char *key1, *key2, *key3;
@@ -200,7 +202,7 @@ msn_rps_encrypt(MsnNexus *nexus)
 	iv[1] = rand();
 
 	len = strlen(nexus->nonce);
-	sha1 = purple_sha1_cipher_new();
+	sha1 = purple_sha1_hash_new();
 	hmac = purple_hmac_cipher_new(sha1);
 	g_object_unref(G_OBJECT(sha1));
 	purple_cipher_set_key_with_len(hmac, (guchar *)key2, 24);
@@ -513,7 +515,7 @@ msn_nexus_update_token(MsnNexus *nexus, 
 	MsnSession *session = nexus->session;
 	MsnNexusUpdateData *ud;
 	MsnNexusUpdateCallback *update;
-	PurpleCipher *sha1;
+	PurpleHash *sha1;
 	PurpleCipher *hmac;
 
 	char *key;
@@ -565,7 +567,7 @@ msn_nexus_update_token(MsnNexus *nexus, 
 	ud->nexus = nexus;
 	ud->id = id;
 
-	sha1 = purple_sha1_cipher_new();
+	sha1 = purple_sha1_hash_new();
 
 	domain = g_strdup_printf(MSN_SSO_RST_TEMPLATE,
 	                         id,
@@ -573,8 +575,8 @@ msn_nexus_update_token(MsnNexus *nexus, 
 	                         ticket_domains[id][SSO_VALID_TICKET_POLICY] != NULL ?
 	                             ticket_domains[id][SSO_VALID_TICKET_POLICY] :
 	                             nexus->policy);
-	purple_cipher_append(sha1, (guchar *)domain, strlen(domain));
-	purple_cipher_digest(sha1, 20, digest, NULL);
+	purple_hash_append(sha1, (guchar *)domain, strlen(domain));
+	purple_hash_digest(sha1, 20, digest, NULL);
 	domain_b64 = purple_base64_encode(digest, 20);
 
 	now = time(NULL);
@@ -585,9 +587,9 @@ msn_nexus_update_token(MsnNexus *nexus, 
 	timestamp = g_strdup_printf(MSN_SSO_TIMESTAMP_TEMPLATE,
 	                            now_str,
 	                            purple_utf8_strftime("%Y-%m-%dT%H:%M:%SZ", tm));
-	purple_cipher_reset(sha1);
-	purple_cipher_append(sha1, (guchar *)timestamp, strlen(timestamp));
-	purple_cipher_digest(sha1, 20, digest, NULL);
+	purple_hash_reset(sha1);
+	purple_hash_append(sha1, (guchar *)timestamp, strlen(timestamp));
+	purple_hash_digest(sha1, 20, digest, NULL);
 	timestamp_b64 = purple_base64_encode(digest, 20);
 	g_free(now_str);
 
@@ -603,7 +605,7 @@ msn_nexus_update_token(MsnNexus *nexus, 
 	nonce_b64 = purple_base64_encode((guchar *)&nonce, sizeof(nonce));
 
 	key = rps_create_key(nexus->secret, 24, (char *)nonce, sizeof(nonce));
-	sha1 = purple_sha1_cipher_new();
+	sha1 = purple_sha1_hash_new();
 	hmac = purple_hmac_cipher_new(sha1);
 	g_object_unref(G_OBJECT(sha1));
 	purple_cipher_set_key_with_len(hmac, (guchar *)key, 24);
============================================================
--- libpurple/protocols/msn/directconn.c	108def282e9b4b9eeb01eb30fe1fa5163ddf0974
+++ libpurple/protocols/msn/directconn.c	3da51636fdc94b415eabef3d16eb121e507da687
@@ -22,7 +22,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
  */
 #include "msn.h"
-#include "cipher/sha1cipher.h"
+#include "cipher/sha1hash.h"
 #include "directconn.h"
 
 #include "slp.h"
@@ -54,10 +54,10 @@ msn_dc_calculate_nonce_hash(MsnDirectCon
 	guchar digest[20];
 
 	if (type == DC_NONCE_SHA1) {
-		PurpleCipher *cipher = purple_sha1_cipher_new();
-		purple_cipher_append(cipher, nonce, sizeof(nonce));
-		purple_cipher_digest(cipher, sizeof(digest), digest, NULL);
-		g_object_unref(G_OBJECT(cipher));
+		PurpleHash *hash = purple_sha1_hash_new();
+		purple_hash_append(hash, nonce, sizeof(nonce));
+		purple_hash_digest(hash, sizeof(digest), digest, NULL);
+		g_object_unref(G_OBJECT(hash));
 	} else if (type == DC_NONCE_PLAIN) {
 		memcpy(digest, nonce, 16);
 	}
============================================================
--- libpurple/protocols/msn/object.c	bf487cc803f1a242fe07a21696b1c621665cfd1f
+++ libpurple/protocols/msn/object.c	2b42e4bca769661f8799c0574c57d430706630d0
@@ -26,7 +26,7 @@
 #include "object.h"
 #include "debug.h"
 /* Sha1 stuff */
-#include "cipher/sha1cipher.h"
+#include "cipher/sha1hash.h"
 /* Base64 stuff */
 #include "util.h"
 
@@ -115,7 +115,7 @@ msn_object_new_from_image(PurpleStoredIm
 		const char *creator, MsnObjectType type)
 {
 	MsnObject *msnobj;
-	PurpleCipher *cipher;
+	PurpleHash *hash;
 	char *buf;
 	gconstpointer data;
 	size_t size;
@@ -142,9 +142,9 @@ msn_object_new_from_image(PurpleStoredIm
 	/* Compute the SHA1D field. */
 	memset(digest, 0, sizeof(digest));
 
-	cipher = purple_sha1_cipher_new();
-	purple_cipher_append(cipher, data, size);
-	purple_cipher_digest(cipher, sizeof(digest), digest, NULL);
+	hash = purple_sha1_hash_new();
+	purple_hash_append(hash, data, size);
+	purple_hash_digest(hash, sizeof(digest), digest, NULL);
 
 	base64 = purple_base64_encode(digest, sizeof(digest));
 	msn_object_set_sha1d(msnobj, base64);
@@ -164,10 +164,10 @@ msn_object_new_from_image(PurpleStoredIm
 
 	memset(digest, 0, sizeof(digest));
 
-	purple_cipher_reset(cipher);
-	purple_cipher_append(cipher, (const guchar *)buf, strlen(buf));
-	purple_cipher_digest(cipher, sizeof(digest), digest, NULL);
-	g_object_unref(G_OBJECT(cipher));
+	purple_hash_reset(hash);
+	purple_hash_append(hash, (const guchar *)buf, strlen(buf));
+	purple_hash_digest(hash, sizeof(digest), digest, NULL);
+	g_object_unref(G_OBJECT(hash));
 	g_free(buf);
 
 	base64 = purple_base64_encode(digest, sizeof(digest));
============================================================
--- libpurple/plugins/perl/common/Cipher.xs	1fc94db89c77224460ea2af358c88de6aef5b055
+++ libpurple/plugins/perl/common/Cipher.xs	9ca95144ac8c5422407c6489db0dd40ae0e88a79
@@ -171,11 +171,11 @@ purple_md5_hash_new()
 Purple::Cipher
 purple_md5_hash_new()
 
-MODULE = Purple::Cipher PACKAGE = Purple::SHA1Cipher PREFIX = purple_sha1_cipher_
+MODULE = Purple::Hash PACKAGE = Purple::SHA1Hash PREFIX = purple_sha1_hash_
 PROTOTYPES: ENABLE
 
 Purple::Cipher
-purple_sha1_cipher_new()
+purple_sha1_hash_new()
 
 MODULE = Purple::Cipher PACKAGE = Purple::HMACCipher PREFIX = purple_hmac_cipher_
 PROTOTYPES: ENABLE
============================================================
--- libpurple/Makefile.am	32c07ea463333ff79fcfa581df903ab8852a3a8b
+++ libpurple/Makefile.am	a51cb9b3428d49b050938dc1e13c20badf00e2ef
@@ -54,7 +54,7 @@ purple_coresources = \
 	cipher/md4hash.c \
 	cipher/md5hash.c \
 	cipher/rc4cipher.c \
-	cipher/sha1cipher.c \
+	cipher/sha1hash.c \
 	cipher/sha256cipher.c \
 	cmds.c \
 	connection.c \
@@ -137,7 +137,7 @@ purple_coreheaders = \
 	cipher/md4hash.h \
 	cipher/md5hash.h \
 	cipher/rc4cipher.h \
-	cipher/sha1cipher.h \
+	cipher/sha1hash.h \
 	cipher/sha256cipher.h \
 	circbuffer.h \
 	cmds.h \
============================================================
--- libpurple/Makefile.mingw	9ce4ff44aa68cede477aaef0bf922eed14e29724
+++ libpurple/Makefile.mingw	8ccc24001d4a97bbc7860da5590c913ee2d9808b
@@ -44,7 +44,7 @@ C_SRC =	\
 			cipher/md4hash.c \
 			cipher/md5hash.c \
 			cipher/rc4cipher.c \
-			cipher/sha1cipher.c \
+			cipher/sha1hash.c \
 			cipher/sha256cipher.c \
 			circbuffer.c \
 			cmds.c \
============================================================
--- libpurple/protocols/myspace/myspace.c	e402e5a2c3f0983ba8b4efcf7986ac245d1de5e3
+++ libpurple/protocols/myspace/myspace.c	fcc49f29550da8cc64b9d51257c00931c6183080
@@ -539,6 +539,7 @@ msim_compute_login_response(const gchar 
 msim_compute_login_response(const gchar nonce[2 * NONCE_SIZE],
 		const gchar *email, const gchar *password, guint *response_len)
 {
+	PurpleHash *hash;
 	PurpleCipher *cipher;
 	guchar hash_pw[HASH_SIZE];
 	guchar key[HASH_SIZE];
@@ -587,11 +588,11 @@ msim_compute_login_response(const gchar 
 	}
 
 	/* Compute password hash */
-	cipher = purple_sha1_cipher_new();
-	purple_cipher_append(cipher, (guchar *)password_utf16le,
-						 conv_bytes_written);
-	purple_cipher_digest(cipher, sizeof(hash_pw), hash_pw, NULL);
-	purple_cipher_reset(cipher);
+	hash = purple_sha1_hash_new();
+	purple_hash_append(hash, (guchar *)password_utf16le,
+					   conv_bytes_written);
+	purple_hash_digest(hash, sizeof(hash_pw), hash_pw, NULL);
+	purple_hash_reset(hash);
 
 	g_free(password_utf16le);
 
@@ -603,10 +604,10 @@ msim_compute_login_response(const gchar 
 #endif
 
 	/* key = sha1(sha1(pw) + nonce2) */
-	purple_cipher_append(cipher, hash_pw, HASH_SIZE);
-	purple_cipher_append(cipher, (guchar *)(nonce + NONCE_SIZE), NONCE_SIZE);
-	purple_cipher_digest(cipher, sizeof(key), key, NULL);
-	g_object_unref(G_OBJECT(cipher));
+	purple_hash_append(hash, hash_pw, HASH_SIZE);
+	purple_hash_append(hash, (guchar *)(nonce + NONCE_SIZE), NONCE_SIZE);
+	purple_hash_digest(hash, sizeof(key), key, NULL);
+	g_object_unref(G_OBJECT(hash));
 
 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE
 	purple_debug_info("msim", "key = ");
============================================================
--- libpurple/protocols/myspace/myspace.h	1af89d9965a67f7f7de3acbf74266f33a3589795
+++ libpurple/protocols/myspace/myspace.h	bc171919a41a46b21943e4b1e3fd8036003c4637
@@ -42,7 +42,7 @@
 #include "plugin.h"
 #include "accountopt.h"
 #include "version.h"
-#include "cipher/sha1cipher.h"
+#include "cipher/sha1hash.h"
 #include "cipher/rc4cipher.h"
 #include "util.h"       /* for base64 */
 #include "debug.h"      /* for purple_debug_info */
============================================================
--- libpurple/cipher/sha1cipher.c	19e45a9eaae0178a23e35ff3e642bc44e9683390
+++ libpurple/cipher/sha1hash.c	4ee7e373d3288464391b4fb52828aacb99402ea9
@@ -1,6 +1,7 @@
 /*
  */
-#include "sha1cipher.h"
+#include "sha1hash.h"
+#include "hmaccipher.h"
 
 #include <string.h>
 
@@ -9,12 +10,16 @@
 #define SHA1_BLOCK_WORDS		16
 #define SHA1_HASH_WORDS		4
 
+#if !GLIB_CHECK_VERSION(2,16,0)
+#define PURPLE_SHA1_HASH_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_SHA1_HASH, PurpleSHA1HashPrivate))
+#endif
 
 /******************************************************************************
  * Structs
  *****************************************************************************/
 #if !GLIB_CHECK_VERSION(2,16,0)
-struct _PurpleSHA1CipherPriv {
+typedef struct {
 	guint32 H[5];
 	guint32 W[80];
 
@@ -22,7 +27,7 @@ struct _PurpleSHA1CipherPriv {
 
 	guint32 sizeHi;
 	guint32 sizeLo;
-};
+} PurpleSHA1HashPrivate;
 #endif
 /******************************************************************************
  * Enums
@@ -43,49 +48,49 @@ static GObjectClass *parent_class = NULL
 #define SHA1_ROTL(X,n) ((((X) << (n)) | ((X) >> (32-(n)))) & 0xFFFFFFFF)
 
 /******************************************************************************
- * Cipher Stuff
+ * Hash Stuff
  *****************************************************************************/
 
 #if !GLIB_CHECK_VERSION(2,16,0)
 static void
-purple_sha1_cipher_reset(PurpleCipher *cipher) {
-	PurpleSHA1Cipher *sha1_cipher = PURPLE_SHA1_CIPHER(cipher);
+purple_sha1_hash_reset(PurpleHash *hash) {
+	PurpleSHA1HashPrivate *priv = PURPLE_SHA1_HASH_GET_PRIVATE(hash);
 
-	sha1_cipher->priv->lenW = 0;
-	sha1_cipher->priv->sizeHi = 0;
-	sha1_cipher->priv->sizeLo = 0;
+	priv->lenW = 0;
+	priv->sizeHi = 0;
+	priv->sizeLo = 0;
 
-	sha1_cipher->priv->H[0] = 0x67452301;
-	sha1_cipher->priv->H[1] = 0xefcdab89;
-	sha1_cipher->priv->H[2] = 0x98badcfe;
-	sha1_cipher->priv->H[3] = 0x10325476;
-	sha1_cipher->priv->H[4] = 0xc3d2e1f0;
+	priv->H[0] = 0x67452301;
+	priv->H[1] = 0xefcdab89;
+	priv->H[2] = 0x98badcfe;
+	priv->H[3] = 0x10325476;
+	priv->H[4] = 0xc3d2e1f0;
 
-	memset(sha1_cipher->priv->W, 0, sizeof(sha1_cipher->priv->W));
+	memset(priv->W, 0, sizeof(priv->W));
 }
 
 static void
-purple_sha1_cipher_hash_block(PurpleSHA1Cipher *sha1_cipher) {
+purple_sha1_hash_hash_block(PurpleSHA1HashPrivate *priv) {
 	gint i;
 	guint32 A, B, C, D, E, T;
 
 	for(i = 16; i < 80; i++) {
-		sha1_cipher->priv->W[i] =
-			SHA1_ROTL(sha1_cipher->priv->W[i -  3] ^
-					  sha1_cipher->priv->W[i -  8] ^
-					  sha1_cipher->priv->W[i - 14] ^
-					  sha1_cipher->priv->W[i - 16], 1);
+		priv->W[i] =
+			SHA1_ROTL(priv->W[i -  3] ^
+					  priv->W[i -  8] ^
+					  priv->W[i - 14] ^
+					  priv->W[i - 16], 1);
 	}
 
-	A = sha1_cipher->priv->H[0];
-	B = sha1_cipher->priv->H[1];
-	C = sha1_cipher->priv->H[2];
-	D = sha1_cipher->priv->H[3];
-	E = sha1_cipher->priv->H[4];
+	A = priv->H[0];
+	B = priv->H[1];
+	C = priv->H[2];
+	D = priv->H[3];
+	E = priv->H[4];
 
 	for(i = 0; i < 20; i++) {
 		T = (SHA1_ROTL(A, 5) + (((C ^ D) & B) ^ D) + E +
-			sha1_cipher->priv->W[i] + 0x5A827999) & 0xFFFFFFFF;
+			priv->W[i] + 0x5A827999) & 0xFFFFFFFF;
 		E = D;
 		D = C;
 		C = SHA1_ROTL(B, 30);
@@ -94,7 +99,7 @@ purple_sha1_cipher_hash_block(PurpleSHA1
 	}
 
 	for(i = 20; i < 40; i++) {
-		T = (SHA1_ROTL(A, 5) + (B ^ C ^ D) + E + sha1_cipher->priv->W[i] +
+		T = (SHA1_ROTL(A, 5) + (B ^ C ^ D) + E + priv->W[i] +
 			0x6ED9EBA1) & 0xFFFFFFFF;
 		E = D;
 		D = C;
@@ -105,7 +110,7 @@ purple_sha1_cipher_hash_block(PurpleSHA1
 
 	for(i = 40; i < 60; i++) {
 		T = (SHA1_ROTL(A, 5) + ((B & C) | (D & (B | C))) + E +
-			sha1_cipher->priv->W[i] + 0x8F1BBCDC) & 0xFFFFFFFF;
+			priv->W[i] + 0x8F1BBCDC) & 0xFFFFFFFF;
 		E = D;
 		D = C;
 		C = SHA1_ROTL(B, 30);
@@ -114,7 +119,7 @@ purple_sha1_cipher_hash_block(PurpleSHA1
 	}
 
 	for(i = 60; i < 80; i++) {
-		T = (SHA1_ROTL(A, 5) + (B ^ C ^ D) + E + sha1_cipher->priv->W[i] +
+		T = (SHA1_ROTL(A, 5) + (B ^ C ^ D) + E + priv->W[i] +
 			0xCA62C1D6) & 0xFFFFFFFF;
 		E = D;
 		D = C;
@@ -123,66 +128,66 @@ purple_sha1_cipher_hash_block(PurpleSHA1
 		A = T;
 	}
 
-	sha1_cipher->priv->H[0] += A;
-	sha1_cipher->priv->H[1] += B;
-	sha1_cipher->priv->H[2] += C;
-	sha1_cipher->priv->H[3] += D;
-	sha1_cipher->priv->H[4] += E;
+	priv->H[0] += A;
+	priv->H[1] += B;
+	priv->H[2] += C;
+	priv->H[3] += D;
+	priv->H[4] += E;
 }
 
 static void
-purple_sha1_cipher_append(PurpleCipher *cipher, const guchar *data,
-						 size_t len)
+purple_sha1_hash_append(PurpleHash *hash, const guchar *data,
+						size_t len)
 {
-	PurpleSHA1Cipher *sha1_cipher = PURPLE_SHA1_CIPHER(cipher);
+	PurpleSHA1HashPrivate *priv = PURPLE_SHA1_HASH_GET_PRIVATE(hash);
 	gint i;
 
 	for(i = 0; i < len; i++) {
-		sha1_cipher->priv->W[sha1_cipher->priv->lenW / 4] <<= 8;
-		sha1_cipher->priv->W[sha1_cipher->priv->lenW / 4] |= data[i];
+		priv->W[priv->lenW / 4] <<= 8;
+		priv->W[priv->lenW / 4] |= data[i];
 
-		if((++sha1_cipher->priv->lenW) % 64 == 0) {
-			purple_sha1_cipher_hash_block(sha1_cipher);
-			sha1_cipher->priv->lenW = 0;
+		if((++priv->lenW) % 64 == 0) {
+			purple_sha1_hash_hash_block(priv);
+			priv->lenW = 0;
 		}
 
-		sha1_cipher->priv->sizeLo += 8;
-		sha1_cipher->priv->sizeHi += (sha1_cipher->priv->sizeLo < 8);
+		priv->sizeLo += 8;
+		priv->sizeHi += (priv->sizeLo < 8);
 	}
 }
 
 static gboolean
-purple_sha1_cipher_digest(PurpleCipher *cipher, size_t in_len,
-						 guchar digest[16], size_t *out_len)
+purple_sha1_hash_digest(PurpleHash *hash, size_t in_len,
+						guchar digest[16], size_t *out_len)
 {
-	PurpleSHA1Cipher *sha1_cipher = PURPLE_SHA1_CIPHER(cipher);
+	PurpleSHA1HashPrivate *priv = PURPLE_SHA1_HASH_GET_PRIVATE(hash);
 	guchar pad0x80 = 0x80, pad0x00 = 0x00;
 	guchar padlen[8];
 	gint i;
 
 	g_return_val_if_fail(in_len >= 20, FALSE);
 
-	padlen[0] = (guchar)((sha1_cipher->priv->sizeHi >> 24) & 255);
-	padlen[1] = (guchar)((sha1_cipher->priv->sizeHi >> 16) & 255);
-	padlen[2] = (guchar)((sha1_cipher->priv->sizeHi >>  8) & 255);
-	padlen[3] = (guchar)((sha1_cipher->priv->sizeHi >>  0) & 255);
-	padlen[4] = (guchar)((sha1_cipher->priv->sizeLo >> 24) & 255);
-	padlen[5] = (guchar)((sha1_cipher->priv->sizeLo >> 16) & 255);
-	padlen[6] = (guchar)((sha1_cipher->priv->sizeLo >>  8) & 255);
-	padlen[7] = (guchar)((sha1_cipher->priv->sizeLo >>  0) & 255);
+	padlen[0] = (guchar)((priv->sizeHi >> 24) & 255);
+	padlen[1] = (guchar)((priv->sizeHi >> 16) & 255);
+	padlen[2] = (guchar)((priv->sizeHi >>  8) & 255);
+	padlen[3] = (guchar)((priv->sizeHi >>  0) & 255);
+	padlen[4] = (guchar)((priv->sizeLo >> 24) & 255);
+	padlen[5] = (guchar)((priv->sizeLo >> 16) & 255);
+	padlen[6] = (guchar)((priv->sizeLo >>  8) & 255);
+	padlen[7] = (guchar)((priv->sizeLo >>  0) & 255);
 
 	/* pad with a 1, then zeroes, then length */
-	purple_sha1_cipher_append(cipher, &pad0x80, 1);
-	while(sha1_cipher->priv->lenW != 56)
-		purple_sha1_cipher_append(cipher, &pad0x00, 1);
-	purple_sha1_cipher_append(cipher, padlen, 8);
+	purple_sha1_hash_append(hash, &pad0x80, 1);
+	while(priv->lenW != 56)
+		purple_sha1_hash_append(hash, &pad0x00, 1);
+	purple_sha1_hash_append(hash, padlen, 8);
 
 	for(i = 0; i < 20; i++) {
-		digest[i] = (guchar)(sha1_cipher->priv->H[i / 4] >> 24);
-		sha1_cipher->priv->H[i / 4] <<= 8;
+		digest[i] = (guchar)(priv->H[i / 4] >> 24);
+		priv->H[i / 4] <<= 8;
 	}
 
-	purple_sha1_cipher_reset(cipher);
+	purple_sha1_hash_reset(hash);
 
 	if(out_len)
 		*out_len = 20;
@@ -191,103 +196,108 @@ purple_sha1_cipher_digest(PurpleCipher *
 }
 #endif /* !GLIB_CHECK_VERSION */
 
-static size_t
-purple_sha1_cipher_get_block_size(PurpleCipher *cipher)
-{
-	return SHA1_HMAC_BLOCK_SIZE;
-}
-
 /******************************************************************************
  * Object Stuff
  *****************************************************************************/
 #if !GLIB_CHECK_VERSION(2,16,0)
 static void
-purple_sha1_cipher_finalize(GObject *obj) {
-	PurpleCipher *cipher = PURPLE_CIPHER(obj);
-	PurpleSHA1Cipher *sha1_cipher = PURPLE_SHA1_CIPHER(obj);
+purple_sha1_hash_finalize(GObject *obj) {
+	PurpleHash *hash = PURPLE_HASH(obj);
+	PurpleSHA1HashPrivate *priv = PURPLE_SHA1_HASH_GET_PRIVATE(obj);
 
-	/* reset the cipher so we don't leave any data around... */
-	purple_sha1_cipher_reset(cipher);
+	/* reset the hash so we don't leave any data around... */
+	purple_sha1_hash_reset(hash);
 
-	g_free(sha1_cipher->priv);
+	g_free(priv);
 }
 #endif /* !GLIB_CHECK_VERSION(2,16,0) */
 
 static void
-purple_sha1_cipher_class_init(PurpleSHA1CipherClass *klass) {
+purple_sha1_hash_class_init(PurpleSHA1HashClass *klass) {
 #if !GLIB_CHECK_VERSION(2,16,0)
 	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+	PurpleHashClass *hash_class = PURPLE_HASH_CLASS(klass);
 #endif
-	PurpleCipherClass *cipher_class = PURPLE_CIPHER_CLASS(klass);
 
 	parent_class = g_type_class_peek_parent(klass);
 
 #if !GLIB_CHECK_VERSION(2,16,0)
-	obj_class->finalize = purple_sha1_cipher_finalize;
+	g_type_class_add_private(klass, sizeof(PurpleSHA1HashPrivate));
 
-	cipher_class->reset = purple_sha1_cipher_reset;
-	cipher_class->append = purple_sha1_cipher_append;
-	cipher_class->digest = purple_sha1_cipher_digest;
+	obj_class->finalize = purple_sha1_hash_finalize;
+
+	hash_class->reset = purple_sha1_hash_reset;
+	hash_class->append = purple_sha1_hash_append;
+	hash_class->digest = purple_sha1_hash_digest;
 #endif
-	cipher_class->get_block_size = purple_sha1_cipher_get_block_size;
 }
 
-static void
-purple_sha1_cipher_init(PurpleCipher *cipher) {
-#if !GLIB_CHECK_VERSION(2,16,0)
-	PurpleSHA1Cipher *sha1_cipher = PURPLE_SHA1_CIPHER(cipher);
+/******************************************************************************
+ * HMACFunction Stuff
+ *****************************************************************************/
+static size_t
+purple_sha1_hash_get_block_size(const PurpleHMACFunction *function) {
+	return SHA1_HMAC_BLOCK_SIZE;
+}
 
-	sha1_cipher->priv = g_new0(PurpleSHA1CipherPriv, 1);
-
-	purple_sha1_cipher_reset(cipher);
-#endif
+static void
+purple_sha1_hash_hmac_function_init(PurpleHMACFunctionIface *iface) {
+	iface->get_block_size = purple_sha1_hash_get_block_size;
 }
 
 /******************************************************************************
  * API
  *****************************************************************************/
 GType
-purple_sha1_cipher_get_gtype(void) {
+purple_sha1_hash_get_gtype(void) {
 	static GType type = 0;
 
 	if(G_UNLIKELY(type == 0)) {
 		static const GTypeInfo info = {
-			sizeof(PurpleSHA1CipherClass),
+			sizeof(PurpleSHA1HashClass),
 			NULL,
 			NULL,
-			(GClassInitFunc)purple_sha1_cipher_class_init,
+			(GClassInitFunc)purple_sha1_hash_class_init,
 			NULL,
 			NULL,
-			sizeof(PurpleSHA1Cipher),
+			sizeof(PurpleSHA1Hash),
 			0,
-			(GInstanceInitFunc)purple_sha1_cipher_init,
 			NULL,
+			NULL,
 		};
+		static const GInterfaceInfo hmac_info = {
+			(GInterfaceInitFunc)purple_sha1_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,
-									  "PurpleSHA1Cipher",
+									  "PurpleSHA1Hash",
 									  &info, 0);
+
+		g_type_add_interface_static(type, PURPLE_TYPE_HMAC_FUNCTION, &hmac_info);
 	}
 
 	return type;
 }
 
-PurpleCipher *
-purple_sha1_cipher_new(void) {
+PurpleHash *
+purple_sha1_hash_new(void) {
 #if GLIB_CHECK_VERSION(2,16,0)
-	return g_object_new(PURPLE_TYPE_SHA1_CIPHER,
+	return g_object_new(PURPLE_TYPE_SHA1_HASH,
 			"checksum_type", G_CHECKSUM_SHA1,
 			NULL);
 #else
-	return g_object_new(PURPLE_TYPE_SHA1_CIPHER, NULL);
+	return g_object_new(PURPLE_TYPE_SHA1_HASH, NULL);
 #endif
 }
 
============================================================
--- libpurple/cipher/sha1cipher.h	f8924a7896d521b47c60c2fee0b14f3aa80b0868
+++ libpurple/cipher/sha1hash.h	e0ec60d774d90d093434395f3066882ecbe230f8
@@ -1,5 +1,5 @@
 /**
- * @file cipher.h Purple Cipher API
+ * @file sha1hash.h Purple Hash API
  * @ingroup core
  *
  * purple
@@ -22,31 +22,31 @@
  * 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_SHA1_CIPHER_H
-#define PURPLE_SHA1_CIPHER_H
+#ifndef PURPLE_SHA1_HASH_H
+#define PURPLE_SHA1_HASH_H
 
-#include <cipher/cipher.h>
+#include <cipher/hash.h>
 #include <cipher/ghash.h>
 
-#define PURPLE_TYPE_SHA1_CIPHER				(purple_sha1_cipher_get_gtype())
-#define PURPLE_SHA1_CIPHER(obj)				(G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_SHA1_CIPHER, PurpleSHA1Cipher))
-#define PURPLE_SHA1_CIPHER_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_SHA1_CIPHER, PurpleSHA1CipherClass))
-#define PURPLE_IS_SHA1_CIPHER(obj)			(G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_SHA1_CIPHER))
-#define PURPLE_IS_SHA1_CIPHER_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE((obj), PURPLE_TYPE_SHA1_CIPHER))
-#define PURPLE_SHA1_CIPHER_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_SHA1_CIPHER, PurpleSHA1CipherClass))
+#define PURPLE_TYPE_SHA1_HASH				(purple_sha1_hash_get_gtype())
+#define PURPLE_SHA1_HASH(obj)				(G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_SHA1_HASH, PurpleSHA1Hash))
+#define PURPLE_SHA1_HASH_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_SHA1_HASH, PurpleSHA1HashClass))
+#define PURPLE_IS_SHA1_HASH(obj)			(G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_SHA1_HASH))
+#define PURPLE_IS_SHA1_HASH_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE((obj), PURPLE_TYPE_SHA1_HASH))
+#define PURPLE_SHA1_HASH_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_SHA1_HASH, PurpleSHA1HashClass))
 
-typedef struct _PurpleSHA1Cipher				PurpleSHA1Cipher;
-typedef struct _PurpleSHA1CipherPriv			PurpleSHA1CipherPriv;
-typedef struct _PurpleSHA1CipherClass		PurpleSHA1CipherClass;
+typedef struct _PurpleSHA1Hash				PurpleSHA1Hash;
+typedef struct _PurpleSHA1HashPriv			PurpleSHA1HashPriv;
+typedef struct _PurpleSHA1HashClass		PurpleSHA1HashClass;
 
-struct _PurpleSHA1Cipher {
+struct _PurpleSHA1Hash {
 #if GLIB_CHECK_VERSION(2,16,0)
 	PurpleGHash parent;
 #else
-	PurpleCipher parent;
+	PurpleHash parent;
 #endif
 
-	PurpleSHA1CipherPriv *priv;
+	PurpleSHA1HashPriv *priv;
 
 	void (*_purple_reserved1)(void);
 	void (*_purple_reserved2)(void);
@@ -54,11 +54,11 @@ struct _PurpleSHA1Cipher {
 	void (*_purple_reserved4)(void);
 };
 
-struct _PurpleSHA1CipherClass {
+struct _PurpleSHA1HashClass {
 #if GLIB_CHECK_VERSION(2,16,0)
 	PurpleGHashClass parent;
 #else
-	PurpleCipherClass parent;
+	PurpleHashClass parent;
 #endif
 
 	void (*_purple_reserved1)(void);
@@ -69,10 +69,10 @@ G_BEGIN_DECLS
 
 G_BEGIN_DECLS
 
-GType purple_sha1_cipher_get_gtype(void);
+GType purple_sha1_hash_get_gtype(void);
 
-PurpleCipher *purple_sha1_cipher_new(void);
+PurpleHash *purple_sha1_hash_new(void);
 
 G_END_DECLS
 
-#endif /* PURPLE_SHA1_CIPHER_H */
+#endif /* PURPLE_SHA1_HASH_H */
============================================================
--- libpurple/protocols/jabber/caps.c	bebbe2d313fce0d3bab731baaa0646a40bdf1a63
+++ libpurple/protocols/jabber/caps.c	94854151a2e4ee7ba792db4b9c0d3035f619b330
@@ -22,9 +22,9 @@
  */
 
 #include "internal.h"
-#include "cipher/cipher.h"
+#include "cipher/hash.h"
 #include "cipher/md5hash.h"
-#include "cipher/sha1cipher.h"
+#include "cipher/sha1hash.h"
 
 #include "debug.h"
 #include "caps.h"
@@ -466,9 +466,9 @@ jabber_caps_client_iqcb(JabberStream *js
 		 * doesn't seem to offer a "Get the hash size" function(?).
 		 */
 		if (!strcmp(userdata->hash, "sha-1")) {
-			hash = jabber_caps_calculate_hash(info, PURPLE_CIPHER(purple_sha1_cipher_new()));
+			hash = jabber_caps_calculate_hash(info, PURPLE_HASH(purple_sha1_hash_new()));
 		} else if (!strcmp(userdata->hash, "md5")) {
-			hash = jabber_caps_calculate_hash(info, PURPLE_CIPHER(purple_md5_hash_new()));
+			hash = jabber_caps_calculate_hash(info, PURPLE_HASH(purple_md5_hash_new()));
 		}
 
 		if (!hash || strcmp(hash, userdata->ver)) {
@@ -848,15 +848,15 @@ static void 
 }
 
 static void 
-append_escaped_string(PurpleCipher *hasher, const gchar *str)
+append_escaped_string(PurpleHash *hasher, const gchar *str)
 {
 	char *tmp = g_markup_escape_text(str, -1);
-	purple_cipher_append(hasher, (guchar *)tmp, strlen(tmp));
+	purple_hash_append(hasher, (guchar *)tmp, strlen(tmp));
 	g_free(tmp);
-	purple_cipher_append(hasher, (guchar *)"<", 1);
+	purple_hash_append(hasher, (guchar *)"<", 1);
 }
 
-gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, PurpleCipher *hasher)
+gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, PurpleHash *hasher)
 {
 	GList *node;
 	guint8 checksum[20];
@@ -888,7 +888,7 @@ gchar *jabber_caps_calculate_hash(Jabber
 		tmp = g_strconcat(category, "/", type, "/", lang ? lang : "",
 		                  "/", name ? name : "", "<", NULL);
 
-		purple_cipher_append(hasher, (guchar *)tmp, strlen(tmp));
+		purple_hash_append(hasher, (guchar *)tmp, strlen(tmp));
 
 		g_free(tmp);
 		g_free(category);
@@ -935,8 +935,8 @@ gchar *jabber_caps_calculate_hash(Jabber
 
 	/* generate hash */
 
-	success = purple_cipher_digest(hasher, checksum_size,
-	                               checksum, &checksum_size);
+	success = purple_hash_digest(hasher, checksum_size,
+	                             checksum, &checksum_size);
 
 	g_object_unref(hasher);
 
@@ -971,7 +971,7 @@ void jabber_caps_calculate_own_hash(Jabb
 	info.forms = NULL;
 
 	g_free(js->caps_hash);
-	js->caps_hash = jabber_caps_calculate_hash(&info, purple_sha1_cipher_new());
+	js->caps_hash = jabber_caps_calculate_hash(&info, purple_sha1_hash_new());
 	g_list_free(info.identities);
 	g_list_free(info.features);
 }
============================================================
--- libpurple/protocols/jabber/caps.h	466f004386b7cdc33440a0a02d1c198c6ca02b30
+++ libpurple/protocols/jabber/caps.h	57dc81dd7bb0f0ca6647f5a1363e2072fbd71ac8
@@ -27,7 +27,7 @@ typedef struct _JabberCapsClientInfo Jab
 typedef struct _JabberCapsClientInfo JabberCapsClientInfo;
 
 #include "jabber.h"
-#include "cipher/cipher.h"
+#include "cipher/hash.h"
 
 /* Implementation of XEP-0115 - Entity Capabilities */
 
@@ -99,7 +99,7 @@ void jabber_caps_get_info(JabberStream *
  *	@param hash Hash cipher to be used. Either sha-1 or md5.
  *	@return		The base64 encoded SHA-1 hash; must be freed by caller
  */
-gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, PurpleCipher *hasher);
+gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, PurpleHash *hasher);
 
 /**
  *  Calculate SHA1 hash for own featureset.
============================================================
--- libpurple/protocols/bonjour/bonjour_ft.c	baa91c87047927f84683be705d3d0a2cafc2c165
+++ libpurple/protocols/bonjour/bonjour_ft.c	962d0319a1a83b205d4e21e11f02facd43f8bc79
@@ -28,7 +28,7 @@
 #include "buddy.h"
 #include "bonjour.h"
 #include "bonjour_ft.h"
-#include "cipher/sha1cipher.h"
+#include "cipher/sha1hash.h"
 
 static void
 bonjour_bytestreams_init(PurpleXfer *xfer);
@@ -846,7 +846,7 @@ bonjour_bytestreams_connect(PurpleXfer *
 bonjour_bytestreams_connect(PurpleXfer *xfer, PurpleBuddy *pb)
 {
 	PurpleAccount *account = NULL;
-	PurpleCipher *cipher;
+	PurpleHash *hash;
 	XepXfer *xf;
 	char dstaddr[41];
 	unsigned char hashval[20];
@@ -866,10 +866,10 @@ bonjour_bytestreams_connect(PurpleXfer *
 
 	p = g_strdup_printf("%s%s%s", xf->sid, purple_buddy_get_name(pb), purple_account_get_username(account));
 
-	cipher = purple_sha1_cipher_new();
-	purple_cipher_append(cipher, (guchar *)p, strlen(p));
-	purple_cipher_digest(cipher, sizeof(hashval), hashval, NULL);
-	g_object_unref(G_OBJECT(cipher));
+	hash = purple_sha1_hash_new();
+	purple_hash_append(hash, (guchar *)p, strlen(p));
+	purple_hash_digest(hash, sizeof(hashval), hashval, NULL);
+	g_object_unref(G_OBJECT(hash));
 
 	g_free(p);
 
============================================================
--- libpurple/protocols/jabber/auth_scram.c	e6368ac7c8321ce15067a16432d87528b87d34ea
+++ libpurple/protocols/jabber/auth_scram.c	ed206c1fa1f971626cd6f3df52f45695bcd5f980
@@ -26,12 +26,13 @@
 #include "auth_scram.h"
 
 #include "cipher/cipher.h"
+#include "cipher/hash.h"
 #include "cipher/hmaccipher.h"
-#include "cipher/sha1cipher.h"
+#include "cipher/sha1hash.h"
 #include "debug.h"
 
 static const JabberScramHash hashes[] = {
-	{ "-SHA-1", purple_sha1_cipher_new, 20 },
+	{ "-SHA-1", purple_sha1_hash_new, 20 },
 };
 
 static const JabberScramHash *mech_to_hash(const char *mech)
@@ -78,7 +79,7 @@ guchar *jabber_scram_hi(const JabberScra
 guchar *jabber_scram_hi(const JabberScramHash *hash, const GString *str,
                         GString *salt, guint iterations)
 {
-	PurpleCipher *hash_cipher;
+	PurpleHash *hasher;
 	PurpleCipher *cipher;
 	guchar *result;
 	guint i;
@@ -93,9 +94,9 @@ guchar *jabber_scram_hi(const JabberScra
 	tmp    = g_new0(guint8, hash->size);
 	result = g_new0(guint8, hash->size);
 
-	hash_cipher = hash->new();
-	cipher = purple_hmac_cipher_new(hash_cipher);
-	g_object_unref(G_OBJECT(hash_cipher));
+	hasher = hash->new();
+	cipher = purple_hmac_cipher_new(hasher);
+	g_object_unref(G_OBJECT(hasher));
 
 	/* Append INT(1), a four-octet encoding of the integer 1, most significant
 	 * octet first. */
@@ -140,12 +141,12 @@ hmac(const JabberScramHash *hash, guchar
 static void
 hmac(const JabberScramHash *hash, guchar *out, const guchar *key, const gchar *str)
 {
-	PurpleCipher *hash_cipher;
+	PurpleHash *hasher;
 	PurpleCipher *cipher;
 
-	hash_cipher = hash->new();
-	cipher = purple_hmac_cipher_new(hash_cipher);
-	g_object_unref(G_OBJECT(hash_cipher));
+	hasher = hash->new();
+	cipher = purple_hmac_cipher_new(hasher);
+	g_object_unref(G_OBJECT(hasher));
 	purple_cipher_set_key_with_len(cipher, key, hash->size);
 	purple_cipher_append(cipher, (guchar *)str, strlen(str));
 	purple_cipher_digest(cipher, hash->size, out, NULL);
@@ -155,12 +156,12 @@ hash(const JabberScramHash *hash, guchar
 static void
 hash(const JabberScramHash *hash, guchar *out, const guchar *data)
 {
-	PurpleCipher *cipher;
+	PurpleHash *hasher;
 
-	cipher = hash->new();
-	purple_cipher_append(cipher, data, hash->size);
-	purple_cipher_digest(cipher, hash->size, out, NULL);
-	g_object_unref(G_OBJECT(cipher));
+	hasher = hash->new();
+	purple_hash_append(hasher, data, hash->size);
+	purple_hash_digest(hasher, hash->size, out, NULL);
+	g_object_unref(G_OBJECT(hasher));
 }
 
 gboolean
============================================================
--- libpurple/protocols/jabber/auth_scram.h	f6114a3176b579d349751715ce61fb5ceb548bc3
+++ libpurple/protocols/jabber/auth_scram.h	5130fca8005124d767b3a9de91eb6b2c13455ac3
@@ -34,7 +34,7 @@ typedef struct {
  */
 typedef struct {
 	const char *mech_substr;
-	PurpleCipher *(*new)(void);
+	PurpleHash *(*new)(void);
 	guint size;
 } JabberScramHash;
 


More information about the Commits mailing list