| 611 purple_connection_error_reason (js->gc, reason, msg); |
611 purple_connection_error_reason (js->gc, reason, msg); |
| 612 g_free(msg); |
612 g_free(msg); |
| 613 } else if(!strcmp(type, "result")) { |
613 } else if(!strcmp(type, "result")) { |
| 614 query = xmlnode_get_child(packet, "query"); |
614 query = xmlnode_get_child(packet, "query"); |
| 615 if(js->stream_id && xmlnode_get_child(query, "digest")) { |
615 if(js->stream_id && xmlnode_get_child(query, "digest")) { |
| 616 unsigned char hashval[20]; |
616 char *s, *hash; |
| 617 char *s, h[41], *p; |
|
| 618 int i; |
|
| 619 |
617 |
| 620 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); |
618 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); |
| 621 query = xmlnode_get_child(iq->node, "query"); |
619 query = xmlnode_get_child(iq->node, "query"); |
| 622 x = xmlnode_new_child(query, "username"); |
620 x = xmlnode_new_child(query, "username"); |
| 623 xmlnode_insert_data(x, js->user->node, -1); |
621 xmlnode_insert_data(x, js->user->node, -1); |
| 624 x = xmlnode_new_child(query, "resource"); |
622 x = xmlnode_new_child(query, "resource"); |
| 625 xmlnode_insert_data(x, js->user->resource, -1); |
623 xmlnode_insert_data(x, js->user->resource, -1); |
| 626 |
624 |
| 627 x = xmlnode_new_child(query, "digest"); |
625 x = xmlnode_new_child(query, "digest"); |
| 628 s = g_strdup_printf("%s%s", js->stream_id, pw); |
626 s = g_strdup_printf("%s%s", js->stream_id, pw); |
| 629 |
627 hash = jabber_calculate_data_sha1sum(s, strlen(s)); |
| 630 purple_cipher_digest_region("sha1", (guchar *)s, strlen(s), |
628 xmlnode_insert_data(x, hash, -1); |
| 631 sizeof(hashval), hashval, NULL); |
629 g_free(hash); |
| 632 |
|
| 633 p = h; |
|
| 634 for(i=0; i<20; i++, p+=2) |
|
| 635 snprintf(p, 3, "%02x", hashval[i]); |
|
| 636 xmlnode_insert_data(x, h, -1); |
|
| 637 g_free(s); |
630 g_free(s); |
| 638 jabber_iq_set_callback(iq, auth_old_result_cb, NULL); |
631 jabber_iq_set_callback(iq, auth_old_result_cb, NULL); |
| 639 jabber_iq_send(iq); |
632 jabber_iq_send(iq); |
| 640 |
633 |
| 641 } else if(js->stream_id && (x = xmlnode_get_child(query, "crammd5"))) { |
634 } else if(js->stream_id && (x = xmlnode_get_child(query, "crammd5"))) { |