| 334 encrypted_data = g_newa(guint8, QQ_LOGIN_DATA_LENGTH + 16); /* 16 bytes more */ |
334 encrypted_data = g_newa(guint8, QQ_LOGIN_DATA_LENGTH + 16); /* 16 bytes more */ |
| 335 qd->inikey = _gen_login_key(); |
335 qd->inikey = _gen_login_key(); |
| 336 |
336 |
| 337 /* now generate the encrypted data |
337 /* now generate the encrypted data |
| 338 * 000-015 use pwkey as key to encrypt empty string */ |
338 * 000-015 use pwkey as key to encrypt empty string */ |
| 339 qq_crypt(ENCRYPT, (guint8 *) "", 0, qd->pwkey, raw_data, &encrypted_len); |
339 qq_encrypt((guint8 *) "", 0, qd->pwkey, raw_data, &encrypted_len); |
| 340 /* 016-016 */ |
340 /* 016-016 */ |
| 341 raw_data[16] = 0x00; |
341 raw_data[16] = 0x00; |
| 342 /* 017-020, used to be IP, now zero */ |
342 /* 017-020, used to be IP, now zero */ |
| 343 *((guint32 *) (raw_data + 17)) = 0x00000000; |
343 *((guint32 *) (raw_data + 17)) = 0x00000000; |
| 344 /* 021-022, used to be port, now zero */ |
344 /* 021-022, used to be port, now zero */ |
| 360 g_memmove(raw_data + pos, login_100_bytes, 100); |
360 g_memmove(raw_data + pos, login_100_bytes, 100); |
| 361 pos += 100; |
361 pos += 100; |
| 362 /* all zero left */ |
362 /* all zero left */ |
| 363 memset(raw_data+pos, 0, QQ_LOGIN_DATA_LENGTH - pos); |
363 memset(raw_data+pos, 0, QQ_LOGIN_DATA_LENGTH - pos); |
| 364 |
364 |
| 365 qq_crypt(ENCRYPT, raw_data, QQ_LOGIN_DATA_LENGTH, qd->inikey, encrypted_data, &encrypted_len); |
365 qq_encrypt(raw_data, QQ_LOGIN_DATA_LENGTH, qd->inikey, encrypted_data, &encrypted_len); |
| 366 |
366 |
| 367 cursor = buf; |
367 cursor = buf; |
| 368 bytes = 0; |
368 bytes = 0; |
| 369 bytes += _create_packet_head_seq(buf, &cursor, gc, QQ_CMD_LOGIN, TRUE, &seq_ret); |
369 bytes += _create_packet_head_seq(buf, &cursor, gc, QQ_CMD_LOGIN, TRUE, &seq_ret); |
| 370 bytes += create_packet_dw(buf, &cursor, qd->uid); |
370 bytes += create_packet_dw(buf, &cursor, qd->uid); |
| 435 |
435 |
| 436 qd = (qq_data *) gc->proto_data; |
436 qd = (qq_data *) gc->proto_data; |
| 437 len = buf_len; |
437 len = buf_len; |
| 438 data = g_newa(guint8, len); |
438 data = g_newa(guint8, len); |
| 439 |
439 |
| 440 if (qq_crypt(DECRYPT, buf, buf_len, qd->pwkey, data, &len)) { |
440 if (qq_decrypt(buf, buf_len, qd->pwkey, data, &len)) { |
| 441 /* should be able to decrypt with pwkey */ |
441 /* should be able to decrypt with pwkey */ |
| 442 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Decrypt login reply packet with pwkey, %d bytes\n", len); |
442 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Decrypt login reply packet with pwkey, %d bytes\n", len); |
| 443 if (data[0] == QQ_LOGIN_REPLY_OK) { |
443 if (data[0] == QQ_LOGIN_REPLY_OK) { |
| 444 ret = _qq_process_login_ok(gc, data, len); |
444 ret = _qq_process_login_ok(gc, data, len); |
| 445 } else { |
445 } else { |
| 446 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Unknown login reply code : %d\n", data[0]); |
446 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Unknown login reply code : %d\n", data[0]); |
| 447 ret = QQ_LOGIN_REPLY_MISC_ERROR; |
447 ret = QQ_LOGIN_REPLY_MISC_ERROR; |
| 448 } |
448 } |
| 449 } else { /* decrypt with pwkey error */ |
449 } else { /* decrypt with pwkey error */ |
| 450 len = buf_len; /* reset len, decrypt will fail if len is too short */ |
450 len = buf_len; /* reset len, decrypt will fail if len is too short */ |
| 451 if (qq_crypt(DECRYPT, buf, buf_len, qd->inikey, data, &len)) { |
451 if (qq_decrypt(buf, buf_len, qd->inikey, data, &len)) { |
| 452 /* decrypt ok with inipwd, it might be password error */ |
452 /* decrypt ok with inipwd, it might be password error */ |
| 453 purple_debug(PURPLE_DEBUG_WARNING, "QQ", |
453 purple_debug(PURPLE_DEBUG_WARNING, "QQ", |
| 454 "Decrypt login reply packet with inikey, %d bytes\n", len); |
454 "Decrypt login reply packet with inikey, %d bytes\n", len); |
| 455 bytes = 0; |
455 bytes = 0; |
| 456 switch (data[0]) { |
456 switch (data[0]) { |