gobjectification: 5245f8f7: HMAC uses a hash, so the property should...

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


----------------------------------------------------------------------
Revision: 5245f8f75b2ad13def4ac6e1e5faabdbc771ae2c
Parent:   021931b42eee6266afb03649729dbe68922cb642
Author:   qulogic at pidgin.im
Date:     07/11/10 03:25:25
Branch:   im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/5245f8f75b2ad13def4ac6e1e5faabdbc771ae2c

Changelog: 

HMAC uses a hash, so the property should be a PurpleHash too.

Changes against parent 021931b42eee6266afb03649729dbe68922cb642

  patched  libpurple/cipher/hmaccipher.c
  patched  libpurple/cipher/hmaccipher.h

-------------- next part --------------
============================================================
--- libpurple/cipher/hmaccipher.c	1af5c26e5466254e3e362a0779b248044a836324
+++ libpurple/cipher/hmaccipher.c	7718c3e4c7932b67f9849ba8c3d34efbf14bc9a8
@@ -30,7 +30,7 @@ typedef struct {
  * Structs
  ******************************************************************************/
 typedef struct {
-	PurpleCipher *hash;
+	PurpleHash *hash;
 	guchar *opad;
 } PurpleHMACCipherPrivate;
 
@@ -53,7 +53,7 @@ purple_hmac_cipher_set_hash(PurpleCipher
  ******************************************************************************/
 static void
 purple_hmac_cipher_set_hash(PurpleCipher *cipher,
-							PurpleCipher *hash)
+							PurpleHash *hash)
 {
 	PurpleHMACCipherPrivate *priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
 
@@ -67,8 +67,8 @@ purple_hmac_cipher_reset(PurpleCipher *c
 purple_hmac_cipher_reset(PurpleCipher *cipher) {
 	PurpleHMACCipherPrivate *priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
 
-	if(PURPLE_IS_CIPHER(priv->hash))
-		purple_cipher_reset(priv->hash);
+	if(PURPLE_IS_HASH(priv->hash))
+		purple_hash_reset(priv->hash);
 
 	if(priv->opad) {
 		g_free(priv->opad);
@@ -80,17 +80,17 @@ purple_hmac_cipher_set_iv(PurpleCipher *
 purple_hmac_cipher_set_iv(PurpleCipher *cipher, guchar *iv, size_t len) {
 	PurpleHMACCipherPrivate *priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
 
-	if(PURPLE_IS_CIPHER(priv->hash))
-		purple_cipher_set_iv(priv->hash, iv, len);
+	if(PURPLE_IS_HASH(priv->hash))
+		purple_hash_set_iv(priv->hash, iv, len);
 }
 
 static void
 purple_hmac_cipher_append(PurpleCipher *cipher, const guchar *d, size_t l) {
 	PurpleHMACCipherPrivate *priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
 
-	g_return_if_fail(PURPLE_IS_CIPHER(priv->hash));
+	g_return_if_fail(PURPLE_IS_HASH(priv->hash));
 
-	purple_cipher_append(priv->hash, d, l);
+	purple_hash_append(priv->hash, d, l);
 }
 
 static gboolean
@@ -101,7 +101,7 @@ purple_hmac_cipher_digest(PurpleCipher *
 	size_t hash_len, block_size;
 	gboolean result = FALSE;
 
-	g_return_val_if_fail(PURPLE_IS_CIPHER(priv->hash), FALSE);
+	g_return_val_if_fail(PURPLE_IS_HASH(priv->hash), FALSE);
 
 	block_size = purple_hmac_function_get_block_size(PURPLE_HMAC_FUNCTION(priv->hash));
 
@@ -109,8 +109,8 @@ purple_hmac_cipher_digest(PurpleCipher *
 	digest = g_malloc(100);
 
 	/* get the digest of the data */
-	result = purple_cipher_digest(priv->hash, 100, digest, &hash_len);
-	purple_cipher_reset(priv->hash);
+	result = purple_hash_digest(priv->hash, 100, digest, &hash_len);
+	purple_hash_reset(priv->hash);
 
 	if(!result) {
 		g_free(digest);
@@ -119,11 +119,11 @@ purple_hmac_cipher_digest(PurpleCipher *
 	}
 
 	/* now append the opad and the digest from above */
-	purple_cipher_append(priv->hash, priv->opad, block_size);
-	purple_cipher_append(priv->hash, digest, hash_len);
+	purple_hash_append(priv->hash, priv->opad, block_size);
+	purple_hash_append(priv->hash, digest, hash_len);
 
 	/* do our last digest */
-	result = purple_cipher_digest(priv->hash, in_len, out, out_len);
+	result = purple_hash_digest(priv->hash, in_len, out, out_len);
 
 	/* cleanup */
 	g_free(digest);
@@ -149,11 +149,11 @@ purple_hmac_cipher_set_key_with_len(Purp
 	priv->opad = g_malloc(block_size);
 
 	if (key_len > block_size) {
-		purple_cipher_reset(priv->hash);
-		purple_cipher_append(priv->hash, key, key_len);
+		purple_hash_reset(priv->hash);
+		purple_hash_append(priv->hash, key, key_len);
 
 		full_key = g_malloc(100); /* TODO: Should be enough for now... */
-		purple_cipher_digest(priv->hash, 100, full_key, &key_len);
+		purple_hash_digest(priv->hash, 100, full_key, &key_len);
 	} else {
 		full_key = g_memdup(key, key_len);
 	}
@@ -170,8 +170,8 @@ purple_hmac_cipher_set_key_with_len(Purp
 
 	g_free(full_key);
 
-	purple_cipher_reset(priv->hash);
-	purple_cipher_append(priv->hash, ipad, block_size);
+	purple_hash_reset(priv->hash);
+	purple_hash_append(priv->hash, ipad, block_size);
 	g_free(ipad);
 }
 
@@ -261,7 +261,7 @@ purple_hmac_cipher_class_init(PurpleHMAC
 	cipher_class->set_key_with_len = purple_hmac_cipher_set_key_with_len;
 	cipher_class->get_block_size = purple_hmac_cipher_get_block_size;
 
-	pspec = g_param_spec_object("hash", "hash", "hash", PURPLE_TYPE_CIPHER,
+	pspec = g_param_spec_object("hash", "hash", "hash", PURPLE_TYPE_HASH,
 								G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
 	g_object_class_install_property(obj_class, PROP_HASH, pspec);
 }
@@ -296,15 +296,15 @@ PurpleCipher *
 }
 
 PurpleCipher *
-purple_hmac_cipher_new(PurpleCipher *hash) {
-	g_return_val_if_fail(PURPLE_IS_CIPHER(hash), NULL);
+purple_hmac_cipher_new(PurpleHash *hash) {
+	g_return_val_if_fail(PURPLE_IS_HASH(hash), NULL);
 
 	return g_object_new(PURPLE_TYPE_HMAC_CIPHER,
 						"hash", hash,
 						NULL);
 }
 
-PurpleCipher *
+PurpleHash *
 purple_hmac_cipher_get_hash(const PurpleHMACCipher *cipher) {
 	PurpleHMACCipherPrivate *priv = NULL;
 
============================================================
--- libpurple/cipher/hmaccipher.h	9aac4f253289575137da08e31aa2b01fc7ad9db6
+++ libpurple/cipher/hmaccipher.h	cca7eb43b059d01e31259c82f9952346e9582df0
@@ -27,6 +27,7 @@
 #define PURPLE_HMAC_CIPHER_H
 
 #include <cipher/cipher.h>
+#include <cipher/hash.h>
 
 #define PURPLE_TYPE_HMAC_CIPHER				(purple_hmac_cipher_get_gtype())
 #define PURPLE_HMAC_CIPHER(obj)				(G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_HMAC_CIPHER, PurpleHMACCipher))
@@ -74,9 +75,9 @@ GType purple_hmac_cipher_get_gtype(void)
 
 GType purple_hmac_cipher_get_gtype(void);
 
-PurpleCipher *purple_hmac_cipher_new(PurpleCipher *hash_cipher);
+PurpleCipher *purple_hmac_cipher_new(PurpleHash *hash_cipher);
 
-PurpleCipher *purple_hmac_cipher_get_hash(const PurpleHMACCipher *cipher);
+PurpleHash *purple_hmac_cipher_get_hash(const PurpleHMACCipher *cipher);
 
 GType purple_hmac_function_get_type(void);
 


More information about the Commits mailing list