annotate libpurple/ntlm.c @ 32374:ce37181749de

disapproval of revision '88118487bea2cf5120dec21de3377fada185180f'
author Mark Doliner <mark@kingant.net>
date Mon, 22 Aug 2011 06:07:08 +0000
parents a13744df700c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file ntlm.c
20074
6bf32c9e15a7 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents: 19990
diff changeset
3 */
6bf32c9e15a7 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents: 19990
diff changeset
4
6bf32c9e15a7 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents: 19990
diff changeset
5 /* purple
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * Copyright (C) 2005 Thomas Butter <butter@uni-mannheim.de>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * hashing done according to description of NTLM on
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * http://www.innovation.ch/java/ntlm.html
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18202
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26
18202
7df46d8bf114 Move the define in internal.h instead.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15823
diff changeset
27 #include "internal.h"
7df46d8bf114 Move the define in internal.h instead.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15823
diff changeset
28
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "util.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "ntlm.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "cipher.h"
22447
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
32 #include "debug.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include <string.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #define NTLM_NEGOTIATE_NTLM2_KEY 0x00080000
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 struct type1_message {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 guint8 protocol[8]; /* 'N', 'T', 'L', 'M', 'S', 'S', 'P', '\0' */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 guint32 type; /* 0x00000001 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 guint32 flags; /* 0x0000b203 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41
26322
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
42 guint16 dom_len1; /* domain string length */
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
43 guint16 dom_len2; /* domain string length */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 guint32 dom_off; /* domain string offset */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
26322
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
46 guint16 host_len1; /* host string length */
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
47 guint16 host_len2; /* host string length */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 guint32 host_off; /* host string offset (always 0x00000020) */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 #if 0
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 guint8 host[*]; /* host string (ASCII) */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 guint8 dom[*]; /* domain string (ASCII) */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 struct type2_message {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 guint8 protocol[8]; /* 'N', 'T', 'L', 'M', 'S', 'S', 'P', '\0'*/
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 guint32 type; /* 0x00000002 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59
26322
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
60 guint32 zero;
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
61 guint16 msg_len1; /* target name length */
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
62 guint16 msg_len2; /* target name length */
26304
511509fa0e02 disapproval of revision '77d562b624d9b55c9ff165d5797b72ba553e3256'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26303
diff changeset
63
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 guint32 flags; /* 0x00008201 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 guint8 nonce[8]; /* nonce */
26322
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
67 guint8 context[8];
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 struct type3_message {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 guint8 protocol[8]; /* 'N', 'T', 'L', 'M', 'S', 'S', 'P', '\0'*/
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 guint32 type; /* 0x00000003 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73
26322
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
74 guint16 lm_resp_len1; /* LanManager response length (always 0x18)*/
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
75 guint16 lm_resp_len2; /* LanManager response length (always 0x18)*/
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 guint32 lm_resp_off; /* LanManager response offset */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77
26322
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
78 guint16 nt_resp_len1; /* NT response length (always 0x18) */
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
79 guint16 nt_resp_len2; /* NT response length (always 0x18) */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 guint32 nt_resp_off; /* NT response offset */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81
26322
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
82 guint16 dom_len1; /* domain string length */
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
83 guint16 dom_len2; /* domain string length */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 guint32 dom_off; /* domain string offset (always 0x00000040) */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85
26322
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
86 guint16 user_len1; /* username string length */
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
87 guint16 user_len2; /* username string length */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 guint32 user_off; /* username string offset */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89
26322
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
90 guint16 host_len1; /* host string length */
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
91 guint16 host_len2; /* host string length */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 guint32 host_off; /* host string offset */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93
26322
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
94 guint16 sess_len1;
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
95 guint16 sess_len2;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 guint32 sess_off; /* message length */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 guint32 flags; /* 0x00008201 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 /* guint32 flags2; */ /* unknown, used in windows messenger */
26322
ed44004c333c Make these type-sizes more explicit. Also, the field names for the type2
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26304
diff changeset
100 /* guint32 flags3; */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 #if 0
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 guint8 dom[*]; /* domain string (unicode UTF-16LE) */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 guint8 user[*]; /* username string (unicode UTF-16LE) */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 guint8 host[*]; /* host string (unicode UTF-16LE) */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 guint8 lm_resp[*]; /* LanManager response */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 guint8 nt_resp[*]; /* NT response */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 gchar *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
112 purple_ntlm_gen_type1(const gchar *hostname, const gchar *domain)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 {
32258
a13744df700c Fix NTLM endianness issue.
jond578@gmail.com
parents: 31053
diff changeset
114 int hostnamelen,host_off;
a13744df700c Fix NTLM endianness issue.
jond578@gmail.com
parents: 31053
diff changeset
115 int domainlen,dom_off;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 unsigned char *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 struct type1_message *tmsg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 gchar *tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 hostnamelen = strlen(hostname);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 domainlen = strlen(domain);
32258
a13744df700c Fix NTLM endianness issue.
jond578@gmail.com
parents: 31053
diff changeset
122 host_off = sizeof(struct type1_message);
a13744df700c Fix NTLM endianness issue.
jond578@gmail.com
parents: 31053
diff changeset
123 dom_off = sizeof(struct type1_message) + hostnamelen;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 msg = g_malloc0(sizeof(struct type1_message) + hostnamelen + domainlen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 tmsg = (struct type1_message*)msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 tmsg->protocol[0] = 'N';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 tmsg->protocol[1] = 'T';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 tmsg->protocol[2] = 'L';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 tmsg->protocol[3] = 'M';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 tmsg->protocol[4] = 'S';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 tmsg->protocol[5] = 'S';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 tmsg->protocol[6] = 'P';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 tmsg->protocol[7] = '\0';
26323
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
134 tmsg->type = GUINT32_TO_LE(0x00000001);
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
135 tmsg->flags = GUINT32_TO_LE(0x0000b203);
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
136 tmsg->dom_len1 = tmsg->dom_len2 = GUINT16_TO_LE(domainlen);
32258
a13744df700c Fix NTLM endianness issue.
jond578@gmail.com
parents: 31053
diff changeset
137 tmsg->dom_off = GUINT32_TO_LE(dom_off);
26323
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
138 tmsg->host_len1 = tmsg->host_len2 = GUINT16_TO_LE(hostnamelen);
32258
a13744df700c Fix NTLM endianness issue.
jond578@gmail.com
parents: 31053
diff changeset
139 tmsg->host_off = GUINT32_TO_LE(host_off);
a13744df700c Fix NTLM endianness issue.
jond578@gmail.com
parents: 31053
diff changeset
140 memcpy(msg + host_off, hostname, hostnamelen);
a13744df700c Fix NTLM endianness issue.
jond578@gmail.com
parents: 31053
diff changeset
141 memcpy(msg + dom_off, domain, domainlen);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
143 tmp = purple_base64_encode(msg, sizeof(struct type1_message) + hostnamelen + domainlen);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 return tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 guint8 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
150 purple_ntlm_parse_type2(const gchar *type2, guint32 *flags)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 gsize retlen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 struct type2_message *tmsg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 static guint8 nonce[8];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
156 tmsg = (struct type2_message*)purple_base64_decode(type2, &retlen);
31053
943fce8ef142 Fix for CVE-2010-3711. Properly validate the return value from
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29028
diff changeset
157 if (tmsg != NULL && retlen >= (sizeof(struct type2_message) - 1)) {
943fce8ef142 Fix for CVE-2010-3711. Properly validate the return value from
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29028
diff changeset
158 memcpy(nonce, tmsg->nonce, 8);
943fce8ef142 Fix for CVE-2010-3711. Properly validate the return value from
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29028
diff changeset
159 if (flags != NULL)
943fce8ef142 Fix for CVE-2010-3711. Properly validate the return value from
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29028
diff changeset
160 *flags = GUINT16_FROM_LE(tmsg->flags);
943fce8ef142 Fix for CVE-2010-3711. Properly validate the return value from
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29028
diff changeset
161 } else {
943fce8ef142 Fix for CVE-2010-3711. Properly validate the return value from
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29028
diff changeset
162 purple_debug_error("ntlm", "Unable to parse type2 message - returning empty nonce.\n");
943fce8ef142 Fix for CVE-2010-3711. Properly validate the return value from
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29028
diff changeset
163 memset(nonce, 0, 8);
943fce8ef142 Fix for CVE-2010-3711. Properly validate the return value from
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29028
diff changeset
164 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 g_free(tmsg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 return nonce;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 * Create a 64bit DES key by taking a 56bit key and adding
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 * a parity bit after every 7th bit.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 setup_des_key(const guint8 key_56[], guint8 *key)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 key[0] = key_56[0];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 key[1] = ((key_56[0] << 7) & 0xFF) | (key_56[1] >> 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 key[2] = ((key_56[1] << 6) & 0xFF) | (key_56[2] >> 2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 key[3] = ((key_56[2] << 5) & 0xFF) | (key_56[3] >> 3);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 key[4] = ((key_56[3] << 4) & 0xFF) | (key_56[4] >> 4);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 key[5] = ((key_56[4] << 3) & 0xFF) | (key_56[5] >> 5);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 key[6] = ((key_56[5] << 2) & 0xFF) | (key_56[6] >> 6);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 key[7] = (key_56[6] << 1) & 0xFF;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 /*
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
188 * helper function for purple cipher.c
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 des_ecb_encrypt(const guint8 *plaintext, guint8 *result, const guint8 *key)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
193 PurpleCipher *cipher;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
194 PurpleCipherContext *context;
21610
0e4549c09e64 purple_cipher_context_encrypt() wants a pointer to a size_t, not a gsize
Evan Schoenberg <evan.s@dreskin.net>
parents: 20074
diff changeset
195 size_t outlen;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
197 cipher = purple_ciphers_find_cipher("des");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
198 context = purple_cipher_context_new(cipher, NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
199 purple_cipher_context_set_key(context, key);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
200 purple_cipher_context_encrypt(context, plaintext, 8, result, &outlen);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
201 purple_cipher_context_destroy(context);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 * takes a 21 byte array and treats it as 3 56-bit DES keys. The
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 * 8 byte plaintext is encrypted with each key and the resulting 24
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 * bytes are stored in the results array.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 calc_resp(guint8 *keys, const guint8 *plaintext, unsigned char *results)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 guint8 key[8];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 setup_des_key(keys, key);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 des_ecb_encrypt(plaintext, results, key);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 setup_des_key(keys + 7, key);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 des_ecb_encrypt(plaintext, results + 8, key);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 setup_des_key(keys + 14, key);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 des_ecb_encrypt(plaintext, results + 16, key);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 gensesskey(char *buffer, const char *oldkey)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 int i = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 if(oldkey == NULL) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 for(i=0; i<16; i++) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 buffer[i] = (char)(rand() & 0xff);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 memcpy(buffer, oldkey, 16);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 gchar *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
237 purple_ntlm_gen_type3(const gchar *username, const gchar *passw, const gchar *hostname, const gchar *domain, const guint8 *nonce, guint32 *flags)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 char lm_pw[14];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 unsigned char lm_hpw[21];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 char sesskey[16];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 guint8 key[8];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 int domainlen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 int usernamelen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 int hostnamelen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 int msglen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 struct type3_message *tmsg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 int passwlen, lennt;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 unsigned char lm_resp[24], nt_resp[24];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 unsigned char magic[] = { 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 unsigned char nt_hpw[21];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 char nt_pw[128];
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
253 PurpleCipher *cipher;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
254 PurpleCipherContext *context;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 char *tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 int idx;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 gchar *ucs2le;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 domainlen = strlen(domain) * 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 usernamelen = strlen(username) * 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 hostnamelen = strlen(hostname) * 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 msglen = sizeof(struct type3_message) + domainlen +
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 usernamelen + hostnamelen + 0x18 + 0x18 + ((flags) ? 0x10 : 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 tmsg = g_malloc0(msglen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 passwlen = strlen(passw);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 /* type3 message initialization */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 tmsg->protocol[0] = 'N';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 tmsg->protocol[1] = 'T';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 tmsg->protocol[2] = 'L';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 tmsg->protocol[3] = 'M';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 tmsg->protocol[4] = 'S';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 tmsg->protocol[5] = 'S';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 tmsg->protocol[6] = 'P';
26323
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
275 tmsg->type = GUINT32_TO_LE(0x00000003);
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
276 tmsg->lm_resp_len1 = tmsg->lm_resp_len2 = GUINT16_TO_LE(0x18);
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
277 tmsg->lm_resp_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen);
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
278 tmsg->nt_resp_len1 = tmsg->nt_resp_len2 = GUINT16_TO_LE(0x18);
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
279 tmsg->nt_resp_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen + 0x18);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280
26323
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
281 tmsg->dom_len1 = tmsg->dom_len2 = GUINT16_TO_LE(domainlen);
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
282 tmsg->dom_off = GUINT32_TO_LE(sizeof(struct type3_message));
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283
26323
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
284 tmsg->user_len1 = tmsg->user_len2 = GUINT16_TO_LE(usernamelen);
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
285 tmsg->user_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286
26323
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
287 tmsg->host_len1 = tmsg->host_len2 = GUINT16_TO_LE(hostnamelen);
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
288 tmsg->host_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen + usernamelen);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 if(flags) {
26323
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
291 tmsg->sess_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen + 0x18 + 0x18);
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
292 tmsg->sess_len1 = tmsg->sess_len2 = GUINT16_TO_LE(0x0010);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294
26323
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
295 tmsg->flags = GUINT32_TO_LE(0x00008201);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 tmp = (char *)tmsg + sizeof(struct type3_message);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298
22447
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
299 ucs2le = g_convert(domain, -1, "UTF-16LE", "UTF-8", NULL, NULL, NULL);
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
300 if (ucs2le != NULL) {
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
301 memcpy(tmp, ucs2le, domainlen);
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
302 g_free(ucs2le);
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
303 tmp += domainlen;
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
304 } else {
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
305 purple_debug_info("ntlm", "Unable to encode domain in UTF-16LE.\n");
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
306 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307
22447
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
308 ucs2le = g_convert(username, -1, "UTF-16LE", "UTF-8", NULL, NULL, NULL);
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
309 if (ucs2le != NULL) {
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
310 memcpy(tmp, ucs2le, usernamelen);
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
311 g_free(ucs2le);
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
312 tmp += usernamelen;
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
313 } else {
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
314 purple_debug_info("ntlm", "Unable to encode username in UTF-16LE.\n");
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
315 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316
22447
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
317 ucs2le = g_convert(hostname, -1, "UTF-16LE", "UTF-8", NULL, NULL, NULL);
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
318 if (ucs2le != NULL) {
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
319 memcpy(tmp, ucs2le, hostnamelen);
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
320 g_free(ucs2le);
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
321 tmp += hostnamelen;
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
322 } else {
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
323 purple_debug_info("ntlm", "Unable to encode hostname in UTF-16LE.\n");
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
324 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 /* LM */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 if (passwlen > 14)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 passwlen = 14;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 for (idx = 0; idx < passwlen; idx++)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 lm_pw[idx] = g_ascii_toupper(passw[idx]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 for (; idx < 14; idx++)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 lm_pw[idx] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 setup_des_key((unsigned char*)lm_pw, key);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 des_ecb_encrypt(magic, lm_hpw, key);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 setup_des_key((unsigned char*)(lm_pw + 7), key);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 des_ecb_encrypt(magic, lm_hpw + 8, key);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 memset(lm_hpw + 16, 0, 5);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 calc_resp(lm_hpw, nonce, lm_resp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 memcpy(tmp, lm_resp, 0x18);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 tmp += 0x18;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 /* NTLM */
22447
9b154f484d64 Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21610
diff changeset
347 /* Convert the password to UTF-16LE */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 lennt = strlen(passw);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 for (idx = 0; idx < lennt; idx++)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 nt_pw[2 * idx] = passw[idx];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 nt_pw[2 * idx + 1] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
355 cipher = purple_ciphers_find_cipher("md4");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
356 context = purple_cipher_context_new(cipher, NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
357 purple_cipher_context_append(context, (guint8 *)nt_pw, 2 * lennt);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
358 purple_cipher_context_digest(context, 21, nt_hpw, NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
359 purple_cipher_context_destroy(context);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 memset(nt_hpw + 16, 0, 5);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 calc_resp(nt_hpw, nonce, nt_resp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 memcpy(tmp, nt_resp, 0x18);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 tmp += 0x18;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 /* LCS Stuff */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 if (flags) {
26323
bee0e8ddfebc I think I'm just going to apply this patch. I don't really see how it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26322
diff changeset
368 tmsg->flags = GUINT32_TO_LE(0x409082d4);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 gensesskey(sesskey, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 memcpy(tmp, sesskey, 0x10);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 /*tmsg->flags2 = 0x0a280105;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 tmsg->flags3 = 0x0f000000;*/
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
376 tmp = purple_base64_encode((guchar *)tmsg, msglen);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 g_free(tmsg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 return tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 }