Mercurial > pidgin
diff libpurple/protocols/yahoo/yahoo_crypt.c @ 15822:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 5fe8042783c1 |
children | 44b4e8bd759b |
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/yahoo_crypt.c Mon Mar 19 06:11:46 2007 +0000 +++ b/libpurple/protocols/yahoo/yahoo_crypt.c Mon Mar 19 07:01:17 2007 +0000 @@ -40,8 +40,8 @@ char *yahoo_crypt(const char *key, const char *salt) { - GaimCipher *cipher; - GaimCipherContext *context1, *context2; + PurpleCipher *cipher; + PurpleCipherContext *context1, *context2; guchar digest[16]; static char *buffer = NULL; static int buflen = 0; @@ -59,9 +59,9 @@ return NULL; } - cipher = gaim_ciphers_find_cipher("md5"); - context1 = gaim_cipher_context_new(cipher, NULL); - context2 = gaim_cipher_context_new(cipher, NULL); + cipher = purple_ciphers_find_cipher("md5"); + context1 = purple_cipher_context_new(cipher, NULL); + context2 = purple_cipher_context_new(cipher, NULL); /* Find beginning of salt string. The prefix should normally always * be present. Just in case it is not. @@ -74,40 +74,40 @@ key_len = strlen (key); /* Add the key string. */ - gaim_cipher_context_append(context1, (const guchar *)key, key_len); + purple_cipher_context_append(context1, (const guchar *)key, key_len); /* Because the SALT argument need not always have the salt prefix we * add it separately. */ - gaim_cipher_context_append(context1, (const guchar *)md5_salt_prefix, + purple_cipher_context_append(context1, (const guchar *)md5_salt_prefix, sizeof(md5_salt_prefix) - 1); /* The last part is the salt string. This must be at most 8 * characters and it ends at the first `$' character (for * compatibility which existing solutions). */ - gaim_cipher_context_append(context1, (const guchar *)salt, salt_len); + purple_cipher_context_append(context1, (const guchar *)salt, salt_len); /* Compute alternate MD5 sum with input KEY, SALT, and KEY. The * final result will be added to the first context. */ /* Add key. */ - gaim_cipher_context_append(context2, (const guchar *)key, key_len); + purple_cipher_context_append(context2, (const guchar *)key, key_len); /* Add salt. */ - gaim_cipher_context_append(context2, (const guchar *)salt, salt_len); + purple_cipher_context_append(context2, (const guchar *)salt, salt_len); /* Add key again. */ - gaim_cipher_context_append(context2, (const guchar *)key, key_len); + purple_cipher_context_append(context2, (const guchar *)key, key_len); /* Now get result of this (16 bytes) and add it to the other context. */ - gaim_cipher_context_digest(context2, sizeof(digest), digest, NULL); + purple_cipher_context_digest(context2, sizeof(digest), digest, NULL); /* Add for any character in the key one byte of the alternate sum. */ for (cnt = key_len; cnt > 16; cnt -= 16) - gaim_cipher_context_append(context1, digest, 16); - gaim_cipher_context_append(context1, digest, cnt); + purple_cipher_context_append(context1, digest, 16); + purple_cipher_context_append(context1, digest, cnt); /* For the following code we need a NUL byte. */ digest[0] = '\0'; @@ -118,11 +118,11 @@ * what was intended but we have to follow this to be compatible. */ for (cnt = key_len; cnt > 0; cnt >>= 1) - gaim_cipher_context_append(context1, + purple_cipher_context_append(context1, (cnt & 1) != 0 ? digest : (guchar *)key, 1); /* Create intermediate result. */ - gaim_cipher_context_digest(context1, sizeof(digest), digest, NULL); + purple_cipher_context_digest(context1, sizeof(digest), digest, NULL); /* Now comes another weirdness. In fear of password crackers here * comes a quite long loop which just processes the output of the @@ -130,30 +130,30 @@ */ for (cnt = 0; cnt < 1000; ++cnt) { /* New context. */ - gaim_cipher_context_reset(context2, NULL); + purple_cipher_context_reset(context2, NULL); /* Add key or last result. */ if ((cnt & 1) != 0) - gaim_cipher_context_append(context2, (const guchar *)key, key_len); + purple_cipher_context_append(context2, (const guchar *)key, key_len); else - gaim_cipher_context_append(context2, digest, 16); + purple_cipher_context_append(context2, digest, 16); /* Add salt for numbers not divisible by 3. */ if (cnt % 3 != 0) - gaim_cipher_context_append(context2, (const guchar *)salt, salt_len); + purple_cipher_context_append(context2, (const guchar *)salt, salt_len); /* Add key for numbers not divisible by 7. */ if (cnt % 7 != 0) - gaim_cipher_context_append(context2, (const guchar *)key, key_len); + purple_cipher_context_append(context2, (const guchar *)key, key_len); /* Add key or last result. */ if ((cnt & 1) != 0) - gaim_cipher_context_append(context2, digest, 16); + purple_cipher_context_append(context2, digest, 16); else - gaim_cipher_context_append(context2, (const guchar *)key, key_len); + purple_cipher_context_append(context2, (const guchar *)key, key_len); /* Create intermediate result. */ - gaim_cipher_context_digest(context2, sizeof(digest), digest, NULL); + purple_cipher_context_digest(context2, sizeof(digest), digest, NULL); } /* Now we can construct the result string. It consists of three parts. */ @@ -198,10 +198,10 @@ * information. We do it in this way to clear correct_words[] * inside the MD5 implementation as well. */ - gaim_cipher_context_reset(context1, NULL); - gaim_cipher_context_digest(context1, sizeof(digest), digest, NULL); - gaim_cipher_context_destroy(context1); - gaim_cipher_context_destroy(context2); + purple_cipher_context_reset(context1, NULL); + purple_cipher_context_digest(context1, sizeof(digest), digest, NULL); + purple_cipher_context_destroy(context1); + purple_cipher_context_destroy(context2); return buffer; }