diff options
author | Ankit Vani <a@nevitus.org> | 2013-06-15 14:28:31 +0530 |
---|---|---|
committer | Ankit Vani <a@nevitus.org> | 2013-06-15 14:28:31 +0530 |
commit | 1e2bfbfaeaee421c70316b4fcb43fd7d95833edc (patch) | |
tree | e55062bf2914710cf2ae32b2e3ffbe7b3ea65ccd /libpurple/protocols/jabber/jutil.c | |
parent | ce68f8c4130e3a3e1fec08efa5412a1aee062be3 (diff) | |
download | pidgin-1e2bfbfaeaee421c70316b4fcb43fd7d95833edc.tar.gz |
Refactored protocols bonjour, gg, jabber to use the GObject-based PurpleCipher
Diffstat (limited to 'libpurple/protocols/jabber/jutil.c')
-rw-r--r-- | libpurple/protocols/jabber/jutil.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/libpurple/protocols/jabber/jutil.c b/libpurple/protocols/jabber/jutil.c index ba3e1c757c..e4bde1d05c 100644 --- a/libpurple/protocols/jabber/jutil.c +++ b/libpurple/protocols/jabber/jutil.c @@ -22,7 +22,6 @@ */ #include "internal.h" #include "account.h" -#include "cipher.h" #include "conversation.h" #include "debug.h" #include "server.h" @@ -33,6 +32,10 @@ #include "presence.h" #include "jutil.h" +#include "ciphers/md4.h" +#include "ciphers/md5.h" +#include "ciphers/sha1.h" + #ifdef USE_IDN #include <idna.h> #include <stringprep.h> @@ -736,25 +739,31 @@ char * jabber_calculate_data_hash(gconstpointer data, size_t len, const gchar *hash_algo) { - PurpleCipherContext *context; + PurpleCipher *hash = NULL; static gchar digest[129]; /* 512 bits hex + \0 */ - context = purple_cipher_context_new_by_name(hash_algo, NULL); - if (context == NULL) + /* FIXME: Check the source of this change and what we need here... */ + if (g_str_equal(hash_algo, "sha1")) + hash = purple_sha1_cipher_new(); + else if (g_str_equal(hash_algo, "md4")) + hash = purple_md4_cipher_new(); + else if (g_str_equal(hash_algo, "md5")) + hash = purple_md5_cipher_new(); + if (hash == NULL) { purple_debug_error("jabber", "Could not find %s cipher\n", hash_algo); g_return_val_if_reached(NULL); } /* Hash the data */ - purple_cipher_context_append(context, data, len); - if (!purple_cipher_context_digest_to_str(context, digest, sizeof(digest))) + purple_cipher_append(hash, data, len); + if (!purple_cipher_digest_to_str(hash, digest, sizeof(digest))) { purple_debug_error("jabber", "Failed to get digest for %s cipher.\n", hash_algo); g_return_val_if_reached(NULL); } - purple_cipher_context_destroy(context); + g_object_unref(G_OBJECT(hash)); return g_strdup(digest); } |