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