annotate src/protocols/qq/crypt.c @ 14142:89d043d547cc

[gaim-migrate @ 16784] Never allow Yahoo! to insert a NULL value into the outgoing packet hash. This fixes some random crashes when the packet gets sent, and yahoo_packet_length() is called, which eventually calls strlen(NULL), which crashes committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 16 Aug 2006 06:58:59 +0000
parents ef8490f9e823
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
1 /**
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
2 * The QQ2003C protocol plugin
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
3 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
4 * for gaim
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
5 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
6 * Copyright (C) 2004 Puzzlebird
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
7 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
11 * (at your option) any later version.
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
12 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
16 * GNU General Public License for more details.
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
17 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
21 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
22 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
23 * OICQ encryption algorithm
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
24 * Convert from ASM code provided by PerlOICQ
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
25 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
26 * Puzzlebird, Nov-Dec 2002
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
27 */
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
28
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
29 /*Notes: (OICQ uses 0x10 iterations, and modified something...)
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
30
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
31 IN : 64 bits of data in v[0] - v[1].
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
32 OUT: 64 bits of data in w[0] - w[1].
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
33 KEY: 128 bits of key in k[0] - k[3].
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
34
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
35 delta is chosen to be the real part of
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
36 the golden ratio: Sqrt(5/4) - 1/2 ~ 0.618034 multiplied by 2^32.
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
37
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
38 0x61C88647 is what we can track on the ASM codes.!!
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
39 */
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
40
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
41 #include <arpa/inet.h>
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
42
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
43 #include <string.h>
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
44
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
45 #include "crypt.h"
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
46 #include "debug.h"
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
47
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
48 /********************************************************************
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
49 * encryption
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
50 *******************************************************************/
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
51
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
52 /* TODO: convert these data types to proper glib ones */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
53 static void qq_encipher(unsigned long *const v, const unsigned long *const k, unsigned long *const w)
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
54 {
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
55 register unsigned long y = ntohl(v[0]),
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
56 z = ntohl(v[1]),
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
57 a = ntohl(k[0]),
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
58 b = ntohl(k[1]),
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
59 c = ntohl(k[2]),
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
60 d = ntohl(k[3]),
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
61 n = 0x10,
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
62 sum = 0,
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
63 delta = 0x9E3779B9; /* 0x9E3779B9 - 0x100000000 = -0x61C88647 */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
64
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
65 while (n-- > 0) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
66 sum += delta;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
67 y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
68 z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
69 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
70
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
71 w[0] = htonl(y);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
72 w[1] = htonl(z);
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
73 }
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
74
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
75 static int rand(void) { /* it can be the real random seed function */
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
76 return 0xdead;
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
77 } /* override with number, convenient for debug */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
78
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
79 /* we encrypt every eight byte block */
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
80 static void encrypt_every_8_byte(unsigned char *plain, unsigned char *plain_pre_8, unsigned char **crypted,
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
81 unsigned char **crypted_pre_8, unsigned char *key, int *count, int *pos_in_byte, int *is_header)
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
82 {
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
83 /* prepare plain text */
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
84 for (*pos_in_byte = 0; *pos_in_byte < 8; (*pos_in_byte)++) {
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
85 if (*is_header) {
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
86 plain[*pos_in_byte] ^= plain_pre_8[*pos_in_byte];
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
87 } else {
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
88 plain[*pos_in_byte] ^= (*crypted_pre_8)[*pos_in_byte];
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
89 }
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
90 }
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
91 /* encrypt it */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
92 qq_encipher((unsigned long *) plain, (unsigned long *) key, (unsigned long *) *crypted);
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
93
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
94 for (*pos_in_byte = 0; *pos_in_byte < 8; (*pos_in_byte)++) {
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
95 (*crypted)[*pos_in_byte] ^= plain_pre_8[*pos_in_byte];
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
96 }
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
97 memcpy(plain_pre_8, plain, 8); /* prepare next */
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
98
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
99 *crypted_pre_8 = *crypted; /* store position of previous 8 byte */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
100 *crypted += 8; /* prepare next output */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
101 *count += 8; /* outstrlen increase by 8 */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
102 *pos_in_byte = 0; /* back to start */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
103 *is_header = 0; /* and exit header */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
104 } /* encrypt_every_8_byte */
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
105
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
106
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
107 static void qq_encrypt(unsigned char *instr, int instrlen, unsigned char *key,
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
108 unsigned char *outstr, int *outstrlen_prt)
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
109 {
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
110 unsigned char plain[8], /* plain text buffer */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
111 plain_pre_8[8], /* plain text buffer, previous 8 bytes */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
112 *crypted, /* crypted text */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
113 *crypted_pre_8, /* crypted test, previous 8 bytes */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
114 *inp; /* current position in instr */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
115 int pos_in_byte = 1, /* loop in the byte */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
116 is_header = 1, /* header is one byte */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
117 count = 0, /* number of bytes being crypted */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
118 padding = 0; /* number of padding stuff */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
119
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
120 pos_in_byte = (instrlen + 0x0a) % 8; /* header padding decided by instrlen */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
121 if (pos_in_byte) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
122 pos_in_byte = 8 - pos_in_byte;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
123 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
124 plain[0] = (rand() & 0xf8) | pos_in_byte;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
125
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
126 memset(plain + 1, rand() & 0xff, pos_in_byte++);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
127 memset(plain_pre_8, 0x00, sizeof(plain_pre_8));
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
128
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
129 crypted = crypted_pre_8 = outstr;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
130
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
131 padding = 1; /* pad some stuff in header */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
132 while (padding <= 2) { /* at most two bytes */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
133 if (pos_in_byte < 8) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
134 plain[pos_in_byte++] = rand() & 0xff;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
135 padding++;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
136 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
137 if (pos_in_byte == 8) {
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
138 encrypt_every_8_byte(plain, plain_pre_8, &crypted, &crypted_pre_8, key, &count, &pos_in_byte, &is_header);
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
139 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
140 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
141
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
142 inp = instr;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
143 while (instrlen > 0) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
144 if (pos_in_byte < 8) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
145 plain[pos_in_byte++] = *(inp++);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
146 instrlen--;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
147 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
148 if (pos_in_byte == 8) {
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
149 encrypt_every_8_byte(plain, plain_pre_8, &crypted, &crypted_pre_8, key, &count, &pos_in_byte, &is_header);
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
150 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
151 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
152
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
153 padding = 1; /* pad some stuff in tail */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
154 while (padding <= 7) { /* at most seven bytes */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
155 if (pos_in_byte < 8) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
156 plain[pos_in_byte++] = 0x00;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
157 padding++;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
158 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
159 if (pos_in_byte == 8) {
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
160 encrypt_every_8_byte(plain, plain_pre_8, &crypted, &crypted_pre_8, key, &count, &pos_in_byte, &is_header);
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
161 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
162 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
163
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
164 *outstrlen_prt = count;
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
165 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
166
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
167
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
168 /********************************************************************
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
169 * decryption
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
170 ********************************************************************/
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
171
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
172 static void qq_decipher(unsigned long *const v, const unsigned long *const k, unsigned long *const w)
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
173 {
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
174 register unsigned long y = ntohl(v[0]),
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
175 z = ntohl(v[1]),
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
176 a = ntohl(k[0]),
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
177 b = ntohl(k[1]),
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
178 c = ntohl(k[2]),
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
179 d = ntohl(k[3]),
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
180 n = 0x10,
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
181 sum = 0xE3779B90, /* why this ? must be related with n value */
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
182 delta = 0x9E3779B9;
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
183
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
184 /* sum = delta<<5, in general sum = delta * n */
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
185 while (n-- > 0) {
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
186 z -= ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d);
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
187 y -= ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b);
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
188 sum -= delta;
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
189 }
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
190
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
191 w[0] = htonl(y);
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
192 w[1] = htonl(z);
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
193 }
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
194
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
195 static int decrypt_every_8_byte(unsigned char **crypt_buff, const int instrlen, const unsigned char * const key,
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
196 int *context_start, unsigned char *decrypted, int *pos_in_byte)
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
197 {
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
198 for (*pos_in_byte = 0; *pos_in_byte < 8; (*pos_in_byte)++) {
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
199 if (*context_start + *pos_in_byte >= instrlen)
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
200 return 1;
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
201 decrypted[*pos_in_byte] ^= (*crypt_buff)[*pos_in_byte];
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
202 }
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
203 qq_decipher((unsigned long *) decrypted, (unsigned long *) key, (unsigned long *) decrypted);
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
204
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
205 *context_start += 8;
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
206 *crypt_buff += 8;
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
207 *pos_in_byte = 0;
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
208
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
209 return 1;
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
210 }
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
211
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
212 /* return 0 if failed, 1 otherwise */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
213 static int qq_decrypt(unsigned char *instr, int instrlen, unsigned char *key,
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
214 unsigned char *outstr, int *outstrlen_ptr)
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
215 {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
216 unsigned char decrypted[8], m[8], *crypt_buff, *crypt_buff_pre_8, *outp;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
217 int count, context_start, pos_in_byte, padding;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
218
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
219 /* at least 16 bytes and %8 == 0 */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
220 if ((instrlen % 8) || (instrlen < 16)) {
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
221 gaim_debug(GAIM_DEBUG_ERROR, "QQ",
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
222 "Packet len is either too short or not a multiple of 8 bytes, read %d bytes\n", instrlen);
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
223 return 0;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
224 }
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
225 /* get information from header */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
226 qq_decipher((unsigned long *) instr, (unsigned long *) key, (unsigned long *) decrypted);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
227 pos_in_byte = decrypted[0] & 0x7;
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
228 count = instrlen - pos_in_byte - 10; /* this is the plaintext length */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
229 /* return if outstr buffer is not large enough or error plaintext length */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
230 if (*outstrlen_ptr < count || count < 0) {
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
231 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Buffer len %d is less than real len %d", *outstrlen_ptr, count);
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
232 return 0;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
233 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
234
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
235 memset(m, 0, 8);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
236 crypt_buff_pre_8 = m;
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
237 *outstrlen_ptr = count; /* everything is ok! set return string length */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
238
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
239 crypt_buff = instr + 8; /* address of real data start */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
240 context_start = 8; /* context is at the second block of 8 bytes */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
241 pos_in_byte++; /* start of paddng stuff */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
242
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
243 padding = 1; /* at least one in header */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
244 while (padding <= 2) { /* there are 2 byte padding stuff in header */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
245 if (pos_in_byte < 8) { /* bypass the padding stuff, it's nonsense data */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
246 pos_in_byte++;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
247 padding++;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
248 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
249 if (pos_in_byte == 8) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
250 crypt_buff_pre_8 = instr;
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
251 if (!decrypt_every_8_byte(&crypt_buff, instrlen, key, &context_start, decrypted, &pos_in_byte)) {
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
252 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "decrypt every 8 bytes error A");
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
253 return 0;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
254 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
255 }
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
256 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
257
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
258 outp = outstr;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
259 while (count != 0) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
260 if (pos_in_byte < 8) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
261 *outp = crypt_buff_pre_8[pos_in_byte] ^ decrypted[pos_in_byte];
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
262 outp++;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
263 count--;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
264 pos_in_byte++;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
265 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
266 if (pos_in_byte == 8) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
267 crypt_buff_pre_8 = crypt_buff - 8;
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
268 if (!decrypt_every_8_byte(&crypt_buff, instrlen, key, &context_start, decrypted, &pos_in_byte)) {
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
269 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "decrypt every 8 bytes error B");
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
270 return 0;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
271 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
272 }
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
273 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
274
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
275 for (padding = 1; padding < 8; padding++) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
276 if (pos_in_byte < 8) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
277 if (crypt_buff_pre_8[pos_in_byte] ^ decrypted[pos_in_byte])
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
278 return 0;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
279 pos_in_byte++;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
280 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
281 if (pos_in_byte == 8) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
282 crypt_buff_pre_8 = crypt_buff;
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
283 if (!decrypt_every_8_byte(&crypt_buff, instrlen, key, &context_start, decrypted, &pos_in_byte)) {
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
284 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "decrypt every 8 bytes error C");
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
285 return 0;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
286 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
287 }
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
288 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
289 return 1;
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
290 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
291
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
292 /* This is the Public Function */
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
293 /* return 1 is succeed, otherwise return 0 */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
294 int qq_crypt(unsigned char flag,
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
295 unsigned char *instr, int instrlen, unsigned char *key, unsigned char *outstr, int *outstrlen_ptr)
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
296 {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
297 if (flag == DECRYPT)
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
298 return qq_decrypt(instr, instrlen, key, outstr, outstrlen_ptr);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
299 else if (flag == ENCRYPT)
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
300 qq_encrypt(instr, instrlen, key, outstr, outstrlen_ptr);
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
301 else
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
302 return 0;
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
303
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13977
diff changeset
304 return 1;
13977
96947ec79828 [gaim-migrate @ 16536]
Mark Huetsch <markhuetsch>
parents: 13870
diff changeset
305 }