comparison libpurple/protocols/jabber/auth.c @ 30896:4072761e3454

jabber: Slight improvements to the stream ID fix This warns that it will fail miserably with digestmd5 legacy auth. Also, document that crammd5 code and remove a check for js->stream_id since crammd5 doesn't use it (no salt!)
author Paul Aurich <paul@darkrain42.org>
date Tue, 31 Aug 2010 02:52:28 +0000
parents 8084631e2e84
children cea7e713ef07
comparison
equal deleted inserted replaced
30895:8084631e2e84 30896:4072761e3454
249 char *msg = jabber_parse_error(js, packet, &reason); 249 char *msg = jabber_parse_error(js, packet, &reason);
250 purple_connection_error_reason(js->gc, reason, msg); 250 purple_connection_error_reason(js->gc, reason, msg);
251 g_free(msg); 251 g_free(msg);
252 } else if (type == JABBER_IQ_RESULT) { 252 } else if (type == JABBER_IQ_RESULT) {
253 query = xmlnode_get_child(packet, "query"); 253 query = xmlnode_get_child(packet, "query");
254 if(js->stream_id && xmlnode_get_child(query, "digest")) { 254 if (js->stream_id && *js->stream_id &&
255 xmlnode_get_child(query, "digest")) {
255 char *s, *hash; 256 char *s, *hash;
256 257
257 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); 258 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth");
258 query = xmlnode_get_child(iq->node, "query"); 259 query = xmlnode_get_child(iq->node, "query");
259 x = xmlnode_new_child(query, "username"); 260 x = xmlnode_new_child(query, "username");
267 xmlnode_insert_data(x, hash, -1); 268 xmlnode_insert_data(x, hash, -1);
268 g_free(hash); 269 g_free(hash);
269 g_free(s); 270 g_free(s);
270 jabber_iq_set_callback(iq, auth_old_result_cb, NULL); 271 jabber_iq_set_callback(iq, auth_old_result_cb, NULL);
271 jabber_iq_send(iq); 272 jabber_iq_send(iq);
272 273 } else if ((x = xmlnode_get_child(query, "crammd5"))) {
273 } else if(js->stream_id && (x = xmlnode_get_child(query, "crammd5"))) { 274 /* For future reference, this appears to be a custom OS X extension
275 * to non-SASL authentication.
276 */
274 const char *challenge; 277 const char *challenge;
275 gchar digest[33]; 278 gchar digest[33];
276 PurpleCipherContext *hmac; 279 PurpleCipherContext *hmac;
277 280
278 /* Calculate the MHAC-MD5 digest */ 281 /* Calculate the MHAC-MD5 digest */