gobjectification: 0d1d0d43: a ton of compile cleanups from the hmac ...

grim at pidgin.im grim at pidgin.im
Sun Jul 19 14:25:21 EDT 2009


-----------------------------------------------------------------
Revision: 0d1d0d436c022bd3f7ca0f39d901997a1c02f33e
Ancestor: c4f372a2fd5dcdb458bee92c82231d3bf0e6c8e3
Author: grim at pidgin.im
Date: 2009-07-19T18:22:25
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/0d1d0d436c022bd3f7ca0f39d901997a1c02f33e

Modified files:
        libpurple/hmaccipher.c libpurple/protocols/jabber/auth.c
        libpurple/protocols/msn/nexus.c
        libpurple/protocols/oscar/clientlogin.c
        libpurple/protocols/oscar/oscar.c
        libpurple/protocols/yahoo/libymsg.c
        libpurple/protocols/yahoo/yahoo_aliases.c

ChangeLog: 

a ton of compile cleanups from the hmac cleanup as well as general compile failures


-------------- next part --------------
============================================================
--- libpurple/hmaccipher.c	50907282533399c5e3764b6d3551ea88d1364781
+++ libpurple/hmaccipher.c	6c8ba8959e4ea9f64fe4aceaa0176d8ca365faf1
@@ -67,14 +67,9 @@ 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)) {
+	if(PURPLE_IS_CIPHER(priv->hash))
 		purple_cipher_reset(priv->hash);
 
-		g_object_unref(G_OBJECT(priv->hash));
-
-		priv->hash = NULL;
-	}
-
 	if(priv->opad) {
 		g_free(priv->opad);
 		priv->opad = NULL;
============================================================
--- libpurple/protocols/jabber/auth.c	37b0ce311bdea332482874133363f5bd9a369d83
+++ libpurple/protocols/jabber/auth.c	d1d7092521e3aaea67c04cf8e1d2865a52abc6c1
@@ -653,12 +653,13 @@ 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;
+			PurpleCipher *hmac, *md5;
 
 			/* Calculate the MHAC-MD5 digest */
 			challenge = xmlnode_get_attrib(x, "challenge");
-			hmac = purple_hmac_cipher_new();
-			purple_cipher_set_hash(hmac, purple_md5_cipher_new());
+			md5 = purple_md5_cipher_new();
+			hmac = purple_hmac_cipher_new(md5);
+			g_object_unref(G_OBJECT(md5));
 			purple_cipher_set_key(hmac, (guchar *)pw);
 			purple_cipher_append(hmac, (guchar*)challenge, strlen(challenge));
 			purple_cipher_digest(hmac, sizeof(digest), digest, NULL);
============================================================
--- libpurple/protocols/msn/nexus.c	86e14da563f0abe9f91601eb9385ce0d5ff7e361
+++ libpurple/protocols/msn/nexus.c	c42e84025939e03b8e4ffd24b95492a63ec39f1d
@@ -100,20 +100,20 @@ rps_create_key(const char *key, int key_
 	const guchar magic[] = "WS-SecureConversation";
 	const int magic_len = sizeof(magic) - 1;
 
-	PurpleCipher *hmac;
+	PurpleCipher *hmac, *sha1;
 	guchar hash1[20], hash2[20], hash3[20], hash4[20];
 	char *result;
 
-	hmac = purple_hmac_cipher_new();
+	sha1 = purple_sha1_cipher_new();
+	hmac = purple_hmac_cipher_new(sha1);
+	g_object_unref(G_OBJECT(sha1));
 
-	g_object_set(G_OBJECT(hmac), "hash", purple_sha1_cipher_new(), NULL);
 	purple_cipher_set_key_with_len(hmac, (guchar *)key, key_len);
 	purple_cipher_append(hmac, magic, magic_len);
 	purple_cipher_append(hmac, (guchar *)data, data_len);
 	purple_cipher_digest(hmac, sizeof(hash1), hash1, NULL);
 
 	purple_cipher_reset(hmac);
-	g_object_set(G_OBJECT(hmac), "hash", purple_sha1_cipher_new(), NULL);
 	purple_cipher_set_key_with_len(hmac, (guchar *)key, key_len);
 	purple_cipher_append(hmac, hash1, 20);
 	purple_cipher_append(hmac, magic, magic_len);
@@ -121,13 +121,11 @@ rps_create_key(const char *key, int key_
 	purple_cipher_digest(hmac, sizeof(hash2), hash2, NULL);
 
 	purple_cipher_reset(hmac);
-	g_object_set(G_OBJECT(hmac), "hash", purple_sha1_cipher_new(), NULL);
 	purple_cipher_set_key_with_len(hmac, (guchar *)key, key_len);
 	purple_cipher_append(hmac, hash1, 20);
 	purple_cipher_digest(hmac, sizeof(hash3), hash3, NULL);
 
 	purple_cipher_reset(hmac);
-	g_object_set(G_OBJECT(hmac), "hash", purple_sha1_cipher_new(), NULL);
 	purple_cipher_set_key_with_len(hmac, (guchar *)key, key_len);
 	purple_cipher_append(hmac, hash3, sizeof(hash3));
 	purple_cipher_append(hmac, magic, magic_len);
@@ -175,7 +173,7 @@ msn_rps_encrypt(MsnNexus *nexus)
 	MsnUsrKey *usr_key;
 	const char magic1[] = "SESSION KEY HASH";
 	const char magic2[] = "SESSION KEY ENCRYPTION";
-	PurpleCipher *hmac;
+	PurpleCipher *hmac, *sha1;
 	size_t len;
 	guchar hash[20];
 	char *key1, *key2, *key3;
@@ -203,8 +201,9 @@ msn_rps_encrypt(MsnNexus *nexus)
 	iv[1] = rand();
 
 	len = strlen(nexus->nonce);
-	hmac = purple_hmac_cipher_new();
-	g_object_set(G_OBJECT(hmac), "hash", purple_sha1_cipher_new(), NULL);
+	sha1 = purple_sha1_cipher_new();
+	hmac = purple_hmac_cipher_new(sha1);
+	g_object_unref(G_OBJECT(sha1));
 	purple_cipher_set_key_with_len(hmac, (guchar *)key2, 24);
 	purple_cipher_append(hmac, (guchar *)nexus->nonce, len);
 	purple_cipher_digest(hmac, 20, hash, NULL);
@@ -609,8 +608,9 @@ 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));
-	hmac = purple_hmac_cipher_new();
-	g_object_set(G_OBJECT(hmac), "hash", purple_sha1_cipher_new(), NULL);
+	sha1 = purple_sha1_cipher_new();
+	hmac = purple_hmac_cipher_new(sha1);
+	g_object_unref(G_OBJECT(sha1));
 	purple_cipher_set_key_with_len(hmac, (guchar *)key, 24);
 	purple_cipher_append(hmac, (guchar *)signedinfo, strlen(signedinfo));
 	purple_cipher_digest(hmac, 20, signature, NULL);
============================================================
--- libpurple/protocols/oscar/clientlogin.c	1222f2616809bea3655bd0d4dfce1f63500a819e
+++ libpurple/protocols/oscar/clientlogin.c	f9ac0f2d0604e939e2cbc36f6dbeb2d6d8874fe5
@@ -38,6 +38,8 @@
 
 #include "cipher.h"
 #include "core.h"
+#include "hmaccipher.h"
+#include "sha256cipher.h"
 
 #include "oscar.h"
 
@@ -111,16 +113,19 @@ static gchar *hmac_sha256(const char *ke
  */
 static gchar *hmac_sha256(const char *key, const char *message)
 {
-	PurpleCipherContext *context;
+	PurpleCipher *hmac, *sha256;
 	guchar digest[32];
 
-	context = purple_cipher_context_new_by_name("hmac", NULL);
-	purple_cipher_context_set_option(context, "hash", "sha256");
-	purple_cipher_context_set_key(context, (guchar *)key);
-	purple_cipher_context_append(context, (guchar *)message, strlen(message));
-	purple_cipher_context_digest(context, sizeof(digest), digest, NULL);
-	purple_cipher_context_destroy(context);
+	sha256 = purple_sha256_cipher_new();
+	hmac = purple_hmac_cipher_new(sha256);
+	g_object_unref(G_OBJECT(sha256));
+	
+	purple_cipher_set_key(hmac, (guchar *)key);
+	purple_cipher_append(hmac, (guchar *)message, strlen(message));
+	purple_cipher_digest(hmac, sizeof(digest), digest, NULL);
 
+	g_object_unref(G_OBJECT(hmac));
+
 	return purple_base64_encode(digest, sizeof(digest));
 }
 
============================================================
--- libpurple/protocols/oscar/oscar.c	7fa9520b158ac8502c6009179cf266974a06e1e9
+++ libpurple/protocols/oscar/oscar.c	e5ddb9eb349805ca2811a921bd3806853f649fce
@@ -1952,7 +1952,7 @@ purple_parse_auth_securid_request_yes_cb
 purple_parse_auth_securid_request_yes_cb(gpointer user_data, const char *msg)
 {
 	PurpleConnection *gc = user_data;
-	OscarData *od = purple_connection_get_protocol_data(gc);
+	OscarData *od = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 
 	aim_auth_securid_send(od, msg);
 }
============================================================
--- libpurple/protocols/yahoo/libymsg.c	82b5f5ba6185f36cbc1e7dfc2aae2e930d400ab4
+++ libpurple/protocols/yahoo/libymsg.c	994d1429f0a1bb93a305c832988ee01a8e20de36
@@ -3689,7 +3689,7 @@ char *yahoo_status_text(PurpleBuddy *b)
 
 	account = purple_buddy_get_account(b);
 	gc = purple_account_get_connection(account);
-	if (!gc || !purple_connection_get_protocol_data(gc))
+	if (!gc || !purple_object_get_protocol_data(PURPLE_OBJECT(gc)))
 		return NULL;
 
 	f = yahoo_friend_find(gc, purple_buddy_get_name(b));
@@ -3958,8 +3958,8 @@ static void yahoo_act_id(PurpleConnectio
 
 static void yahoo_act_id(PurpleConnection *gc, PurpleRequestFields *fields)
 {
+	struct yahoo_data *yd = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	const char *name = yd->profiles[purple_request_fields_get_choice(fields, "id")];
-	struct yahoo_data *yd = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 
 	struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, yd->session_id);
 	yahoo_packet_hash_str(pkt, 3, name);
@@ -4057,7 +4057,7 @@ static void yahoo_show_act_id(PurplePlug
 	PurpleRequestFieldGroup *group;
 	PurpleRequestField *field;
 	PurpleConnection *gc = (PurpleConnection *) action->context;
-	struct yahoo_data *yd = purple_connection_get_protocol_data(gc);
+	struct yahoo_data *yd = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	const char *name = purple_connection_get_display_name(gc);
 	int iter;
 
============================================================
--- libpurple/protocols/yahoo/yahoo_aliases.c	e1fe3238bf19d4895a9bbc58fcdee2227cc6c9fd
+++ libpurple/protocols/yahoo/yahoo_aliases.c	3134e253f3ea4c0a3e34d7d2a59c7435e9141a0c
@@ -454,7 +454,7 @@ yahoo_set_userinfo_cb(PurpleConnection *
 {
 	xmlnode *node = xmlnode_new("ab");
 	xmlnode *ct = xmlnode_new_child(node, "ct");
-	struct yahoo_data *yd = purple_connection_get_protocol_data(gc);
+	struct yahoo_data *yd = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	PurpleAccount *account;
 	PurpleUtilFetchUrlData *url_data;
 	char *webaddress, *webpage;
@@ -594,7 +594,7 @@ void yahoo_set_userinfo(PurpleConnection
 
 void yahoo_set_userinfo(PurpleConnection *gc)
 {
-	struct yahoo_data *yd = purple_connection_get_protocol_data(gc);
+	struct yahoo_data *yd = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	PurpleRequestFields *fields = request_fields_from_personal_details(&yd->ypd,
 					purple_connection_get_display_name(gc));
 	purple_request_fields(gc, NULL, _("Set User Info"), NULL, fields,
@@ -692,7 +692,7 @@ void yahoo_process_contact_details(Purpl
 {
 	GSList *l = pkt->hash;
 	const char *who = NULL, *xml = NULL;
-	struct yahoo_data *yd = purple_connection_get_protocol_data(gc);
+	struct yahoo_data *yd = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 
 	for (; l; l = l->next) {
 		struct yahoo_pair *pair = l->data;


More information about the Commits mailing list