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