comparison libpurple/protocols/myspace/myspace.c @ 25884:212fb65cef7f

explicit merge of 'ba66150a2a1efc5a5cee7204adab69208825630e' and 'ac72bbedc88fef81dfdd1e2a4b2587010a030657'
author Richard Laager <rlaager@wiktel.com>
date Fri, 02 Jan 2009 22:10:31 +0000
parents e22bc87b758b 3c224208b814
children 138c729f8c9a
comparison
equal deleted inserted replaced
25883:e22bc87b758b 25884:212fb65cef7f
547 PurpleCipherContext *rc4; 547 PurpleCipherContext *rc4;
548 548
549 guchar hash_pw[HASH_SIZE]; 549 guchar hash_pw[HASH_SIZE];
550 guchar key[HASH_SIZE]; 550 guchar key[HASH_SIZE];
551 gchar *password_utf16le, *password_utf8_lc; 551 gchar *password_utf16le, *password_utf8_lc;
552 guchar *data; 552 GString *data;
553 guchar *data_out; 553 guchar *data_out;
554 size_t data_len, data_out_len; 554 size_t data_out_len;
555 gsize conv_bytes_read, conv_bytes_written; 555 gsize conv_bytes_read, conv_bytes_written;
556 GError *conv_error; 556 GError *conv_error;
557 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE 557 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE
558 int i; 558 int i;
559 #endif 559 #endif
623 /* TODO: obtain IPs of network interfaces */ 623 /* TODO: obtain IPs of network interfaces */
624 624
625 /* rc4 encrypt: 625 /* rc4 encrypt:
626 * nonce1+email+IP list */ 626 * nonce1+email+IP list */
627 627
628 data_len = NONCE_SIZE + strlen(email) + MSIM_LOGIN_IP_LIST_LEN; 628 data = g_string_new(NULL);
629 data = g_new0(guchar, data_len); 629 g_string_append_len(data, nonce, NONCE_SIZE);
630 memcpy(data, nonce, NONCE_SIZE); 630 g_string_append(data, email);
631 memcpy(data + NONCE_SIZE, email, strlen(email)); 631 g_string_append_len(data, MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN);
632 memcpy(data + NONCE_SIZE + strlen(email), MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN); 632
633 633 data_out = g_new0(guchar, data->len);
634 data_out = g_new0(guchar, data_len); 634
635 635 purple_cipher_context_encrypt(rc4, (const guchar *)data->str,
636 purple_cipher_context_encrypt(rc4, (const guchar *)data, 636 data->len, data_out, &data_out_len);
637 data_len, data_out, &data_out_len);
638 purple_cipher_context_destroy(rc4); 637 purple_cipher_context_destroy(rc4);
639 g_free(data); 638
640 639 if (data_out_len != data->len) {
641 if (data_out_len != data_len) {
642 purple_debug_info("msim", "msim_compute_login_response: " 640 purple_debug_info("msim", "msim_compute_login_response: "
643 "data length mismatch: %" G_GSIZE_FORMAT " != %" 641 "data length mismatch: %" G_GSIZE_FORMAT " != %"
644 G_GSIZE_FORMAT "\n", data_out_len, data_len); 642 G_GSIZE_FORMAT "\n", data_out_len, data->len);
645 } 643 }
644
645 g_string_free(data, TRUE);
646 646
647 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE 647 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE
648 purple_debug_info("msim", "response=<%s>\n", data_out); 648 purple_debug_info("msim", "response=<%s>\n", data_out);
649 #endif 649 #endif
650 650