Mercurial > pidgin.yaz
annotate src/protocols/oscar/auth.c @ 13047:473d3a454615
[gaim-migrate @ 15408]
15:52:32 <NSA_> In the system tray, the "Custom Status..." should be changed to
"New Status..." to be more consistent.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Thu, 26 Jan 2006 20:54:00 +0000 |
parents | 59207955adc2 |
children |
rev | line source |
---|---|
2086 | 1 /* |
3912 | 2 * Family 0x0017 - Authentication. |
3 * | |
11404 | 4 * Deals with the authorizer for SNAC-based login, and also old-style |
3912 | 5 * non-SNAC login. |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6 * |
2086 | 7 */ |
8 | |
9 #define FAIM_INTERNAL | |
11404 | 10 #include "aim.h" |
2086 | 11 |
11448 | 12 #include "cipher.h" |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
13 |
7282 | 14 #include <ctype.h> |
15 | |
12308 | 16 #define USE_XOR_FOR_ICQ |
17 | |
10693 | 18 #ifdef USE_XOR_FOR_ICQ |
7253 | 19 /** |
20 * Encode a password using old XOR method | |
21 * | |
22 * This takes a const pointer to a (null terminated) string | |
23 * containing the unencoded password. It also gets passed | |
24 * an already allocated buffer to store the encoded password. | |
25 * This buffer should be the exact length of the password without | |
26 * the null. The encoded password buffer /is not %NULL terminated/. | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
27 * |
7253 | 28 * The encoding_table seems to be a fixed set of values. We'll |
11404 | 29 * hope it doesn't change over time! |
7253 | 30 * |
31 * This is only used for the XOR method, not the better MD5 method. | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
32 * |
7253 | 33 * @param password Incoming password. |
34 * @param encoded Buffer to put encoded password. | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
35 */ |
7253 | 36 static int aim_encode_password(const char *password, fu8_t *encoded) |
2086 | 37 { |
7253 | 38 fu8_t encoding_table[] = { |
39 #if 0 /* old v1 table */ | |
40 0xf3, 0xb3, 0x6c, 0x99, | |
41 0x95, 0x3f, 0xac, 0xb6, | |
42 0xc5, 0xfa, 0x6b, 0x63, | |
43 0x69, 0x6c, 0xc3, 0x9f | |
44 #else /* v2.1 table, also works for ICQ */ | |
45 0xf3, 0x26, 0x81, 0xc4, | |
46 0x39, 0x86, 0xdb, 0x92, | |
47 0x71, 0xa3, 0xb9, 0xe6, | |
48 0x53, 0x7a, 0x95, 0x7c | |
49 #endif | |
50 }; | |
7631 | 51 unsigned int i; |
2086 | 52 |
7253 | 53 for (i = 0; i < strlen(password); i++) |
54 encoded[i] = (password[i] ^ encoding_table[i]); | |
2086 | 55 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
56 return 0; |
2086 | 57 } |
10693 | 58 #endif |
2086 | 59 |
7253 | 60 #ifdef USE_OLD_MD5 |
61 static int aim_encode_password_md5(const char *password, const char *key, fu8_t *digest) | |
62 { | |
11404 | 63 GaimCipher *cipher; |
64 GaimCipherContext *context; | |
65 | |
66 cipher = gaim_ciphers_find_cipher("md5"); | |
7253 | 67 |
11404 | 68 context = gaim_cipher_context_new(cipher, NULL); |
69 gaim_cipher_context_append(context, (const guchar *)key, strlen(key)); | |
70 gaim_cipher_context_append(context, (const guchar *)password, strlen(password)); | |
71 gaim_cipher_context_append(context, (const guchar *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); | |
72 gaim_cipher_context_digest(context, 16, digest, NULL); | |
73 gaim_cipher_context_destroy(context); | |
7253 | 74 |
75 return 0; | |
76 } | |
77 #else | |
78 static int aim_encode_password_md5(const char *password, const char *key, fu8_t *digest) | |
79 { | |
11404 | 80 GaimCipher *cipher; |
81 GaimCipherContext *context; | |
82 guchar passdigest[16]; | |
83 | |
84 cipher = gaim_ciphers_find_cipher("md5"); | |
7253 | 85 |
11404 | 86 context = gaim_cipher_context_new(cipher, NULL); |
87 gaim_cipher_context_append(context, (const guchar *)password, strlen(password)); | |
88 gaim_cipher_context_digest(context, 16, passdigest, NULL); | |
89 gaim_cipher_context_destroy(context); | |
7253 | 90 |
11404 | 91 context = gaim_cipher_context_new(cipher, NULL); |
92 gaim_cipher_context_append(context, (const guchar *)key, strlen(key)); | |
93 gaim_cipher_context_append(context, passdigest, 16); | |
94 gaim_cipher_context_append(context, (const guchar *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); | |
95 gaim_cipher_context_digest(context, 16, digest, NULL); | |
96 gaim_cipher_context_destroy(context); | |
7253 | 97 |
98 return 0; | |
99 } | |
100 #endif | |
101 | |
2086 | 102 /* |
11404 | 103 * The FLAP version is sent by itself at the beginning of authorization |
104 * connections. The FLAP version is also sent before the cookie when connecting | |
7313 | 105 * for other services (BOS, chatnav, chat, etc.). |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
106 */ |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
107 faim_export int aim_sendflapver(aim_session_t *sess, aim_conn_t *conn) |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
108 { |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
109 aim_frame_t *fr; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
110 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
111 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 4))) |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
112 return -ENOMEM; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
113 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
114 aimbs_put32(&fr->data, 0x00000001); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
115 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
116 aim_tx_enqueue(sess, fr); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
117 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
118 return 0; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
119 } |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
120 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
121 /* |
7253 | 122 * This just pushes the passed cookie onto the passed connection, without |
123 * the SNAC header or any of that. | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
124 * |
7253 | 125 * Very commonly used, as every connection except auth will require this to |
126 * be the first thing you send. | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
127 * |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
128 */ |
7253 | 129 faim_export int aim_sendcookie(aim_session_t *sess, aim_conn_t *conn, const fu16_t length, const fu8_t *chipsahoy) |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
130 { |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
131 aim_frame_t *fr; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
132 aim_tlvlist_t *tl = NULL; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
133 |
10267 | 134 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 4+2+2+length))) |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
135 return -ENOMEM; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
136 |
7253 | 137 aimbs_put32(&fr->data, 0x00000001); |
138 aim_tlvlist_add_raw(&tl, 0x0006, length, chipsahoy); | |
7167 | 139 aim_tlvlist_write(&fr->data, &tl); |
140 aim_tlvlist_free(&tl); | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
141 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
142 aim_tx_enqueue(sess, fr); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
143 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
144 return 0; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
145 } |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
146 |
10693 | 147 #ifdef USE_XOR_FOR_ICQ |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
148 /* |
3458 | 149 * Part two of the ICQ hack. Note the ignoring of the key. |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
150 */ |
3458 | 151 static int goddamnicq2(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *password, struct client_info_s *ci) |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
152 { |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
153 aim_frame_t *fr; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
154 aim_tlvlist_t *tl = NULL; |
5345 | 155 int passwdlen; |
5927 | 156 fu8_t *password_encoded; |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
157 |
5345 | 158 passwdlen = strlen(password); |
11767 | 159 if (!(password_encoded = (fu8_t *)malloc(passwdlen+1))) |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
160 return -ENOMEM; |
5345 | 161 if (passwdlen > MAXICQPASSLEN) |
162 passwdlen = MAXICQPASSLEN; | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
163 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
164 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 1152))) { |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
165 free(password_encoded); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
166 return -ENOMEM; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
167 } |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
168 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
169 aim_encode_password(password, password_encoded); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
170 |
3458 | 171 aimbs_put32(&fr->data, 0x00000001); /* FLAP Version */ |
10991 | 172 aim_tlvlist_add_str(&tl, 0x0001, sn); |
7167 | 173 aim_tlvlist_add_raw(&tl, 0x0002, passwdlen, password_encoded); |
3458 | 174 |
175 if (ci->clientstring) | |
10991 | 176 aim_tlvlist_add_str(&tl, 0x0003, ci->clientstring); |
7167 | 177 aim_tlvlist_add_16(&tl, 0x0016, (fu16_t)ci->clientid); |
178 aim_tlvlist_add_16(&tl, 0x0017, (fu16_t)ci->major); | |
179 aim_tlvlist_add_16(&tl, 0x0018, (fu16_t)ci->minor); | |
180 aim_tlvlist_add_16(&tl, 0x0019, (fu16_t)ci->point); | |
181 aim_tlvlist_add_16(&tl, 0x001a, (fu16_t)ci->build); | |
182 aim_tlvlist_add_32(&tl, 0x0014, (fu32_t)ci->distrib); /* distribution chan */ | |
10991 | 183 aim_tlvlist_add_str(&tl, 0x000f, ci->lang); |
184 aim_tlvlist_add_str(&tl, 0x000e, ci->country); | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
185 |
7167 | 186 aim_tlvlist_write(&fr->data, &tl); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
187 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
188 free(password_encoded); |
7167 | 189 aim_tlvlist_free(&tl); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
190 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
191 aim_tx_enqueue(sess, fr); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
192 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
193 return 0; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
194 } |
10693 | 195 #endif |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
196 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
197 /* |
7253 | 198 * Subtype 0x0002 |
199 * | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
200 * This is the initial login request packet. |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
201 * |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
202 * NOTE!! If you want/need to make use of the aim_sendmemblock() function, |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
203 * then the client information you send here must exactly match the |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
204 * executable that you're pulling the data from. |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
205 * |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
206 * Java AIM 1.1.19: |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
207 * clientstring = "AOL Instant Messenger (TM) version 1.1.19 for Java built 03/24/98, freeMem 215871 totalMem 1048567, i686, Linus, #2 SMP Sun Feb 11 03:41:17 UTC 2001 2.4.1-ac9, IBM Corporation, 1.1.8, 45.3, Tue Mar 27 12:09:17 PST 2001" |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
208 * clientid = 0x0001 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
209 * major = 0x0001 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
210 * minor = 0x0001 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
211 * point = (not sent) |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
212 * build = 0x0013 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
213 * unknown= (not sent) |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
214 * |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
215 * AIM for Linux 1.1.112: |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
216 * clientstring = "AOL Instant Messenger (SM)" |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
217 * clientid = 0x1d09 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
218 * major = 0x0001 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
219 * minor = 0x0001 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
220 * point = 0x0001 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
221 * build = 0x0070 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
222 * unknown= 0x0000008b |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
223 * serverstore = 0x01 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
224 * |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
225 */ |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
226 faim_export int aim_send_login(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *password, struct client_info_s *ci, const char *key) |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
227 { |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
228 aim_frame_t *fr; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
229 aim_tlvlist_t *tl = NULL; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
230 fu8_t digest[16]; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
231 aim_snacid_t snacid; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
232 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
233 if (!ci || !sn || !password) |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
234 return -EINVAL; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
235 |
10693 | 236 #ifdef USE_XOR_FOR_ICQ |
7282 | 237 /* If we're signing on an ICQ account then use the older, XOR login method */ |
238 if (isdigit(sn[0])) | |
3458 | 239 return goddamnicq2(sess, conn, sn, password, ci); |
10693 | 240 #endif |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
241 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
242 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
243 return -ENOMEM; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
244 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
245 snacid = aim_cachesnac(sess, 0x0017, 0x0002, 0x0000, NULL, 0); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
246 aim_putsnac(&fr->data, 0x0017, 0x0002, 0x0000, snacid); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
247 |
10991 | 248 aim_tlvlist_add_str(&tl, 0x0001, sn); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
249 |
10712 | 250 /* Truncate ICQ passwords, if necessary */ |
251 if (isdigit(sn[0]) && (strlen(password) > MAXICQPASSLEN)) | |
252 { | |
253 char truncated[MAXICQPASSLEN + 1]; | |
254 strncpy(truncated, password, MAXICQPASSLEN); | |
255 truncated[MAXICQPASSLEN] = 0; | |
256 aim_encode_password_md5(truncated, key, digest); | |
257 } | |
258 else | |
259 { | |
260 aim_encode_password_md5(password, key, digest); | |
261 } | |
262 | |
7167 | 263 aim_tlvlist_add_raw(&tl, 0x0025, 16, digest); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
264 |
7253 | 265 #ifndef USE_OLD_MD5 |
266 aim_tlvlist_add_noval(&tl, 0x004c); | |
267 #endif | |
3213 | 268 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
269 if (ci->clientstring) |
10991 | 270 aim_tlvlist_add_str(&tl, 0x0003, ci->clientstring); |
7167 | 271 aim_tlvlist_add_16(&tl, 0x0016, (fu16_t)ci->clientid); |
272 aim_tlvlist_add_16(&tl, 0x0017, (fu16_t)ci->major); | |
273 aim_tlvlist_add_16(&tl, 0x0018, (fu16_t)ci->minor); | |
274 aim_tlvlist_add_16(&tl, 0x0019, (fu16_t)ci->point); | |
275 aim_tlvlist_add_16(&tl, 0x001a, (fu16_t)ci->build); | |
276 aim_tlvlist_add_32(&tl, 0x0014, (fu32_t)ci->distrib); | |
10991 | 277 aim_tlvlist_add_str(&tl, 0x000f, ci->lang); |
278 aim_tlvlist_add_str(&tl, 0x000e, ci->country); | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
279 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
280 /* |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
281 * If set, old-fashioned buddy lists will not work. You will need |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
282 * to use SSI. |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
283 */ |
7167 | 284 aim_tlvlist_add_8(&tl, 0x004a, 0x01); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
285 |
7167 | 286 aim_tlvlist_write(&fr->data, &tl); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
287 |
7167 | 288 aim_tlvlist_free(&tl); |
10267 | 289 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
290 aim_tx_enqueue(sess, fr); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
291 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
292 return 0; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
293 } |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
294 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
295 /* |
2086 | 296 * This is sent back as a general response to the login command. |
297 * It can be either an error or a success, depending on the | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10712
diff
changeset
|
298 * presence of certain TLVs. |
2086 | 299 * |
300 * The client should check the value passed as errorcode. If | |
301 * its nonzero, there was an error. | |
302 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
303 static int parse(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 304 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
305 aim_tlvlist_t *tlvlist; |
2704 | 306 aim_rxcallback_t userfunc; |
4102 | 307 struct aim_authresp_info *info; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
308 int ret = 0; |
2704 | 309 |
4102 | 310 info = (struct aim_authresp_info *)malloc(sizeof(struct aim_authresp_info)); |
311 memset(info, 0, sizeof(struct aim_authresp_info)); | |
2086 | 312 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
313 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
314 * Read block of TLVs. All further data is derived |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
315 * from what is parsed here. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
316 */ |
7167 | 317 tlvlist = aim_tlvlist_read(bs); |
2086 | 318 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
319 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
320 * No matter what, we should have a screen name. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
321 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
322 memset(sess->sn, 0, sizeof(sess->sn)); |
7167 | 323 if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) { |
324 info->sn = aim_tlv_getstr(tlvlist, 0x0001, 1); | |
4102 | 325 strncpy(sess->sn, info->sn, sizeof(sess->sn)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
326 } |
2086 | 327 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
328 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
329 * Check for an error code. If so, we should also |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
330 * have an error url. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
331 */ |
10267 | 332 if (aim_tlv_gettlv(tlvlist, 0x0008, 1)) |
7167 | 333 info->errorcode = aim_tlv_get16(tlvlist, 0x0008, 1); |
334 if (aim_tlv_gettlv(tlvlist, 0x0004, 1)) | |
335 info->errorurl = aim_tlv_getstr(tlvlist, 0x0004, 1); | |
2086 | 336 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
337 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
338 * BOS server address. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
339 */ |
7167 | 340 if (aim_tlv_gettlv(tlvlist, 0x0005, 1)) |
341 info->bosip = aim_tlv_getstr(tlvlist, 0x0005, 1); | |
2086 | 342 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
343 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
344 * Authorization cookie. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
345 */ |
7167 | 346 if (aim_tlv_gettlv(tlvlist, 0x0006, 1)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
347 aim_tlv_t *tmptlv; |
2086 | 348 |
7167 | 349 tmptlv = aim_tlv_gettlv(tlvlist, 0x0006, 1); |
2086 | 350 |
4293 | 351 info->cookielen = tmptlv->length; |
4102 | 352 info->cookie = tmptlv->value; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
353 } |
2086 | 354 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
355 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
356 * The email address attached to this account |
4102 | 357 * Not available for ICQ or @mac.com logins. |
358 * If you receive this TLV, then you are allowed to use | |
359 * family 0x0018 to check the status of your email. | |
4317 | 360 * XXX - Not really true! |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
361 */ |
7167 | 362 if (aim_tlv_gettlv(tlvlist, 0x0011, 1)) |
363 info->email = aim_tlv_getstr(tlvlist, 0x0011, 1); | |
2086 | 364 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
365 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
366 * The registration status. (Not real sure what it means.) |
4102 | 367 * Not available for ICQ or @mac.com logins. |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
368 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
369 * 1 = No disclosure |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
370 * 2 = Limited disclosure |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
371 * 3 = Full disclosure |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
372 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
373 * This has to do with whether your email address is available |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
374 * to other users or not. AFAIK, this feature is no longer used. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
375 * |
4102 | 376 * Means you can use the admin family? (0x0007) |
377 * | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
378 */ |
7167 | 379 if (aim_tlv_gettlv(tlvlist, 0x0013, 1)) |
380 info->regstatus = aim_tlv_get16(tlvlist, 0x0013, 1); | |
2086 | 381 |
7167 | 382 if (aim_tlv_gettlv(tlvlist, 0x0040, 1)) |
383 info->latestbeta.build = aim_tlv_get32(tlvlist, 0x0040, 1); | |
384 if (aim_tlv_gettlv(tlvlist, 0x0041, 1)) | |
385 info->latestbeta.url = aim_tlv_getstr(tlvlist, 0x0041, 1); | |
386 if (aim_tlv_gettlv(tlvlist, 0x0042, 1)) | |
387 info->latestbeta.info = aim_tlv_getstr(tlvlist, 0x0042, 1); | |
388 if (aim_tlv_gettlv(tlvlist, 0x0043, 1)) | |
389 info->latestbeta.name = aim_tlv_getstr(tlvlist, 0x0043, 1); | |
12429
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
390 |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
391 #if 0 |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
392 if (aim_tlv_gettlv(tlvlist, 0x0048, 1)) { |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
393 /* beta serial */ |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
394 } |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
395 #endif |
2086 | 396 |
7167 | 397 if (aim_tlv_gettlv(tlvlist, 0x0044, 1)) |
398 info->latestrelease.build = aim_tlv_get32(tlvlist, 0x0044, 1); | |
399 if (aim_tlv_gettlv(tlvlist, 0x0045, 1)) | |
400 info->latestrelease.url = aim_tlv_getstr(tlvlist, 0x0045, 1); | |
401 if (aim_tlv_gettlv(tlvlist, 0x0046, 1)) | |
402 info->latestrelease.info = aim_tlv_getstr(tlvlist, 0x0046, 1); | |
403 if (aim_tlv_gettlv(tlvlist, 0x0047, 1)) | |
404 info->latestrelease.name = aim_tlv_getstr(tlvlist, 0x0047, 1); | |
12429
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
405 |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
406 #if 0 |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
407 if (aim_tlv_gettlv(tlvlist, 0x0049, 1)) { |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
408 /* lastest release serial */ |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
409 } |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
410 #endif |
2086 | 411 |
3912 | 412 /* |
413 * URL to change password. | |
414 */ | |
7167 | 415 if (aim_tlv_gettlv(tlvlist, 0x0054, 1)) |
416 info->chpassurl = aim_tlv_getstr(tlvlist, 0x0054, 1); | |
4102 | 417 |
12429
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
418 #if 0 |
4102 | 419 /* |
420 * Unknown. Seen on an @mac.com screen name with value of 0x003f | |
421 */ | |
12429
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
422 if (aim_tlv_gettlv(tlvlist, 0x0055, 1)) { |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
423 /* Unhandled */ |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
424 } |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
12308
diff
changeset
|
425 #endif |
4102 | 426 |
427 sess->authinfo = info; | |
2086 | 428 |
2704 | 429 if ((userfunc = aim_callhandler(sess, rx->conn, snac ? snac->family : 0x0017, snac ? snac->subtype : 0x0003))) |
4102 | 430 ret = userfunc(sess, rx, info); |
2086 | 431 |
7167 | 432 aim_tlvlist_free(&tlvlist); |
2086 | 433 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
434 return ret; |
2086 | 435 } |
436 | |
10693 | 437 #ifdef USE_XOR_FOR_ICQ |
2086 | 438 /* |
7253 | 439 * Subtype 0x0007 (kind of) - Send a fake type 0x0007 SNAC to the client |
440 * | |
441 * This is a bit confusing. | |
442 * | |
443 * Normal SNAC login goes like this: | |
444 * - connect | |
445 * - server sends flap version | |
446 * - client sends flap version | |
447 * - client sends screen name (17/6) | |
448 * - server sends hash key (17/7) | |
449 * - client sends auth request (17/2 -- aim_send_login) | |
450 * - server yells | |
451 * | |
452 * XOR login (for ICQ) goes like this: | |
453 * - connect | |
454 * - server sends flap version | |
455 * - client sends auth request which contains flap version (aim_send_login) | |
456 * - server yells | |
457 * | |
458 * For the client API, we make them implement the most complicated version, | |
459 * and for the simpler version, we fake it and make it look like the more | |
460 * complicated process. | |
461 * | |
462 * This is done by giving the client a faked key, just so we can convince | |
463 * them to call aim_send_login right away, which will detect the session | |
464 * flag that says this is XOR login and ignore the key, sending an ICQ | |
465 * login request instead of the normal SNAC one. | |
466 * | |
467 * As soon as AOL makes ICQ log in the same way as AIM, this is /gone/. | |
468 * | |
469 * XXX This may cause problems if the client relies on callbacks only | |
470 * being called from the context of aim_rxdispatch()... | |
471 * | |
472 */ | |
473 static int goddamnicq(aim_session_t *sess, aim_conn_t *conn, const char *sn) | |
474 { | |
475 aim_frame_t fr; | |
476 aim_rxcallback_t userfunc; | |
10267 | 477 |
7253 | 478 fr.conn = conn; |
10267 | 479 |
7253 | 480 if ((userfunc = aim_callhandler(sess, conn, 0x0017, 0x0007))) |
481 userfunc(sess, &fr, ""); | |
482 | |
483 return 0; | |
484 } | |
10693 | 485 #endif |
7253 | 486 |
487 /* | |
488 * Subtype 0x0006 | |
489 * | |
490 * In AIM 3.5 protocol, the first stage of login is to request login from the | |
491 * Authorizer, passing it the screen name for verification. If the name is | |
492 * invalid, a 0017/0003 is spit back, with the standard error contents. If | |
493 * valid, a 0017/0007 comes back, which is the signal to send it the main | |
494 * login command (0017/0002). | |
495 * | |
496 */ | |
497 faim_export int aim_request_login(aim_session_t *sess, aim_conn_t *conn, const char *sn) | |
498 { | |
499 aim_frame_t *fr; | |
500 aim_snacid_t snacid; | |
501 aim_tlvlist_t *tl = NULL; | |
10267 | 502 |
7253 | 503 if (!sess || !conn || !sn) |
504 return -EINVAL; | |
505 | |
10693 | 506 #ifdef USE_XOR_FOR_ICQ |
7313 | 507 if (isdigit(sn[0])) |
7253 | 508 return goddamnicq(sess, conn, sn); |
10693 | 509 #endif |
7253 | 510 |
511 aim_sendflapver(sess, conn); | |
512 | |
10464 | 513 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(sn)+8 ))) |
7253 | 514 return -ENOMEM; |
515 | |
516 snacid = aim_cachesnac(sess, 0x0017, 0x0006, 0x0000, NULL, 0); | |
517 aim_putsnac(&fr->data, 0x0017, 0x0006, 0x0000, snacid); | |
518 | |
10991 | 519 aim_tlvlist_add_str(&tl, 0x0001, sn); |
10464 | 520 |
10644 | 521 /* Tell the server we support SecurID logins. */ |
10464 | 522 aim_tlvlist_add_noval(&tl, 0x004b); |
10644 | 523 |
524 /* Unknown. Sent in recent WinAIM clients.*/ | |
10464 | 525 aim_tlvlist_add_noval(&tl, 0x005a); |
526 | |
7253 | 527 aim_tlvlist_write(&fr->data, &tl); |
528 aim_tlvlist_free(&tl); | |
529 | |
530 aim_tx_enqueue(sess, fr); | |
531 | |
532 return 0; | |
533 } | |
534 | |
535 /* | |
536 * Subtype 0x0007 | |
537 * | |
2086 | 538 * Middle handler for 0017/0007 SNACs. Contains the auth key prefixed |
539 * by only its length in a two byte word. | |
540 * | |
541 * Calls the client, which should then use the value to call aim_send_login. | |
542 * | |
543 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
544 static int keyparse(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 545 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
546 int keylen, ret = 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
547 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
548 char *keystr; |
2086 | 549 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
550 keylen = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
551 keystr = aimbs_getstr(bs, keylen); |
2086 | 552 |
4230 | 553 /* XXX - When GiantGrayPanda signed on AIM I got a thing asking me to register |
554 * for the netscape network. This SNAC had a type 0x0058 TLV with length 10. | |
555 * Data is 0x0007 0004 3e19 ae1e 0006 0004 0000 0005 */ | |
556 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
557 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
558 ret = userfunc(sess, rx, keystr); |
2086 | 559 |
10267 | 560 free(keystr); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
561 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
562 return ret; |
2086 | 563 } |
564 | |
10464 | 565 /** |
566 * Subtype 0x000a | |
567 * | |
568 * Receive SecurID request. | |
569 */ | |
570 static int got_securid_request(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | |
571 { | |
572 int ret = 0; | |
573 aim_rxcallback_t userfunc; | |
574 | |
575 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
576 ret = userfunc(sess, rx); | |
577 | |
578 return ret; | |
579 } | |
580 | |
581 /** | |
582 * Subtype 0x000b | |
583 * | |
584 * Send SecurID response. | |
585 */ | |
586 faim_export int aim_auth_securid_send(aim_session_t *sess, const char *securid) | |
587 { | |
588 aim_conn_t *conn; | |
589 aim_frame_t *fr; | |
590 aim_snacid_t snacid; | |
591 int len; | |
592 | |
593 if (!sess || !(conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH)) || !securid) | |
594 return -EINVAL; | |
595 | |
596 len = strlen(securid); | |
597 | |
10467 | 598 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+len))) |
10464 | 599 return -ENOMEM; |
600 | |
601 snacid = aim_cachesnac(sess, AIM_CB_FAM_ATH, AIM_CB_ATH_SECURID_RESPONSE, 0x0000, NULL, 0); | |
602 aim_putsnac(&fr->data, AIM_CB_FAM_ATH, AIM_CB_ATH_SECURID_RESPONSE, 0x0000, 0); | |
603 | |
604 aimbs_put16(&fr->data, len); | |
10990 | 605 aimbs_putstr(&fr->data, securid); |
10464 | 606 |
607 aim_tx_enqueue(sess, fr); | |
608 | |
609 return 0; | |
610 } | |
611 | |
4102 | 612 static void auth_shutdown(aim_session_t *sess, aim_module_t *mod) |
613 { | |
614 if (sess->authinfo) { | |
615 free(sess->authinfo->sn); | |
616 free(sess->authinfo->bosip); | |
617 free(sess->authinfo->errorurl); | |
618 free(sess->authinfo->email); | |
619 free(sess->authinfo->chpassurl); | |
620 free(sess->authinfo->latestrelease.name); | |
621 free(sess->authinfo->latestrelease.url); | |
622 free(sess->authinfo->latestrelease.info); | |
623 free(sess->authinfo->latestbeta.name); | |
624 free(sess->authinfo->latestbeta.url); | |
625 free(sess->authinfo->latestbeta.info); | |
626 free(sess->authinfo); | |
627 } | |
628 } | |
629 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
630 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 631 { |
632 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
633 if (snac->subtype == 0x0003) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
634 return parse(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
635 else if (snac->subtype == 0x0007) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
636 return keyparse(sess, mod, rx, snac, bs); |
10464 | 637 else if (snac->subtype == 0x000a) |
638 return got_securid_request(sess, mod, rx, snac, bs); | |
2086 | 639 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
640 return 0; |
2086 | 641 } |
642 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
643 faim_internal int auth_modfirst(aim_session_t *sess, aim_module_t *mod) |
2086 | 644 { |
645 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
646 mod->family = 0x0017; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
647 mod->version = 0x0000; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
648 mod->flags = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
649 strncpy(mod->name, "auth", sizeof(mod->name)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
650 mod->snachandler = snachandler; |
4102 | 651 mod->shutdown = auth_shutdown; |
2086 | 652 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
653 return 0; |
2086 | 654 } |