Mercurial > pidgin.yaz
changeset 22527:217fffe3f46f
Patch from ccpaging to clean up some QQ stuff. I removed the now commented
out qq_crypt() instead of, well, comment it out.
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Mon, 24 Mar 2008 07:14:29 +0000 |
parents | 06f195789c3e |
children | 322b92e28005 ebdbac0a51cf |
files | libpurple/protocols/qq/buddy_info.c libpurple/protocols/qq/buddy_list.c libpurple/protocols/qq/buddy_opt.c libpurple/protocols/qq/buddy_status.c libpurple/protocols/qq/crypt.c libpurple/protocols/qq/crypt.h libpurple/protocols/qq/file_trans.c libpurple/protocols/qq/group_network.c libpurple/protocols/qq/im.c libpurple/protocols/qq/keep_alive.c libpurple/protocols/qq/login_logout.c libpurple/protocols/qq/recv_core.c libpurple/protocols/qq/send_core.c libpurple/protocols/qq/sys_msg.c |
diffstat | 14 files changed, 36 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/qq/buddy_info.c Fri Mar 21 21:11:07 2008 +0000 +++ b/libpurple/protocols/qq/buddy_info.c Mon Mar 24 07:14:29 2008 +0000 @@ -541,7 +541,7 @@ len = buf_len; data = g_newa(guint8, len); - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { data[len] = '\0'; if (qd->uid == atoi((gchar *) data)) { /* return should be my uid */ purple_debug(PURPLE_DEBUG_INFO, "QQ", "Update info ACK OK\n"); @@ -718,7 +718,7 @@ data = g_newa(guint8, len); info = NULL; - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { if (NULL == (segments = split_data(data, len, "\x1e", QQ_CONTACT_FIELDS))) return; @@ -828,7 +828,7 @@ decr_len = buf_len; decr_buf = g_new0(guint8, buf_len); - if (!qq_crypt(DECRYPT, buf, buf_len, qd->session_key, decr_buf, &decr_len)) { + if (!qq_decrypt(buf, buf_len, qd->session_key, decr_buf, &decr_len)) { purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Couldn't decrypt get level packet\n"); }
--- a/libpurple/protocols/qq/buddy_list.c Fri Mar 21 21:11:07 2008 +0000 +++ b/libpurple/protocols/qq/buddy_list.c Mon Mar 24 07:14:29 2008 +0000 @@ -166,7 +166,7 @@ purple_debug(PURPLE_DEBUG_INFO, "QQ", "processing get_buddies_online_reply\n"); - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { _qq_show_packet("Get buddies online reply packet", data, len); @@ -262,7 +262,7 @@ data = g_newa(guint8, len); cursor = data; - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { read_packet_w(data, &cursor, len, &position); /* the following data is buddy list in this packet */ i = 0; @@ -356,7 +356,7 @@ data = g_newa(guint8, len); cursor = data; - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { read_packet_b(data, &cursor, len, &sub_cmd); g_return_if_fail(sub_cmd == 0x01); read_packet_b(data, &cursor, len, &reply_code);
--- a/libpurple/protocols/qq/buddy_opt.c Fri Mar 21 21:11:07 2008 +0000 +++ b/libpurple/protocols/qq/buddy_opt.c Mon Mar 24 07:14:29 2008 +0000 @@ -267,7 +267,7 @@ data = g_newa(guint8, len); cursor = data; - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { read_packet_b(data, &cursor, len, &reply); if (reply != QQ_ADD_BUDDY_AUTH_REPLY_OK) { purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Add buddy with auth request failed\n"); @@ -297,7 +297,7 @@ len = buf_len; data = g_newa(guint8, len); - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { cursor = data; read_packet_b(data, &cursor, len, &reply); if (reply != QQ_REMOVE_BUDDY_REPLY_OK) { @@ -326,7 +326,7 @@ len = buf_len; data = g_newa(guint8, len); - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { cursor = data; read_packet_b(data, &cursor, len, &reply); if (reply != QQ_REMOVE_SELF_REPLY_OK) @@ -381,7 +381,7 @@ data = g_newa(guint8, len); - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { if (NULL == (segments = split_data(data, len, "\x1f", 2))) return; uid = segments[0];
--- a/libpurple/protocols/qq/buddy_status.c Fri Mar 21 21:11:07 2008 +0000 +++ b/libpurple/protocols/qq/buddy_status.c Mon Mar 24 07:14:29 2008 +0000 @@ -195,7 +195,7 @@ len = buf_len; data = g_newa(guint8, len); - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { cursor = data; read_packet_b(data, &cursor, len, &reply); if (reply != QQ_CHANGE_ONLINE_STATUS_REPLY_OK) { @@ -232,7 +232,7 @@ data = g_newa(guint8, len); cursor = data; - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { s = g_new0(qq_buddy_status, 1); bytes = 0; /* 000-030: qq_buddy_status */
--- a/libpurple/protocols/qq/crypt.c Fri Mar 21 21:11:07 2008 +0000 +++ b/libpurple/protocols/qq/crypt.c Mon Mar 24 07:14:29 2008 +0000 @@ -99,7 +99,7 @@ *is_header = 0; /* and exit header */ } /* encrypt_block */ -static void qq_encrypt(const guint8 *const instr, gint instrlen, +void qq_encrypt(const guint8 *const instr, gint instrlen, const guint8 *const key, guint8 *outstr, gint *outstrlen_ptr) { @@ -211,7 +211,7 @@ } /* return 0 if failed, 1 otherwise */ -static gint qq_decrypt(const guint8 *const instr, gint instrlen, +gint qq_decrypt(const guint8 *const instr, gint instrlen, const guint8 *const key, guint8 *outstr, gint *outstrlen_ptr) { @@ -296,19 +296,3 @@ } return 1; } - -/* return 1 is succeed, otherwise return 0 */ -gint qq_crypt(gint flag, - const guint8 *const instr, gint instrlen, - const guint8 *const key, - guint8 *outstr, gint *outstrlen_ptr) -{ - if (flag == DECRYPT) - return qq_decrypt(instr, instrlen, key, outstr, outstrlen_ptr); - else if (flag == ENCRYPT) - qq_encrypt(instr, instrlen, key, outstr, outstrlen_ptr); - else - return 0; - - return 1; -}
--- a/libpurple/protocols/qq/crypt.h Fri Mar 21 21:11:07 2008 +0000 +++ b/libpurple/protocols/qq/crypt.h Mon Mar 24 07:14:29 2008 +0000 @@ -27,12 +27,12 @@ #include <glib.h> -#define DECRYPT 0x00 -#define ENCRYPT 0x01 - -gint qq_crypt(gint flag, - const guint8 *const instr, gint instrlen, - const guint8 *const key, - guint8 *outstr, gint *outstrlen_ptr); - +void qq_encrypt(const guint8 *const instr, gint instrlen, + const guint8 *const key, + guint8 *outstr, gint *outstrlen_ptr); + +gint qq_decrypt(const guint8 *const instr, gint instrlen, + const guint8 *const key, + guint8 *outstr, gint *outstrlen_ptr); + #endif
--- a/libpurple/protocols/qq/file_trans.c Fri Mar 21 21:11:07 2008 +0000 +++ b/libpurple/protocols/qq/file_trans.c Mon Mar 24 07:14:29 2008 +0000 @@ -357,7 +357,7 @@ g_free(hex_dump); encrypted_len = bytes + 16; encrypted_data = g_newa(guint8, encrypted_len); - qq_crypt(ENCRYPT, raw_data, bytes, info->file_session_key, encrypted_data, &encrypted_len); + qq_encrypt(raw_data, bytes, info->file_session_key, encrypted_data, &encrypted_len); /*debug: try to decrypt it */ /* if (QQ_DEBUG) { @@ -368,7 +368,7 @@ g_free(hex_dump); buf = g_newa(guint8, MAX_PACKET_SIZE); buflen = encrypted_len; - if (qq_crypt(DECRYPT, encrypted_data, encrypted_len, info->file_session_key, buf, &buflen)) { + if (qq_decrypt(encrypted_data, encrypted_len, info->file_session_key, buf, &buflen)) { purple_debug(PURPLE_DEBUG_INFO, "QQ", "decrypt success\n"); if (buflen == bytes && memcmp(raw_data, buf, buflen) == 0) purple_debug(PURPLE_DEBUG_INFO, "QQ", "checksum ok\n"); @@ -534,7 +534,7 @@ decrypted_data = g_newa(guint8, len); decrypted_len = len; - if (qq_crypt(DECRYPT, cursor, len - (cursor - data), qd->session_md5, decrypted_data, &decrypted_len)) { + if (qq_decrypt(cursor, len - (cursor - data), qd->session_md5, decrypted_data, &decrypted_len)) { gchar *hex_dump; cursor = decrypted_data + 16; /* skip md5 section */ read_packet_w(decrypted_data, &cursor, decrypted_len, &packet_type);
--- a/libpurple/protocols/qq/group_network.c Fri Mar 21 21:11:07 2008 +0000 +++ b/libpurple/protocols/qq/group_network.c Mon Mar 24 07:14:29 2008 +0000 @@ -149,7 +149,7 @@ return; } - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { if (len <= 2) { purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Group cmd reply is too short, only %d bytes\n", len); return;
--- a/libpurple/protocols/qq/im.c Fri Mar 21 21:11:07 2008 +0000 +++ b/libpurple/protocols/qq/im.c Mon Mar 24 07:14:29 2008 +0000 @@ -568,7 +568,7 @@ len = buf_len; data = g_newa(guint8, len); - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { cursor = data; read_packet_b(data, &cursor, len, &reply); if (reply != QQ_SEND_IM_REPLY_OK) { @@ -597,7 +597,7 @@ len = buf_len; data = g_newa(guint8, len); - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { if (len < 16) { /* we need to ack with the first 16 bytes */ purple_debug(PURPLE_DEBUG_ERROR, "QQ", "IM is too short\n"); return;
--- a/libpurple/protocols/qq/keep_alive.c Fri Mar 21 21:11:07 2008 +0000 +++ b/libpurple/protocols/qq/keep_alive.c Mon Mar 24 07:14:29 2008 +0000 @@ -77,7 +77,7 @@ len = buf_len; data = g_newa(guint8, len); - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { /* the last one is 60, don't know what it is */ if (NULL == (segments = split_data(data, len, "\x1f", 6))) return;
--- a/libpurple/protocols/qq/login_logout.c Fri Mar 21 21:11:07 2008 +0000 +++ b/libpurple/protocols/qq/login_logout.c Mon Mar 24 07:14:29 2008 +0000 @@ -336,7 +336,7 @@ /* now generate the encrypted data * 000-015 use pwkey as key to encrypt empty string */ - qq_crypt(ENCRYPT, (guint8 *) "", 0, qd->pwkey, raw_data, &encrypted_len); + qq_encrypt((guint8 *) "", 0, qd->pwkey, raw_data, &encrypted_len); /* 016-016 */ raw_data[16] = 0x00; /* 017-020, used to be IP, now zero */ @@ -362,7 +362,7 @@ /* all zero left */ memset(raw_data+pos, 0, QQ_LOGIN_DATA_LENGTH - pos); - qq_crypt(ENCRYPT, raw_data, QQ_LOGIN_DATA_LENGTH, qd->inikey, encrypted_data, &encrypted_len); + qq_encrypt(raw_data, QQ_LOGIN_DATA_LENGTH, qd->inikey, encrypted_data, &encrypted_len); cursor = buf; bytes = 0; @@ -437,7 +437,7 @@ len = buf_len; data = g_newa(guint8, len); - if (qq_crypt(DECRYPT, buf, buf_len, qd->pwkey, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->pwkey, data, &len)) { /* should be able to decrypt with pwkey */ purple_debug(PURPLE_DEBUG_INFO, "QQ", "Decrypt login reply packet with pwkey, %d bytes\n", len); if (data[0] == QQ_LOGIN_REPLY_OK) { @@ -448,7 +448,7 @@ } } else { /* decrypt with pwkey error */ len = buf_len; /* reset len, decrypt will fail if len is too short */ - if (qq_crypt(DECRYPT, buf, buf_len, qd->inikey, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->inikey, data, &len)) { /* decrypt ok with inipwd, it might be password error */ purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Decrypt login reply packet with inikey, %d bytes\n", len);
--- a/libpurple/protocols/qq/recv_core.c Fri Mar 21 21:11:07 2008 +0000 +++ b/libpurple/protocols/qq/recv_core.c Mon Mar 24 07:14:29 2008 +0000 @@ -91,7 +91,7 @@ msg_utf8 = NULL; _qq_show_packet("Processing unknown packet", buf, len); - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { gchar *hex_dump = hex_dump_to_str(data, len); purple_debug(PURPLE_DEBUG_WARNING, "QQ", ">>> [%d] %s, %d bytes -> [default] decrypt and dump\n%s",
--- a/libpurple/protocols/qq/send_core.c Fri Mar 21 21:11:07 2008 +0000 +++ b/libpurple/protocols/qq/send_core.c Mon Mar 24 07:14:29 2008 +0000 @@ -132,7 +132,7 @@ cursor = buf; bytes_written = 0; - qq_crypt(ENCRYPT, data, len, qd->session_key, encrypted_data, &encrypted_len); + qq_encrypt(data, len, qd->session_key, encrypted_data, &encrypted_len); seq_ret = seq; if (_create_packet_head_seq(buf, &cursor, gc, cmd, is_auto_seq, &seq_ret) >= 0) {
--- a/libpurple/protocols/qq/sys_msg.c Fri Mar 21 21:11:07 2008 +0000 +++ b/libpurple/protocols/qq/sys_msg.c Mon Mar 24 07:14:29 2008 +0000 @@ -288,7 +288,7 @@ len = buf_len; data = g_newa(guint8, len); - if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { if (NULL == (segments = split_data(data, len, "\x1f", 4))) return; code = segments[0];