~vish/ubuntu/maverick/pidgin/bug25979

« back to all changes in this revision

Viewing changes to libpurple/ntlm.c

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-10-09 19:40:26 UTC
  • mfrom: (1.4.1 upstream) (46.1.10 karmic)
  • Revision ID: james.westby@ubuntu.com-20091009194026-wbqqh0bsbz19nx5q
Tags: 1:2.6.2-1ubuntu7
* Don't stick the buddy list window to all desktops as some
  window managers have trouble to properly unstick it (LP: #346840)
  - debian/patches/11_buddy_list_really_show.patch
* Always use default tray icon size on KDE (LP: #209440)
  - debian/patches/62_tray_icon_size_kde.patch
* Use scrollbars in the preferences dialog if the screen height is
  below 700 px instead of 600 px
  - debian/patches/60_1024x600_gtkprefs.c.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
        guint32 type;            /* 0x00000001 */
42
42
        guint32 flags;           /* 0x0000b203 */
43
43
 
44
 
        short   dom_len1;        /* domain string length */
45
 
        short   dom_len2;        /* domain string length */
 
44
        guint16 dom_len1;        /* domain string length */
 
45
        guint16 dom_len2;        /* domain string length */
46
46
        guint32 dom_off;         /* domain string offset */
47
47
 
48
 
        short   host_len1;       /* host string length */
49
 
        short   host_len2;       /* host string length */
 
48
        guint16 host_len1;       /* host string length */
 
49
        guint16 host_len2;       /* host string length */
50
50
        guint32 host_off;        /* host string offset (always 0x00000020) */
51
51
 
52
52
#if 0
59
59
        guint8  protocol[8];     /* 'N', 'T', 'L', 'M', 'S', 'S', 'P', '\0'*/
60
60
        guint32 type;            /* 0x00000002 */
61
61
 
62
 
        short   msg_len1;        /* target name length */
63
 
        short   msg_len2;        /* target name length */
64
 
        guint32 msg_off;         /* target name offset (always 0x00000048) */
 
62
        guint32 zero;
 
63
        guint16 msg_len1;        /* target name length */
 
64
        guint16 msg_len2;        /* target name length */
65
65
 
66
66
        guint32 flags;           /* 0x00008201 */
67
67
 
68
68
        guint8  nonce[8];        /* nonce */
69
 
        guint8 context[8];
 
69
        guint8  context[8];
70
70
};
71
71
 
72
72
struct type3_message {
73
73
        guint8  protocol[8];     /* 'N', 'T', 'L', 'M', 'S', 'S', 'P', '\0'*/
74
74
        guint32 type;            /* 0x00000003 */
75
75
 
76
 
        short   lm_resp_len1;    /* LanManager response length (always 0x18)*/
77
 
        short   lm_resp_len2;    /* LanManager response length (always 0x18)*/
 
76
        guint16 lm_resp_len1;    /* LanManager response length (always 0x18)*/
 
77
        guint16 lm_resp_len2;    /* LanManager response length (always 0x18)*/
78
78
        guint32 lm_resp_off;     /* LanManager response offset */
79
79
 
80
 
        short   nt_resp_len1;    /* NT response length (always 0x18) */
81
 
        short   nt_resp_len2;    /* NT response length (always 0x18) */
 
80
        guint16 nt_resp_len1;    /* NT response length (always 0x18) */
 
81
        guint16 nt_resp_len2;    /* NT response length (always 0x18) */
82
82
        guint32 nt_resp_off;     /* NT response offset */
83
83
 
84
 
        short   dom_len1;        /* domain string length */
85
 
        short   dom_len2;        /* domain string length */
 
84
        guint16 dom_len1;        /* domain string length */
 
85
        guint16 dom_len2;        /* domain string length */
86
86
        guint32 dom_off;         /* domain string offset (always 0x00000040) */
87
87
 
88
 
        short   user_len1;       /* username string length */
89
 
        short   user_len2;       /* username string length */
 
88
        guint16 user_len1;       /* username string length */
 
89
        guint16 user_len2;       /* username string length */
90
90
        guint32 user_off;        /* username string offset */
91
91
 
92
 
        short   host_len1;       /* host string length */
93
 
        short   host_len2;       /* host string length */
 
92
        guint16 host_len1;       /* host string length */
 
93
        guint16 host_len2;       /* host string length */
94
94
        guint32 host_off;        /* host string offset */
95
95
 
96
 
        short   sess_len1;
97
 
        short   sess_len2;
 
96
        guint16 sess_len1;
 
97
        guint16 sess_len2;
98
98
        guint32 sess_off;         /* message length */
99
99
 
100
100
        guint32 flags;            /* 0x00008201 */
101
101
        /* guint32 flags2; */     /* unknown, used in windows messenger */
102
 
        /* guint32  flags3; */
 
102
        /* guint32 flags3; */
103
103
 
104
104
#if 0
105
105
        guint8  dom[*];          /* domain string (unicode UTF-16LE) */
110
110
#endif
111
111
};
112
112
 
113
 
/* TODO: Will this work on both little-endian and big-endian machines? */
114
113
gchar *
115
114
purple_ntlm_gen_type1(const gchar *hostname, const gchar *domain)
116
115
{
132
131
        tmsg->protocol[5] = 'S';
133
132
        tmsg->protocol[6] = 'P';
134
133
        tmsg->protocol[7] = '\0';
135
 
        tmsg->type      = 0x00000001;
136
 
        tmsg->flags     = 0x0000b203;
137
 
        tmsg->dom_len1  = tmsg->dom_len2 = domainlen;
138
 
        tmsg->dom_off   = sizeof(struct type1_message) + hostnamelen;
139
 
        tmsg->host_len1 = tmsg->host_len2 = hostnamelen;
140
 
        tmsg->host_off  = sizeof(struct type1_message);
 
134
        tmsg->type      = GUINT32_TO_LE(0x00000001);
 
135
        tmsg->flags     = GUINT32_TO_LE(0x0000b203);
 
136
        tmsg->dom_len1  = tmsg->dom_len2 = GUINT16_TO_LE(domainlen);
 
137
        tmsg->dom_off   = GUINT32_TO_LE(sizeof(struct type1_message) + hostnamelen);
 
138
        tmsg->host_len1 = tmsg->host_len2 = GUINT16_TO_LE(hostnamelen);
 
139
        tmsg->host_off  = GUINT32_TO_LE(sizeof(struct type1_message));
141
140
        memcpy(msg + tmsg->host_off, hostname, hostnamelen);
142
141
        memcpy(msg + tmsg->dom_off, domain, domainlen);
143
142
 
157
156
        tmsg = (struct type2_message*)purple_base64_decode(type2, &retlen);
158
157
        memcpy(nonce, tmsg->nonce, 8);
159
158
        if (flags != NULL)
160
 
                *flags = tmsg->flags;
 
159
                *flags = GUINT16_FROM_LE(tmsg->flags);
161
160
        g_free(tmsg);
162
161
 
163
162
        return nonce;
268
267
        tmsg->protocol[4] = 'S';
269
268
        tmsg->protocol[5] = 'S';
270
269
        tmsg->protocol[6] = 'P';
271
 
        tmsg->type = 0x00000003;
272
 
        tmsg->lm_resp_len1 = tmsg->lm_resp_len2 = 0x18;
273
 
        tmsg->lm_resp_off = sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen;
274
 
        tmsg->nt_resp_len1 = tmsg->nt_resp_len2 = 0x18;
275
 
        tmsg->nt_resp_off = sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen + 0x18;
276
 
 
277
 
        tmsg->dom_len1 = tmsg->dom_len2 = domainlen;
278
 
        tmsg->dom_off = sizeof(struct type3_message);
279
 
 
280
 
        tmsg->user_len1 = tmsg->user_len2 = usernamelen;
281
 
        tmsg->user_off = sizeof(struct type3_message) + domainlen;
282
 
 
283
 
        tmsg->host_len1 = tmsg->host_len2 = hostnamelen;
284
 
        tmsg->host_off = sizeof(struct type3_message) + domainlen + usernamelen;
 
270
        tmsg->type = GUINT32_TO_LE(0x00000003);
 
271
        tmsg->lm_resp_len1 = tmsg->lm_resp_len2 = GUINT16_TO_LE(0x18);
 
272
        tmsg->lm_resp_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen);
 
273
        tmsg->nt_resp_len1 = tmsg->nt_resp_len2 = GUINT16_TO_LE(0x18);
 
274
        tmsg->nt_resp_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen + 0x18);
 
