From 34afea7dd6b066a9e7153d16a8e386c7c90ffe87 Mon Sep 17 00:00:00 2001 From: dequis Date: Sun, 18 Jan 2015 03:39:20 -0300 Subject: Use glib's GChecksum for md5/sha1 This changes behavior slightly: - md5_init()/sha1_init() allocate a GChecksum - md5_finish()/sha1_finish() close and free() it - md5_digest_keep() was added (no sha1 equivalent needed) And yes, glib has this concept of "closing" the GChecksum, which means it can't be used anymore after g_checksum_get_digest(). jabber_cache_add() actually seems to need to do that to generate some random-ish values, so i kept that working by adding a md5_digest_keep() function that copies the GChecksum before it gets closed GChecksum was introduced in glib 2.16, so the configure script version was bumped. We were already depending on glib 2.16 accidentally (some post-3.2.2 code uses GHashTableIter) --- lib/oauth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/oauth.c') diff --git a/lib/oauth.c b/lib/oauth.c index 6bf8e4e0..54c272c8 100644 --- a/lib/oauth.c +++ b/lib/oauth.c @@ -37,7 +37,7 @@ static char *oauth_sign( const char *method, const char *url, const char *params, struct oauth_info *oi ) { - uint8_t hash[sha1_hash_size]; + uint8_t hash[SHA1_HASH_SIZE]; GString *payload = g_string_new( "" ); char *key; char *s; @@ -65,7 +65,7 @@ static char *oauth_sign( const char *method, const char *url, /* base64_encode + HTTP escape it (both consumers need it that away) and we're done. */ - s = base64_encode( hash, sha1_hash_size ); + s = base64_encode( hash, SHA1_HASH_SIZE ); s = g_realloc( s, strlen( s ) * 3 + 1 ); http_encode( s ); -- cgit v1.2.3