comparison src/protocols/jabber/auth.c @ 11127:719779387f96

[gaim-migrate @ 13183] Change the base16 and base64 functions to use better data types, and make appropriate changes to other parts of the Gaim code to get rid of a few warnings and hopefully make things more correct. In other news, why is CVS HEAD crashing for me on exit? committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 19 Jul 2005 05:15:45 +0000
parents 94cc67130789
children 096020ae09a9
comparison
equal deleted inserted replaced
11126:2a3568cbd8a6 11127:719779387f96
62 static void finish_plaintext_authentication(JabberStream *js) 62 static void finish_plaintext_authentication(JabberStream *js)
63 { 63 {
64 if(js->auth_type == JABBER_AUTH_PLAIN) { 64 if(js->auth_type == JABBER_AUTH_PLAIN) {
65 xmlnode *auth; 65 xmlnode *auth;
66 GString *response; 66 GString *response;
67 unsigned char *enc_out; 67 gchar *enc_out;
68 68
69 auth = xmlnode_new("auth"); 69 auth = xmlnode_new("auth");
70 xmlnode_set_attrib(auth, "xmlns", "urn:ietf:params:xml:ns:xmpp-sasl"); 70 xmlnode_set_attrib(auth, "xmlns", "urn:ietf:params:xml:ns:xmpp-sasl");
71 71
72 response = g_string_new(""); 72 response = g_string_new("");
74 response = g_string_append(response, js->user->node); 74 response = g_string_append(response, js->user->node);
75 response = g_string_append_len(response, "\0", 1); 75 response = g_string_append_len(response, "\0", 1);
76 response = g_string_append(response, 76 response = g_string_append(response,
77 gaim_connection_get_password(js->gc)); 77 gaim_connection_get_password(js->gc));
78 78
79 enc_out = gaim_base64_encode(response->str, response->len); 79 enc_out = gaim_base64_encode((guint8 *)response->str, response->len);
80 80
81 xmlnode_set_attrib(auth, "mechanism", "PLAIN"); 81 xmlnode_set_attrib(auth, "mechanism", "PLAIN");
82 xmlnode_insert_data(auth, enc_out, -1); 82 xmlnode_insert_data(auth, enc_out, -1);
83 g_free(enc_out); 83 g_free(enc_out);
84 g_string_free(response, TRUE); 84 g_string_free(response, TRUE);
305 GaimCipher *cipher; 305 GaimCipher *cipher;
306 GaimCipherContext *context; 306 GaimCipherContext *context;
307 guint8 result[16]; 307 guint8 result[16];
308 size_t a1len; 308 size_t a1len;
309 309
310 unsigned char *x, *a1, *ha1, *ha2, *kd, *z, *convnode, *convpasswd; 310 unsigned char *x, *a1, *kd, *convnode, *convpasswd;
311 gchar *ha1, *ha2, *z;
311 312
312 if((convnode = g_convert(jid->node, strlen(jid->node), "iso-8859-1", "utf-8", 313 if((convnode = g_convert(jid->node, strlen(jid->node), "iso-8859-1", "utf-8",
313 NULL, NULL, NULL)) == NULL) { 314 NULL, NULL, NULL)) == NULL) {
314 convnode = g_strdup(jid->node); 315 convnode = g_strdup(jid->node);
315 } 316 }
374 if(!enc_in) { 375 if(!enc_in) {
375 gaim_connection_error(js->gc, _("Invalid response from server.")); 376 gaim_connection_error(js->gc, _("Invalid response from server."));
376 return; 377 return;
377 } 378 }
378 379
379 gaim_base64_decode(enc_in, &dec_in, NULL); 380 dec_in = (char *)gaim_base64_decode(enc_in, NULL);
380 gaim_debug(GAIM_DEBUG_MISC, "jabber", "decoded challenge (%d): %s\n", 381 gaim_debug(GAIM_DEBUG_MISC, "jabber", "decoded challenge (%d): %s\n",
381 strlen(dec_in), dec_in); 382 strlen(dec_in), dec_in);
382 383
383 parts = parse_challenge(dec_in); 384 parts = parse_challenge(dec_in);
384 385
442 g_string_append_printf(response, ",charset=utf-8"); 443 g_string_append_printf(response, ",charset=utf-8");
443 444
444 g_free(auth_resp); 445 g_free(auth_resp);
445 g_free(cnonce); 446 g_free(cnonce);
446 447
447 enc_out = gaim_base64_encode(response->str, response->len); 448 enc_out = gaim_base64_encode((guint8 *)response->str, response->len);
448 449
449 gaim_debug(GAIM_DEBUG_MISC, "jabber", "decoded response (%d): %s\n", response->len, response->str); 450 gaim_debug(GAIM_DEBUG_MISC, "jabber", "decoded response (%d): %s\n", response->len, response->str);
450 451
451 buf = g_strdup_printf("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>%s</response>", enc_out); 452 buf = g_strdup_printf("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>%s</response>", enc_out);
452 453