[librest] Use HMAC glib implementation instead of rolling our own



commit 2a8dac4cc7aeca25b182bb9806ddb1881f2f4994
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Sun Jun 17 13:39:32 2012 +0200

    Use HMAC glib implementation instead of rolling our own
    
    https://bugzilla.gnome.org/show_bug.cgi?id=658725

 configure.ac                    |    2 +-
 rest-extras/flickr-proxy-call.c |    1 -
 rest-extras/lastfm-proxy-call.c |    1 -
 rest/Makefile.am                |    4 +-
 rest/oauth-proxy-call.c         |    6 +-
 rest/oauth2-proxy-call.c        |    1 -
 rest/sha1.c                     |  108 ---------------------------------------
 rest/sha1.h                     |   22 --------
 8 files changed, 5 insertions(+), 140 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f1105ae..680ade1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,7 +40,7 @@ AM_PROG_CC_C_O
 LT_PREREQ([2.2.6])
 LT_INIT([disable-static])
 
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.24)
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.30)
 PKG_CHECK_MODULES(SOUP, libsoup-2.4)
 PKG_CHECK_MODULES(XML, libxml-2.0)
 PKG_CHECK_MODULES(GTHREAD, gthread-2.0)
diff --git a/rest-extras/flickr-proxy-call.c b/rest-extras/flickr-proxy-call.c
index a9bc6f7..51881dd 100644
--- a/rest-extras/flickr-proxy-call.c
+++ b/rest-extras/flickr-proxy-call.c
@@ -26,7 +26,6 @@
 #include "flickr-proxy-call.h"
 #include "flickr-proxy-private.h"
 #include "rest/rest-proxy-call-private.h"
-#include "rest/sha1.h"
 
 G_DEFINE_TYPE (FlickrProxyCall, flickr_proxy_call, REST_TYPE_PROXY_CALL)
 
diff --git a/rest-extras/lastfm-proxy-call.c b/rest-extras/lastfm-proxy-call.c
index 5e04038..afc7288 100644
--- a/rest-extras/lastfm-proxy-call.c
+++ b/rest-extras/lastfm-proxy-call.c
@@ -27,7 +27,6 @@
 #include "lastfm-proxy-call.h"
 #include "lastfm-proxy-private.h"
 #include "rest/rest-proxy-call-private.h"
-#include "rest/sha1.h"
 
 G_DEFINE_TYPE (LastfmProxyCall, lastfm_proxy_call, REST_TYPE_PROXY_CALL)
 
diff --git a/rest/Makefile.am b/rest/Makefile.am
index e8a313f..35067c5 100644
--- a/rest/Makefile.am
+++ b/rest/Makefile.am
@@ -18,9 +18,7 @@ lib_sources = \
 	oauth-proxy-private.h 		\
 	oauth2-proxy.c			\
 	oauth2-proxy-call.c		\
-	oauth2-proxy-private.h 		\
-	sha1.c				\
-	sha1.h
+	oauth2-proxy-private.h
 lib_headers = \
 	rest-param.h		\
 	rest-params.h		\
diff --git a/rest/oauth-proxy-call.c b/rest/oauth-proxy-call.c
index d8cff95..c9d1ecd 100644
--- a/rest/oauth-proxy-call.c
+++ b/rest/oauth-proxy-call.c
@@ -26,7 +26,6 @@
 #include "oauth-proxy-call.h"
 #include "oauth-proxy-private.h"
 #include "rest-proxy-call-private.h"
-#include "sha1.h"
 
 G_DEFINE_TYPE (OAuthProxyCall, oauth_proxy_call, REST_TYPE_PROXY_CALL)
 
@@ -163,8 +162,9 @@ sign_hmac (OAuthProxy *proxy, RestProxyCall *call, GHashTable *oauth_params)
   /* PLAINTEXT signature value is the HMAC-SHA1 key value */
   key = sign_plaintext (priv);
 
-  signature = hmac_sha1 (key, text->str);
-
+  signature = g_compute_hmac_for_string (G_CHECKSUM_SHA1,
+                                         (guchar *)key, strlen (key),
+                                         text->str, -1);
   g_free (key);
   g_string_free (text, TRUE);
 
diff --git a/rest/oauth2-proxy-call.c b/rest/oauth2-proxy-call.c
index f0d441c..87ad8f7 100644
--- a/rest/oauth2-proxy-call.c
+++ b/rest/oauth2-proxy-call.c
@@ -27,7 +27,6 @@
 #include "oauth2-proxy-call.h"
 #include "oauth2-proxy-private.h"
 #include "rest-proxy-call-private.h"
-#include "sha1.h"
 
 G_DEFINE_TYPE (OAuth2ProxyCall, oauth2_proxy_call, REST_TYPE_PROXY_CALL)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]