libpurple/protocols/oscar/kerberos.c

Thu, 16 Jun 2016 13:13:04 -0400

author
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
date
Thu, 16 Jun 2016 13:13:04 -0400
branch
oscar_auth
changeset 37772
d2294123c226
parent 37771
e72f18aea857
child 37901
41e45e18f3b2
child 38240
0552f69f1996
permissions
-rw-r--r--

oscar: Fix coding style, no whitespace before parenthesis of function calls

37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
1 /*
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
2 * Purple's oscar protocol plugin
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
3 * This file is the legal property of its developers.
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
4 * Please see the AUTHORS file distributed alongside this file.
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
5 *
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
6 * This library is free software; you can redistribute it and/or
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
9 * version 2 of the License, or (at your option) any later version.
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
10 *
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
11 * This library is distributed in the hope that it will be useful,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
14 * Lesser General Public License for more details.
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
15 *
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
17 * License along with this library; if not, write to the Free Software
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
19 */
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
20
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
21 /**
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
22 * This file implements AIM's kerberos procedure for authenticating
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
23 * users. This replaces the older MD5-based and XOR-based
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
24 * authentication methods that use SNAC family 0x0017.
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
25 *
37769
36f7f4789d1a oscar: Fix the file comment which still had references to the clientLogin auth
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37768
diff changeset
26 * This doesn't use SNACs or FLAPs at all. It makes https
36f7f4789d1a oscar: Fix the file comment which still had references to the clientLogin auth
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37768
diff changeset
27 * POSTs to AOL KDC server to validate the user based on the password they
36f7f4789d1a oscar: Fix the file comment which still had references to the clientLogin auth
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37768
diff changeset
28 * provided to us. Upon successful authentication we receive two tokens
36f7f4789d1a oscar: Fix the file comment which still had references to the clientLogin auth
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37768
diff changeset
29 * in the response. One is assumed to be the kerberos ticket for authentication
36f7f4789d1a oscar: Fix the file comment which still had references to the clientLogin auth
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37768
diff changeset
30 * on the various AOL websites, while the other contains BOSS information, such
36f7f4789d1a oscar: Fix the file comment which still had references to the clientLogin auth
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37768
diff changeset
31 * as the hostname and port number to use, the TLS certificate name as well as
36f7f4789d1a oscar: Fix the file comment which still had references to the clientLogin auth
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37768
diff changeset
32 * the cookie to use to authenticate to the BOS server.
36f7f4789d1a oscar: Fix the file comment which still had references to the clientLogin auth
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37768
diff changeset
33 * And then everything else is the same as with BUCP.
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
34 *
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
35 */
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
36
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
37 #include "oscar.h"
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
38 #include "oscarcommon.h"
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
39 #include "core.h"
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
40
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
41 #define MAXAIMPASSLEN 16
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
42
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
43 /*
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
44 * Incomplete X-SNAC format taken from reverse engineering doen by digsby:
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
45 * https://github.com/ifwe/digsby/blob/master/digsby/src/oscar/login2.py
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
46 */
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
47 typedef struct {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
48 aim_tlv_t *main_tlv;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
49 gchar *principal1;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
50 gchar *service;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
51 gchar *principal1_again;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
52 gchar *principal2;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
53 gchar unknown;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
54 guint8 *footer;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
55 struct {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
56 guint32 unknown1;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
57 guint32 unknown2;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
58 guint32 epoch_now;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
59 guint32 epoch_valid;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
60 guint32 epoch_renew;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
61 guint32 epoch_expire;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
62 guint32 unknown3;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
63 guint32 unknown4;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
64 guint32 unknown5;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
65 } dates;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
66 GSList *tlvlist;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
67 } aim_xsnac_token_t;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
68
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
69 typedef struct {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
70 guint16 family;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
71 guint16 subtype;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
72 guint8 flags[8];
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
73 guint16 request_id;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
74 guint32 epoch;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
75 guint32 unknown;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
76 gchar *principal1;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
77 gchar *principal2;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
78 guint16 num_tokens;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
79 aim_xsnac_token_t *tokens;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
80 GSList *tlvlist;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
81 } aim_xsnac_t;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
82
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
83 static gchar *get_kdc_url(OscarData *od)
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
84 {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
85 PurpleAccount *account = purple_connection_get_account(od->gc);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
86 const gchar *server;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
87 gchar *url;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
88 gchar *port_str = NULL;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
89 gint port;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
90
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
91 server = purple_account_get_string(account, "server", AIM_DEFAULT_KDC_SERVER);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
92 port = purple_account_get_int(account, "port", AIM_DEFAULT_KDC_PORT);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
93 if (port != 443)
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
94 port_str = g_strdup_printf(":%d", port);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
95 url = g_strdup_printf("https://%s%s/", server, port_str ? port_str : "");
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
96 g_free(port_str);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
97
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
98 return url;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
99 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
100
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
101 /*
37765
c96207fb539b Fix outdated comment copied from clientlogin.c.
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37763
diff changeset
102 * Using kerberos auth requires a developer ID. This key is for libpurple.
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
103 * It is the default key for all libpurple-based clients. AOL encourages
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
104 * UIs (especially ones with lots of users) to override this with their
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
105 * own key. This key is owned by the AIM account "markdoliner"
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
106 *
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
107 * Keys can be managed at http://developer.aim.com/manageKeys.jsp
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
108 */
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
109 #define DEFAULT_CLIENT_KEY "ma15d7JTxbmVG-RP"
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
110
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
111 static const char *get_client_key(OscarData *od)
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
112 {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
113 return oscar_get_ui_info_string(
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
114 od->icq ? "prpl-icq-clientkey" : "prpl-aim-clientkey",
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
115 DEFAULT_CLIENT_KEY);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
116 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
117
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
118 static void
37768
05fd9d875913 oscar: Set password_xored as gchar to remove a warning
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37767
diff changeset
119 aim_encode_password(const char *password, gchar *encoded)
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
120 {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
121 guint8 encoding_table[] = {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
122 0x76, 0x91, 0xc5, 0xe7,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
123 0xd0, 0xd9, 0x95, 0xdd,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
124 0x9e, 0x2F, 0xea, 0xd8,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
125 0x6B, 0x21, 0xc2, 0xbc,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
126
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
127 };
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
128 guint i;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
129
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
130 /*
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
131 * We truncate AIM passwords to 16 characters since that's what
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
132 * the official client does as well.
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
133 */
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
134 for (i = 0; i < strlen(password) && i < MAXAIMPASSLEN; i++)
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
135 encoded[i] = (password[i] ^ encoding_table[i]);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
136 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
137
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
138 static void
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
139 aim_xsnac_free(aim_xsnac_t *xsnac)
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
140 {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
141 gint i;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
142
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
143 g_free(xsnac->principal1);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
144 g_free(xsnac->principal2);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
145 aim_tlvlist_free(xsnac->tlvlist);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
146
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
147 for (i = 0; i < xsnac->num_tokens; i++) {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
148 g_free(xsnac->tokens[i].main_tlv->value);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
149 g_free(xsnac->tokens[i].main_tlv);
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
150 g_free(xsnac->tokens[i].principal1);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
151 g_free(xsnac->tokens[i].service);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
152 g_free(xsnac->tokens[i].principal1_again);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
153 g_free(xsnac->tokens[i].principal2);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
154 g_free(xsnac->tokens[i].footer);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
155 aim_tlvlist_free(xsnac->tokens[i].tlvlist);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
156 }
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
157 g_free(xsnac->tokens);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
158 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
159
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
160 static void
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
161 kerberos_login_cb(PurpleHttpConnection *http_conn,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
162 PurpleHttpResponse *response, gpointer _od)
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
163 {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
164 OscarData *od = _od;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
165 PurpleConnection *gc;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
166 const gchar *got_data;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
167 size_t got_len;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
168 ByteStream bs;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
169 aim_xsnac_t xsnac = {0};
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
170 guint16 len;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
171 gchar *bosip = NULL;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
172 gchar *tlsCertName = NULL;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
173 guint8 *cookie = NULL;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
174 guint32 cookie_len = 0;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
175 char *host; int port;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
176 gsize i;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
177
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
178 gc = od->gc;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
179
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
180 od->hc = NULL;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
181
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
182 if (!purple_http_response_is_successful(response)) {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
183 gchar *tmp;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
184 gchar *url;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
185
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
186 url = get_kdc_url(od);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
187 tmp = g_strdup_printf(_("Error requesting %s: %s"),
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
188 url,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
189 purple_http_response_get_error(response));
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
190 purple_connection_error(gc,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
191 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
192 g_free(tmp);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
193 g_free(url);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
194 return;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
195 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
196
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
197 got_data = purple_http_response_get_data(response, &got_len);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
198 purple_debug_info("oscar", "Received kerberos login HTTP response %lu : ", got_len);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
199
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
200 byte_stream_init(&bs, (guint8 *)got_data, got_len);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
201
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
202 xsnac.family = byte_stream_get16(&bs);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
203 xsnac.subtype = byte_stream_get16(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
204 byte_stream_getrawbuf(&bs, (guint8 *) xsnac.flags, 8);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
205
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
206 if (xsnac.family == 0x50C && xsnac.subtype == 0x0005) {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
207 purple_connection_error(gc,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
208 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
209 _("Incorrect password"));
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
210 return;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
211 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
212 if (xsnac.family != 0x50C || xsnac.subtype != 0x0003) {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
213 purple_connection_error(gc,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
214 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
215 _("Error parsing response from authentication server"));
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
216 return;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
217 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
218 xsnac.request_id = byte_stream_get16(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
219 xsnac.epoch = byte_stream_get32(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
220 xsnac.unknown = byte_stream_get32(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
221 len = byte_stream_get16(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
222 xsnac.principal1 = byte_stream_getstr(&bs, len);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
223 len = byte_stream_get16(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
224 xsnac.principal2 = byte_stream_getstr(&bs, len);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
225 xsnac.num_tokens = byte_stream_get16(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
226
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
227 purple_debug_info("oscar", "KDC: %d tokens between '%s' and '%s'\n",
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
228 xsnac.num_tokens, xsnac.principal1, xsnac.principal2);
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
229 xsnac.tokens = g_new0(aim_xsnac_token_t, xsnac.num_tokens);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
230 for (i = 0; i < xsnac.num_tokens; i++) {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
231 GSList *tlv;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
232
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
233 tlv = aim_tlvlist_readnum(&bs, 1);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
234 if (tlv)
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
235 xsnac.tokens[i].main_tlv = tlv->data;
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
236 g_slist_free(tlv);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
237
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
238 len = byte_stream_get16(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
239 xsnac.tokens[i].principal1 = byte_stream_getstr(&bs, len);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
240 len = byte_stream_get16(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
241 xsnac.tokens[i].service = byte_stream_getstr(&bs, len);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
242 len = byte_stream_get16(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
243 xsnac.tokens[i].principal1_again = byte_stream_getstr(&bs, len);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
244 len = byte_stream_get16(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
245 xsnac.tokens[i].principal2 = byte_stream_getstr(&bs, len);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
246 xsnac.tokens[i].unknown = byte_stream_get8(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
247 len = byte_stream_get16(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
248 xsnac.tokens[i].footer = byte_stream_getraw(&bs, len);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
249
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
250 xsnac.tokens[i].dates.unknown1 = byte_stream_get32(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
251 xsnac.tokens[i].dates.unknown2 = byte_stream_get32(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
252 xsnac.tokens[i].dates.epoch_now = byte_stream_get32(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
253 xsnac.tokens[i].dates.epoch_valid = byte_stream_get32(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
254 xsnac.tokens[i].dates.epoch_renew = byte_stream_get32(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
255 xsnac.tokens[i].dates.epoch_expire = byte_stream_get32(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
256 xsnac.tokens[i].dates.unknown3 = byte_stream_get32(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
257 xsnac.tokens[i].dates.unknown4 = byte_stream_get32(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
258 xsnac.tokens[i].dates.unknown5 = byte_stream_get32(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
259
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
260 len = byte_stream_get16(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
261 xsnac.tokens[i].tlvlist = aim_tlvlist_readnum(&bs, len);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
262
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
263 purple_debug_info("oscar", "Token %lu has %d TLVs for service '%s'\n",
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
264 i, len, xsnac.tokens[i].service);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
265 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
266 len = byte_stream_get16(&bs);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
267 xsnac.tlvlist = aim_tlvlist_readnum(&bs, len);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
268
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
269 for (i = 0; i < xsnac.num_tokens; i++) {
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
270 if (purple_strequal(xsnac.tokens[i].service, "im/boss")) {
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
271 aim_tlv_t *tlv;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
272 GSList *tlvlist;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
273 ByteStream tbs;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
274
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
275 tlv = aim_tlv_gettlv(xsnac.tokens[i].tlvlist, 0x0003, 1);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
276 if (tlv != NULL) {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
277 byte_stream_init(&tbs, tlv->value, tlv->length);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
278 byte_stream_get32(&tbs);
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
279 tlvlist = aim_tlvlist_read(&tbs);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
280 if (aim_tlv_gettlv(tlvlist, 0x0005, 1))
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
281 bosip = aim_tlv_getstr(tlvlist, 0x0005, 1);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
282 if (aim_tlv_gettlv(tlvlist, 0x0005, 1))
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
283 tlsCertName = aim_tlv_getstr(tlvlist, 0x008D, 1);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
284 tlv = aim_tlv_gettlv(tlvlist, 0x0006, 1);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
285 if (tlv) {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
286 cookie_len = tlv->length;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
287 cookie = tlv->value;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
288 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
289 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
290 break;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
291 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
292 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
293 if (bosip && cookie) {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
294 port = AIM_DEFAULT_KDC_PORT;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
295 for (i = 0; i < strlen(bosip); i++) {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
296 if (bosip[i] == ':') {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
297 port = atoi(&(bosip[i+1]));
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
298 break;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
299 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
300 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
301 host = g_strndup(bosip, i);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
302 oscar_connect_to_bos(gc, od, host, port, cookie, cookie_len, tlsCertName);
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
303 g_free(host);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
304 } else {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
305 purple_connection_error(gc,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
306 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
307 _("Unknown error during authentication"));
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
308 }
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
309 aim_xsnac_free(&xsnac);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
310 g_free(tlsCertName);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
311 g_free(bosip);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
312 }
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
313
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
314 /**
37765
c96207fb539b Fix outdated comment copied from clientlogin.c.
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37763
diff changeset
315 * This function sends a binary blob request to the Kerberos KDC server
c96207fb539b Fix outdated comment copied from clientlogin.c.
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37763
diff changeset
316 * https://kdc.uas.aol.com with the user's username and password and
c96207fb539b Fix outdated comment copied from clientlogin.c.
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37763
diff changeset
317 * receives the IM cookie, which is used to request a connection to the
c96207fb539b Fix outdated comment copied from clientlogin.c.
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37763
diff changeset
318 * BOSS server.
37767
5e65b489a31d oscar: Add a comment explaining the data and meaning of the KDC binary blob
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37766
diff changeset
319 * The binary data below is what AIM 8.0.8.1 sends in order to authenticate
5e65b489a31d oscar: Add a comment explaining the data and meaning of the KDC binary blob
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37766
diff changeset
320 * to the KDC server. It is an 'X-SNAC' packet, which is relatively similar
5e65b489a31d oscar: Add a comment explaining the data and meaning of the KDC binary blob
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37766
diff changeset
321 * to SNAC packets but somehow different.
5e65b489a31d oscar: Add a comment explaining the data and meaning of the KDC binary blob
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37766
diff changeset
322 * The header starts with the 0x50C family follow by 0x0002 subtype, then
5e65b489a31d oscar: Add a comment explaining the data and meaning of the KDC binary blob
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37766
diff changeset
323 * some fixed length data and TLVs. The string "COOL" appears in there for
5e65b489a31d oscar: Add a comment explaining the data and meaning of the KDC binary blob
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37766
diff changeset
324 * some reason followed by the 'US' and 'en' strings.
5e65b489a31d oscar: Add a comment explaining the data and meaning of the KDC binary blob
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37766
diff changeset
325 * Then the 'imApp key=<client key>' comes after that, and then the username
5e65b489a31d oscar: Add a comment explaining the data and meaning of the KDC binary blob
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37766
diff changeset
326 * and the string "im/boss" which seems to represent the service we are
5e65b489a31d oscar: Add a comment explaining the data and meaning of the KDC binary blob
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37766
diff changeset
327 * requesting the authentication for. Changing that will lead to a
5e65b489a31d oscar: Add a comment explaining the data and meaning of the KDC binary blob
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37766
diff changeset
328 * 'unknown service' error. The client key is then added again (without the
5e65b489a31d oscar: Add a comment explaining the data and meaning of the KDC binary blob
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37766
diff changeset
329 * 'imApp key' string prepended to it) then a XOR-ed version of the password.
5e65b489a31d oscar: Add a comment explaining the data and meaning of the KDC binary blob
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37766
diff changeset
330 * The meaning of the header/footer/in-between bytes is not known but never
5e65b489a31d oscar: Add a comment explaining the data and meaning of the KDC binary blob
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37766
diff changeset
331 * seems to change so there is no need to reverse engineer their meaning at
5e65b489a31d oscar: Add a comment explaining the data and meaning of the KDC binary blob
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37766
diff changeset
332 * this point.
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
333 */
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
334 void send_kerberos_login(OscarData *od, const char *username)
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
335 {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
336 PurpleConnection *gc;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
337 PurpleHttpRequest *req;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
338 gchar *url;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
339 const gchar *password;
37768
05fd9d875913 oscar: Set password_xored as gchar to remove a warning
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37767
diff changeset
340 gchar password_xored[MAXAIMPASSLEN];
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
341 const gchar *client_key;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
342 gchar *imapp_key;
37766
3538db90056f Use GString to build the KDC request body instead of memcpy into a malloc-ed raw array. Makes for much cleaner code.
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37765
diff changeset
343 GString *body;
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
344 guint16 len_be;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
345 guint16 reqid;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
346 const gchar header[] = {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
347 0x05, 0x0C, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
348 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
349 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
350 0x00, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x05,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
351 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
352 0x00, 0x02, 0x00, 0x04, 0x00, 0x00, 0x18, 0x99,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
353 0x00, 0x05, 0x00, 0x04, 0x43, 0x4F, 0x4F, 0x4C,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
354 0x00, 0x0A, 0x00, 0x02, 0x00, 0x01, 0x00, 0x0B,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
355 0x00, 0x04, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
356 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
357 0x55, 0x53, 0x00, 0x02, 0x65, 0x6E, 0x00, 0x04,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
358 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0D,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
359 0x00, 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
360 0x00, 0x05};
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
361 const gchar pre_username[] = {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
362 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x01, 0x8B,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
363 0x01, 0x00, 0x00, 0x00, 0x00};
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
364 const gchar post_username[] = {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
365 0x00, 0x07, 0x69, 0x6D, 0x2F, 0x62, 0x6F, 0x73,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
366 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
367 0x04, 0x00, 0x02};
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
368 const gchar pre_password[] = {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
369 0x40, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
370 0x00, 0x00};
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
371 const gchar post_password[] = {0x00, 0x00, 0x00, 0x1D};
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
372 const gchar footer[] = {
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
373 0x00, 0x21, 0x00, 0x32, 0x00, 0x01, 0x10, 0x03,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
374 0x00, 0x2C, 0x00, 0x07, 0x00, 0x14, 0x00, 0x04,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
375 0x00, 0x00, 0x01, 0x8B, 0x00, 0x16, 0x00, 0x02,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
376 0x00, 0x26, 0x00, 0x17, 0x00, 0x02, 0x00, 0x07,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
377 0x00, 0x18, 0x00, 0x02, 0x00, 0x00, 0x00, 0x19,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
378 0x00, 0x02, 0x00, 0x0D, 0x00, 0x1A, 0x00, 0x02,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
379 0x00, 0x04, 0x00, 0xAB, 0x00, 0x00, 0x00, 0x28,
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
380 0x00, 0x00};
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
381
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
382 gc = od->gc;
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
383
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
384 password = purple_connection_get_password(gc);
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
385 aim_encode_password(password, password_xored);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
386
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
387 client_key = get_client_key(od);
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
388 imapp_key = g_strdup_printf("imApp key=%s", client_key);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
389
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
390 /* Construct the body of the HTTP POST request */
37766
3538db90056f Use GString to build the KDC request body instead of memcpy into a malloc-ed raw array. Makes for much cleaner code.
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37765
diff changeset
391 body = g_string_new(NULL);
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
392 g_string_append_len(body, header, sizeof(header));
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
393 reqid = (guint16) g_random_int();
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
394 g_string_overwrite_len(body, 0xC, (void *)&reqid, sizeof(guint16));
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
395
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
396 len_be = GUINT16_TO_BE(strlen(imapp_key));
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
397 g_string_append_len(body, (void *)&len_be, sizeof(guint16));
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
398 g_string_append(body, imapp_key);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
399
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
400 len_be = GUINT16_TO_BE(strlen(username));
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
401 g_string_append_len(body, pre_username, sizeof(pre_username));
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
402 g_string_append_len(body, (void *)&len_be, sizeof(guint16));
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
403 g_string_append(body, username);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
404 g_string_append_len(body, post_username, sizeof(post_username));
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
405
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
406 len_be = GUINT16_TO_BE(strlen(password) + 0x10);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
407 g_string_append_len(body, (void *)&len_be, sizeof(guint16));
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
408 g_string_append_len(body, pre_password, sizeof(pre_password));
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
409 len_be = GUINT16_TO_BE(strlen(password) + 4);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
410 g_string_append_len(body, (void *)&len_be, sizeof(guint16));
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
411 len_be = GUINT16_TO_BE(strlen(password));
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
412 g_string_append_len(body, (void *)&len_be, sizeof(guint16));
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
413 g_string_append_len(body, password_xored, strlen(password));
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
414 g_string_append_len(body, post_password, sizeof(post_password));
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
415
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
416 len_be = GUINT16_TO_BE(strlen(client_key));
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
417 g_string_append_len(body, (void *)&len_be, sizeof(guint16));
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
418 g_string_append(body, client_key);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
419 g_string_append_len(body, footer, sizeof(footer));
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
420
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
421 g_free(imapp_key);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
422
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
423 url = get_kdc_url(od);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
424 req = purple_http_request_new(url);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
425 purple_http_request_set_method(req, "POST");
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
426 purple_http_request_header_set(req, "Content-Type",
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
427 "application/x-snac");
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
428 purple_http_request_header_set(req, "Accept",
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
429 "application/x-snac");
37766
3538db90056f Use GString to build the KDC request body instead of memcpy into a malloc-ed raw array. Makes for much cleaner code.
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37765
diff changeset
430 purple_http_request_set_contents(req, body->str, body->len);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
431 od->hc = purple_http_request(gc, req, kerberos_login_cb, od);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
432 purple_http_request_unref(req);
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
433
37772
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
434 g_string_free(body, TRUE);
d2294123c226 oscar: Fix coding style, no whitespace before parenthesis of function calls
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents: 37771
diff changeset
435 g_free(url);
37762
0105b155a3d1 oscar: Add kerberos authentication method support for AIM
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
parents:
diff changeset
436 }

mercurial