Mercurial > pidgin.yaz
comparison src/protocols/jabber/auth.c @ 7267:109817b028a6
[gaim-migrate @ 7844]
a patch from Karsten Huneycutt (kph) to fix SASL authentication when the
realm isn't the same as the jabber server
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Wed, 15 Oct 2003 04:45:36 +0000 |
parents | e78c6f6e759c |
children | 632cee95cc5c |
comparison
equal
deleted
inserted
replaced
7266:dc3918a729e8 | 7267:109817b028a6 |
---|---|
196 return ret; | 196 return ret; |
197 } | 197 } |
198 | 198 |
199 static unsigned char* | 199 static unsigned char* |
200 generate_response_value(JabberID *jid, const char *passwd, const char *nonce, | 200 generate_response_value(JabberID *jid, const char *passwd, const char *nonce, |
201 const char *cnonce, const char *a2) | 201 const char *cnonce, const char *a2, const char *realm) |
202 { | 202 { |
203 md5_state_t ctx; | 203 md5_state_t ctx; |
204 md5_byte_t result[16]; | 204 md5_byte_t result[16]; |
205 | 205 |
206 char *x, *y, *a1, *ha1, *ha2, *kd, *z; | 206 char *x, *y, *a1, *ha1, *ha2, *kd, *z; |
207 | 207 |
208 x = g_strdup_printf("%s:%s:%s", jid->node, jid->domain, passwd); | 208 x = g_strdup_printf("%s:%s:%s", jid->node, realm, passwd); |
209 md5_init(&ctx); | 209 md5_init(&ctx); |
210 md5_append(&ctx, x, strlen(x)); | 210 md5_append(&ctx, x, strlen(x)); |
211 md5_finish(&ctx, result); | 211 md5_finish(&ctx, result); |
212 | 212 |
213 y = g_strndup(result, 16); | 213 y = g_strndup(result, 16); |
278 nonce = g_hash_table_lookup(parts, "nonce"); | 278 nonce = g_hash_table_lookup(parts, "nonce"); |
279 realm = g_hash_table_lookup(parts, "realm"); | 279 realm = g_hash_table_lookup(parts, "realm"); |
280 | 280 |
281 a2 = g_strdup_printf("AUTHENTICATE:xmpp/%s", realm); | 281 a2 = g_strdup_printf("AUTHENTICATE:xmpp/%s", realm); |
282 auth_resp = generate_response_value(js->user, | 282 auth_resp = generate_response_value(js->user, |
283 gaim_account_get_password(js->gc->account), nonce, cnonce, a2); | 283 gaim_account_get_password(js->gc->account), nonce, cnonce, a2, realm); |
284 g_free(a2); | 284 g_free(a2); |
285 | 285 |
286 a2 = g_strdup_printf(":xmpp/%s", realm); | 286 a2 = g_strdup_printf(":xmpp/%s", realm); |
287 js->expected_rspauth = generate_response_value(js->user, | 287 js->expected_rspauth = generate_response_value(js->user, |
288 gaim_account_get_password(js->gc->account), nonce, cnonce, a2); | 288 gaim_account_get_password(js->gc->account), nonce, cnonce, a2, realm); |
289 g_free(a2); | 289 g_free(a2); |
290 | 290 |
291 | 291 |
292 g_string_append_printf(response, "username=\"%s\"", js->user->node); | 292 g_string_append_printf(response, "username=\"%s\"", js->user->node); |
293 g_string_append_printf(response, ",realm=\"%s\"", realm); | 293 g_string_append_printf(response, ",realm=\"%s\"", realm); |