Mercurial > pidgin
comparison src/protocols/yahoo/crypt.c @ 10687:b256ce6b85b8
[gaim-migrate @ 12235]
grim says this is really fixed this time.
committer: Tailor Script <tailor@pidgin.im>
| author | Etan Reisner <pidgin@unreliablesource.net> |
|---|---|
| date | Sat, 12 Mar 2005 01:10:37 +0000 |
| parents | 72a5babfa8b4 |
| children | 923b78741964 |
comparison
equal
deleted
inserted
replaced
| 10686:212946f774c0 | 10687:b256ce6b85b8 |
|---|---|
| 47 int needed = 3 + strlen (salt) + 1 + 26 + 1; | 47 int needed = 3 + strlen (salt) + 1 + 26 + 1; |
| 48 | 48 |
| 49 size_t salt_len; | 49 size_t salt_len; |
| 50 size_t key_len; | 50 size_t key_len; |
| 51 size_t cnt; | 51 size_t cnt; |
| 52 | |
| 52 char *cp; | 53 char *cp; |
| 53 | 54 |
| 54 if (buflen < needed) { | 55 if (buflen < needed) { |
| 55 buflen = needed; | 56 buflen = needed; |
| 56 if ((buffer = g_realloc(buffer, buflen)) == NULL) | 57 if ((buffer = g_realloc(buffer, buflen)) == NULL) |
| 98 | 99 |
| 99 /* Add key again. */ | 100 /* Add key again. */ |
| 100 gaim_cipher_context_append(context2, key, key_len); | 101 gaim_cipher_context_append(context2, key, key_len); |
| 101 | 102 |
| 102 /* Now get result of this (16 bytes) and add it to the other context. */ | 103 /* Now get result of this (16 bytes) and add it to the other context. */ |
| 103 gaim_cipher_context_digest(context2, NULL, digest); | 104 gaim_cipher_context_digest(context2, sizeof(digest), digest, NULL); |
| 104 | 105 |
| 105 /* Add for any character in the key one byte of the alternate sum. */ | 106 /* Add for any character in the key one byte of the alternate sum. */ |
| 106 for (cnt = key_len; cnt > 16; cnt -= 16) | 107 for (cnt = key_len; cnt > 16; cnt -= 16) |
| 107 gaim_cipher_context_append(context1, digest, 16); | 108 gaim_cipher_context_append(context1, digest, 16); |
| 108 gaim_cipher_context_append(context1, digest, cnt); | 109 gaim_cipher_context_append(context1, digest, cnt); |
| 118 for (cnt = key_len; cnt > 0; cnt >>= 1) | 119 for (cnt = key_len; cnt > 0; cnt >>= 1) |
| 119 gaim_cipher_context_append(context1, | 120 gaim_cipher_context_append(context1, |
| 120 (cnt & 1) != 0 ? digest : (guint8 *)key, 1); | 121 (cnt & 1) != 0 ? digest : (guint8 *)key, 1); |
| 121 | 122 |
| 122 /* Create intermediate result. */ | 123 /* Create intermediate result. */ |
| 123 gaim_cipher_context_digest(context1, NULL, digest); | 124 gaim_cipher_context_digest(context1, sizeof(digest), digest, NULL); |
| 124 | 125 |
| 125 /* Now comes another weirdness. In fear of password crackers here | 126 /* Now comes another weirdness. In fear of password crackers here |
| 126 * comes a quite long loop which just processes the output of the | 127 * comes a quite long loop which just processes the output of the |
| 127 * previous round again. We cannot ignore this here. | 128 * previous round again. We cannot ignore this here. |
| 128 */ | 129 */ |
| 149 gaim_cipher_context_append(context2, digest, 16); | 150 gaim_cipher_context_append(context2, digest, 16); |
| 150 else | 151 else |
| 151 gaim_cipher_context_append(context2, key, key_len); | 152 gaim_cipher_context_append(context2, key, key_len); |
| 152 | 153 |
| 153 /* Create intermediate result. */ | 154 /* Create intermediate result. */ |
| 154 gaim_cipher_context_digest(context2, NULL, digest); | 155 gaim_cipher_context_digest(context2, sizeof(digest), digest, NULL); |
| 155 } | 156 } |
| 156 | 157 |
| 157 /* Now we can construct the result string. It consists of three parts. */ | 158 /* Now we can construct the result string. It consists of three parts. */ |
| 158 strncpy(buffer, md5_salt_prefix, MAX (0, buflen)); | 159 strncpy(buffer, md5_salt_prefix, MAX (0, buflen)); |
| 159 cp = buffer + strlen(buffer); | 160 cp = buffer + strlen(buffer); |
| 195 * attaching to processes or reading core dumps cannot get any | 196 * attaching to processes or reading core dumps cannot get any |
| 196 * information. We do it in this way to clear correct_words[] | 197 * information. We do it in this way to clear correct_words[] |
| 197 * inside the MD5 implementation as well. | 198 * inside the MD5 implementation as well. |
| 198 */ | 199 */ |
| 199 gaim_cipher_context_reset(context1, NULL); | 200 gaim_cipher_context_reset(context1, NULL); |
| 200 gaim_cipher_context_digest(context1, NULL, digest); | 201 gaim_cipher_context_digest(context1, sizeof(digest), digest, NULL); |
| 201 gaim_cipher_context_destroy(context1); | 202 gaim_cipher_context_destroy(context1); |
| 202 gaim_cipher_context_destroy(context2); | 203 gaim_cipher_context_destroy(context2); |
| 203 | 204 |
| 204 return buffer; | 205 return buffer; |
| 205 } | 206 } |
