changeset 3157:2bb8b7380814

[gaim-migrate @ 3173] This should fix Yahoo so it works 100% Many thanks to Toby Gray for the patch. We went to the zoo together; it was fun. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 18 Apr 2002 23:49:42 +0000
parents 3fd77e1a6fa1
children ea6f8d8d74e5
files src/protocols/yahoo/yahoo.c
diffstat 1 files changed, 29 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/yahoo/yahoo.c	Thu Apr 18 01:22:37 2002 +0000
+++ b/src/protocols/yahoo/yahoo.c	Thu Apr 18 23:49:42 2002 +0000
@@ -378,7 +378,6 @@
 {
 	struct yahoo_data *yd = gc->proto_data;
 	GSList *l = pkt->hash;
-	struct yahoo_packet *newpkt;
 	char *name = NULL;
 	int state = 0;
 	int gamestate = 0;
@@ -745,45 +744,15 @@
 		char *hash_string_p = g_malloc(50 + strlen(sn));
 		char *hash_string_c = g_malloc(50 + strlen(sn));
 		
-		int ordering;
 		char checksum;
 		
-		char sv;
+		int sv;
 		
 		char *result6 = g_malloc(25);
 		char *result96 = g_malloc(25);
 
 		sv = seed[15];
-		checksum = sv % 16;
-
-		/* I bet there's some really cool mathematical pattern here if I looked hard enough.
-		 * But, this works. */
-		switch (checksum) {
-		case 1:
-		case 6:
-		case 9:
-		case 14:
-			
-			checksum = seed[9];
-			break;
-		case 3:
-		case 11:
-			checksum = seed[1];
-			break;
-		case 4:
-		case 12:
-			checksum = seed[3];
-			break;
-		case 5:
-		case 8:
-		case 13:
-		case 0:
-			checksum = seed[7];
-			break;
-		}
-		checksum = seed[checksum % 16];
-		
-		ordering = sv % 8;
+		sv = sv % 8;
 
 		md5_init(&ctx);
 		md5_append(&ctx, gc->password, strlen(gc->password));
@@ -795,49 +764,50 @@
 		md5_append(&ctx, crypt_result, strlen(crypt_result));
 		md5_finish(&ctx, result);
 		to_y64(crypt_hash, result, 16);
-		
-		/* I bet there's a nice pattern here, too. */
-		switch (ordering) {
+
+		switch (sv) {
 		case 1:
 		case 6:
+			checksum = seed[seed[9] % 16];
 			g_snprintf(hash_string_p, strlen(sn) + 50,
-				   "%c%s%s%s", checksum, gc->username, seed, password_hash);
-			g_snprintf(hash_string_c, strlen(sn) + 50,
+                                   "%c%s%s%s", checksum, gc->username, seed, password_hash);
+                        g_snprintf(hash_string_c, strlen(sn) + 50,
 				   "%c%s%s%s", checksum, gc->username, seed, crypt_hash);
 			break;
 		case 2:
 		case 7:
+			checksum = seed[seed[15] % 16];
 			g_snprintf(hash_string_p, strlen(sn) + 50,
-				   "%c%s%s%s", checksum, seed, password_hash, gc->username);
-			g_snprintf(hash_string_c, strlen(sn) + 50,
-				   "%c%s%s%s", checksum, seed, crypt_hash, gc->username);
-			break;			
+                                   "%c%s%s%s", checksum, seed, password_hash, gc->username);
+                        g_snprintf(hash_string_c, strlen(sn) + 50,
+                                   "%c%s%s%s", checksum, seed, crypt_hash, gc->username);
+			break;
 		case 3:
+			checksum = seed[seed[1] % 16];
 			g_snprintf(hash_string_p, strlen(sn) + 50,
-				   "%c%s%s%s", checksum, gc->username, password_hash, seed);
+                                   "%c%s%s%s", checksum, gc->username, password_hash, seed);
+                        g_snprintf(hash_string_c, strlen(sn) + 50,
+                                   "%c%s%s%s", checksum, gc->username, crypt_hash, seed);
+			break;
+		case 4:
+			checksum = seed[seed[3] % 16];
+			g_snprintf(hash_string_p, strlen(sn) + 50,
+				   "%c%s%s%s", checksum, password_hash, seed, gc->username);
 			g_snprintf(hash_string_c, strlen(sn) + 50,
-				   "%c%s%s%s", checksum, gc->username, crypt_hash, seed);
-			break;			
-		case 4:
-			g_snprintf(hash_string_p, strlen(sn) + 50,
-				   "%c%s%s%s", checksum, gc->username, password_hash, seed);
-			g_snprintf(hash_string_c, strlen(sn) + 50,
-				   "%c%s%s%s", checksum, gc->username, crypt_hash, seed);
-			break;	
+				   "%c%s%s%s", checksum, crypt_hash, seed, gc->username);
+			break;
 		case 0:
 		case 5:
+			checksum = seed[seed[7] % 16];
 			g_snprintf(hash_string_p, strlen(sn) + 50,
-				   "%c%s%s%s", checksum, password_hash, gc->username, seed);
-			g_snprintf(hash_string_c, strlen(sn) + 50,
+                                   "%c%s%s%s", checksum, password_hash, gc->username, seed);
+                        g_snprintf(hash_string_c, strlen(sn) + 50,
 				   "%c%s%s%s", checksum, crypt_hash, gc->username, seed);
-			break;		
+			break;
 		}
-
-		debug_printf("\nPassword: %s\n", hash_string_p);
-		debug_printf("Crypt:    %s\n\n", hash_string_c);
-
+		
 		md5_init(&ctx);  
-		md5_append(&ctx, hash_string_p, strlen(hash_string_c));
+		md5_append(&ctx, hash_string_p, strlen(hash_string_p));
 		md5_finish(&ctx, result);
 		to_y64(result6, result, 16);
 
@@ -846,11 +816,6 @@
 		md5_finish(&ctx, result);
 		to_y64(result96, result, 16);
 
-		md5_init(&ctx);
-		md5_append(&ctx, gc->password, strlen(gc->password));
-		md5_finish(&ctx, result);
-		to_y64(password_hash, result, 16);
-
 		pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0);
 		yahoo_packet_hash(pack, 0, gc->username);
 		yahoo_packet_hash(pack, 6, result6);