Mercurial > pidgin.yaz
comparison src/protocols/oscar/auth.c @ 11404:677a3862260f
[gaim-migrate @ 13639]
Stop using separate md5 stuff in oscar and use Gaim's cipher API
instead. This reduces the need for G_MODULE_BIND_LOCAL
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 01 Sep 2005 03:30:18 +0000 |
parents | 1798ad0be460 |
children | 1d29b44038c7 |
comparison
equal
deleted
inserted
replaced
11403:f5b14ad58722 | 11404:677a3862260f |
---|---|
1 /* | 1 /* |
2 * Family 0x0017 - Authentication. | 2 * Family 0x0017 - Authentication. |
3 * | 3 * |
4 * Deals with the authorizer for SNAC-based login, and also old-style | 4 * Deals with the authorizer for SNAC-based login, and also old-style |
5 * non-SNAC login. | 5 * non-SNAC login. |
6 * | 6 * |
7 */ | 7 */ |
8 | 8 |
9 #define FAIM_INTERNAL | 9 #define FAIM_INTERNAL |
10 #include <aim.h> | 10 #include "aim.h" |
11 | 11 |
12 #include "md5.h" | 12 #include "cipher.c" |
13 | 13 |
14 #include <ctype.h> | 14 #include <ctype.h> |
15 | 15 |
16 #ifdef USE_XOR_FOR_ICQ | 16 #ifdef USE_XOR_FOR_ICQ |
17 /** | 17 /** |
22 * an already allocated buffer to store the encoded password. | 22 * an already allocated buffer to store the encoded password. |
23 * This buffer should be the exact length of the password without | 23 * This buffer should be the exact length of the password without |
24 * the null. The encoded password buffer /is not %NULL terminated/. | 24 * the null. The encoded password buffer /is not %NULL terminated/. |
25 * | 25 * |
26 * The encoding_table seems to be a fixed set of values. We'll | 26 * The encoding_table seems to be a fixed set of values. We'll |
27 * hope it doesn't change over time! | 27 * hope it doesn't change over time! |
28 * | 28 * |
29 * This is only used for the XOR method, not the better MD5 method. | 29 * This is only used for the XOR method, not the better MD5 method. |
30 * | 30 * |
31 * @param password Incoming password. | 31 * @param password Incoming password. |
32 * @param encoded Buffer to put encoded password. | 32 * @param encoded Buffer to put encoded password. |
56 #endif | 56 #endif |
57 | 57 |
58 #ifdef USE_OLD_MD5 | 58 #ifdef USE_OLD_MD5 |
59 static int aim_encode_password_md5(const char *password, const char *key, fu8_t *digest) | 59 static int aim_encode_password_md5(const char *password, const char *key, fu8_t *digest) |
60 { | 60 { |
61 md5_state_t state; | 61 GaimCipher *cipher; |
62 | 62 GaimCipherContext *context; |
63 md5_init(&state); | 63 |
64 md5_append(&state, (const md5_byte_t *)key, strlen(key)); | 64 cipher = gaim_ciphers_find_cipher("md5"); |
65 md5_append(&state, (const md5_byte_t *)password, strlen(password)); | 65 |
66 md5_append(&state, (const md5_byte_t *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); | 66 context = gaim_cipher_context_new(cipher, NULL); |
67 md5_finish(&state, (md5_byte_t *)digest); | 67 gaim_cipher_context_append(context, (const guchar *)key, strlen(key)); |
68 gaim_cipher_context_append(context, (const guchar *)password, strlen(password)); | |
69 gaim_cipher_context_append(context, (const guchar *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); | |
70 gaim_cipher_context_digest(context, 16, digest, NULL); | |
71 gaim_cipher_context_destroy(context); | |
68 | 72 |
69 return 0; | 73 return 0; |
70 } | 74 } |
71 #else | 75 #else |
72 static int aim_encode_password_md5(const char *password, const char *key, fu8_t *digest) | 76 static int aim_encode_password_md5(const char *password, const char *key, fu8_t *digest) |
73 { | 77 { |
74 md5_state_t state; | 78 GaimCipher *cipher; |
75 fu8_t passdigest[16]; | 79 GaimCipherContext *context; |
76 | 80 guchar passdigest[16]; |
77 md5_init(&state); | 81 |
78 md5_append(&state, (const md5_byte_t *)password, strlen(password)); | 82 cipher = gaim_ciphers_find_cipher("md5"); |
79 md5_finish(&state, (md5_byte_t *)&passdigest); | 83 |
80 | 84 context = gaim_cipher_context_new(cipher, NULL); |
81 md5_init(&state); | 85 gaim_cipher_context_append(context, (const guchar *)password, strlen(password)); |
82 md5_append(&state, (const md5_byte_t *)key, strlen(key)); | 86 gaim_cipher_context_digest(context, 16, passdigest, NULL); |
83 md5_append(&state, (const md5_byte_t *)&passdigest, 16); | 87 gaim_cipher_context_destroy(context); |
84 md5_append(&state, (const md5_byte_t *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); | 88 |
85 md5_finish(&state, (md5_byte_t *)digest); | 89 context = gaim_cipher_context_new(cipher, NULL); |
86 | 90 gaim_cipher_context_append(context, (const guchar *)key, strlen(key)); |
87 return 0; | 91 gaim_cipher_context_append(context, passdigest, 16); |
88 } | 92 gaim_cipher_context_append(context, (const guchar *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); |
89 #endif | 93 gaim_cipher_context_digest(context, 16, digest, NULL); |
90 | 94 gaim_cipher_context_destroy(context); |
91 /* | 95 |
92 * The FLAP version is sent by itself at the beginning of authorization | 96 return 0; |
93 * connections. The FLAP version is also sent before the cookie when connecting | 97 } |
98 #endif | |
99 | |
100 /* | |
101 * The FLAP version is sent by itself at the beginning of authorization | |
102 * connections. The FLAP version is also sent before the cookie when connecting | |
94 * for other services (BOS, chatnav, chat, etc.). | 103 * for other services (BOS, chatnav, chat, etc.). |
95 */ | 104 */ |
96 faim_export int aim_sendflapver(aim_session_t *sess, aim_conn_t *conn) | 105 faim_export int aim_sendflapver(aim_session_t *sess, aim_conn_t *conn) |
97 { | 106 { |
98 aim_frame_t *fr; | 107 aim_frame_t *fr; |