comparison libpurple/protocols/jabber/auth_scram.c @ 29094:40a46992c728

jabber: Interop with Prosody (via Tobias' code). Hooray!
author Paul Aurich <paul@darkrain42.org>
date Tue, 17 Nov 2009 21:37:14 +0000
parents 65a34cce02e3
children cea22db36ffc
comparison
equal deleted inserted replaced
29093:65a34cce02e3 29094:40a46992c728
30 30
31 static const struct { 31 static const struct {
32 const char *mech_substr; 32 const char *mech_substr;
33 const char *hash; 33 const char *hash;
34 } mech_hashes[] = { 34 } mech_hashes[] = {
35 { "-SHA-1-", "sha1" }, 35 { "-SHA-1", "sha1" },
36 }; 36 };
37 37
38 static const struct { 38 static const struct {
39 const char *hash; 39 const char *hash;
40 guint size; 40 guint size;
50 50
51 for (i = 0; i < G_N_ELEMENTS(mech_hashes); ++i) { 51 for (i = 0; i < G_N_ELEMENTS(mech_hashes); ++i) {
52 if (strstr(mech, mech_hashes[i].mech_substr)) 52 if (strstr(mech, mech_hashes[i].mech_substr))
53 return mech_hashes[i].hash; 53 return mech_hashes[i].hash;
54 } 54 }
55
56 purple_debug_error("jabber", "Unknown SCRAM mechanism %s\n", mech);
55 57
56 return NULL; 58 return NULL;
57 } 59 }
58 60
59 static guint hash_to_output_len(const gchar *hash) 61 static guint hash_to_output_len(const gchar *hash)
373 #ifdef CHANNEL_BINDING 375 #ifdef CHANNEL_BINDING
374 if (strstr(js->auth_mech_name, "-PLUS")) 376 if (strstr(js->auth_mech_name, "-PLUS"))
375 data->channel_binding = TRUE; 377 data->channel_binding = TRUE;
376 #endif 378 #endif
377 cnonce = ((guint64)g_random_int() << 32) | g_random_int(); 379 cnonce = ((guint64)g_random_int() << 32) | g_random_int();
378 data->cnonce = purple_base64_encode((guchar *)cnonce, sizeof(cnonce)); 380 data->cnonce = purple_base64_encode((guchar *)&cnonce, sizeof(cnonce));
379 381
380 data->auth_message = g_string_new(NULL); 382 data->auth_message = g_string_new(NULL);
381 g_string_printf(data->auth_message, "n=%s,r=%s", 383 g_string_printf(data->auth_message, "n=%s,r=%s",
382 js->user->node /* TODO: SaslPrep */, 384 js->user->node /* TODO: SaslPrep */,
383 data->cnonce); 385 data->cnonce);