275
 
 
276
        tmsg->dom_len1 = tmsg->dom_len2 = GUINT16_TO_LE(domainlen);
 
277
        tmsg->dom_off = GUINT32_TO_LE(sizeof(struct type3_message));
 
278
 
 
279
        tmsg->user_len1 = tmsg->user_len2 = GUINT16_TO_LE(usernamelen);
 
280
        tmsg->user_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen);
 
281
 
 
282
        tmsg->host_len1 = tmsg->host_len2 = GUINT16_TO_LE(hostnamelen);
 
283
        tmsg->host_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen + usernamelen);
285
284
 
286
285
        if(flags) {
287
 
                tmsg->sess_off = sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen + 0x18 + 0x18;
288
 
                tmsg->sess_len1 = tmsg->sess_len2 = 0x0010;
 
286
                tmsg->sess_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen + 0x18 + 0x18);
 
287
                tmsg->sess_len1 = tmsg->sess_len2 = GUINT16_TO_LE(0x0010);
289
288
        }
290
289
 
291
 
        tmsg->flags = 0x00008201;
 
290
        tmsg->flags = GUINT32_TO_LE(0x00008201);
292
291
 
293
292
        tmp = (char *)tmsg + sizeof(struct type3_message);
294
293
 
361
360
 
362
361
        /* LCS Stuff */
363
362
        if (flags) {
364
 
                tmsg->flags = 0x409082d4;
 
363
                tmsg->flags = GUINT32_TO_LE(0x409082d4);
365
364
                gensesskey(sesskey, NULL);
366
365
                memcpy(tmp, sesskey, 0x10);
367
366
        }