comparison libpurple/protocols/myspace/myspace.c @ 27155:8cb0f676c70d

Fix a few problems with our myspace login response: * email address should include the null terminator * we should add padding * don't send an incorrect ip address (instead, send nothing)
author Mark Doliner <mark@kingant.net>
date Tue, 23 Jun 2009 05:53:14 +0000
parents 5fbcfcbd6551
children 1bbed9fd046b
comparison
equal deleted inserted replaced
27154:5fbcfcbd6551 27155:8cb0f676c70d
517 types = g_list_append(types, status); 517 types = g_list_append(types, status);
518 518
519 return types; 519 return types;
520 } 520 }
521 521
522 /*
523 * TODO: This define is stolen from oscar.h.
524 * It's also in yahoo.h.
525 * It should be in libpurple/util.c
526 */
527 #define msim_put32(buf, data) ( \
528 (*((buf)) = (unsigned char)((data)>>24)&0xff), \
529 (*((buf)+1) = (unsigned char)((data)>>16)&0xff), \
530 (*((buf)+2) = (unsigned char)((data)>>8)&0xff), \
531 (*((buf)+3) = (unsigned char)(data)&0xff), \
532 4)
533
522 /** 534 /**
523 * Compute the base64'd login challenge response based on username, password, nonce, and IPs. 535 * Compute the base64'd login challenge response based on username, password, nonce, and IPs.
524 * 536 *
525 * @param nonce The base64 encoded nonce ('nc') field from the server. 537 * @param nonce The base64 encoded nonce ('nc') field from the server.
526 * @param email User's email address (used as login name). 538 * @param email User's email address (used as login name).
617 /* Note: 'key' variable is 0x14 bytes (from SHA-1 hash), 629 /* Note: 'key' variable is 0x14 bytes (from SHA-1 hash),
618 * but only first 0x10 used for the RC4 key. */ 630 * but only first 0x10 used for the RC4 key. */
619 purple_cipher_context_set_option(rc4, "key_len", (gpointer)0x10); 631 purple_cipher_context_set_option(rc4, "key_len", (gpointer)0x10);
620 purple_cipher_context_set_key(rc4, key); 632 purple_cipher_context_set_key(rc4, key);
621 633
622 /* TODO: obtain IPs of network interfaces */
623
624 /* rc4 encrypt: 634 /* rc4 encrypt:
625 * nonce1+email+IP list */ 635 * nonce1+email+IP list */
626 636
627 data = g_string_new(NULL); 637 data = g_string_new(NULL);
628 g_string_append_len(data, nonce, NONCE_SIZE); 638 g_string_append_len(data, nonce, NONCE_SIZE);
629 g_string_append(data, email); 639
640 /* Include the null terminator */
641 g_string_append_len(data, email, strlen(email) + 1);
642
643 while (data->len % 4 != 0)
644 g_string_append_c(data, 0xfb);
645
646 #ifdef SEND_OUR_IP_ADDRESSES
647 /* TODO: Obtain IPs of network interfaces instead of using this hardcoded value */
648 g_string_set_size(data, data->len + 4);
649 msim_put32(data->str + data->len - 4, MSIM_LOGIN_IP_LIST_LEN);
630 g_string_append_len(data, MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN); 650 g_string_append_len(data, MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN);
651 #else
652 g_string_set_size(data, data->len + 4);
653 msim_put32(data->str + data->len - 4, 0);
654 #endif /* !SEND_OUR_IP_ADDRESSES */
631 655
632 data_out = g_new0(guchar, data->len); 656 data_out = g_new0(guchar, data->len);
633 657
634 purple_cipher_context_encrypt(rc4, (const guchar *)data->str, 658 purple_cipher_context_encrypt(rc4, (const guchar *)data->str,
635 data->len, data_out, &data_out_len); 659 data->len, data_out, &data_out_len);