libpurple/protocols/gg/oauth/oauth.c

changeset 38311
0444cac8e452
parent 38197
4e604f83f847
parent 38305
016572eb1295
child 38341
3da74e727e78
--- a/libpurple/protocols/gg/oauth/oauth.c	Thu May 25 20:30:56 2017 -0500
+++ b/libpurple/protocols/gg/oauth/oauth.c	Tue May 30 16:51:05 2017 -0500
@@ -26,8 +26,6 @@
 #include "oauth.h"
 
 #include "oauth-parameter.h"
-#include "ciphers/hmaccipher.h"
-#include "ciphers/sha1hash.h"
 
 char *gg_oauth_static_nonce;		/* dla unit testów */
 char *gg_oauth_static_timestamp;	/* dla unit testów */
@@ -49,19 +47,14 @@
 
 static gchar *gg_hmac_sha1(const char *key, const char *message)
 {
-	PurpleCipher *cipher;
-	PurpleHash *hash;
+	GHmac *hmac;
 	guchar digest[20];
-
-	hash = purple_sha1_hash_new();
-	cipher = purple_hmac_cipher_new(hash);
+	gsize digest_len = 20;
 
-	purple_cipher_set_key(cipher, (guchar *)key, strlen(key));
-	purple_cipher_append(cipher, (guchar *)message, strlen(message));
-	purple_cipher_digest(cipher, digest, sizeof(digest));
-
-	g_object_unref(cipher);
-	g_object_unref(hash);
+	hmac = g_hmac_new(G_CHECKSUM_SHA1, (guchar *)key, strlen(key));
+	g_hmac_update(hmac, (guchar *)message, -1);
+	g_hmac_get_digest(hmac, digest, &digest_len);
+	g_hmac_unref(hmac);
 
 	return purple_base64_encode(digest, sizeof(digest));
 }

mercurial