6 * Copyright (C) 2010 pier11 <pier11@operamail.com>
7 * Copyright (C) 2008 Novell, Inc.
9 * Implemented with reference to the follow documentation:
10 * - http://davenport.sourceforge.net/ntlm.html
11 * - MS-NLMP: http://msdn.microsoft.com/en-us/library/cc207842.aspx
12 * - MS-SIP : http://msdn.microsoft.com/en-us/library/cc246115.aspx
14 * Build and run with (adjust as needed to your build platform!)
16 * $ gcc -I /usr/include/libpurple \
17 * -I /usr/include/dbus-1.0 -I /usr/lib/dbus-1.0/include \
18 * -I /usr/include/glib-2.0 -I /usr/lib/glib-2.0/include \
19 * -o tests tests.c sipe-sign.c sipmsg.c sip-sec.c uuid.c -lpurple
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 2 of the License, or
25 * (at your option) any later version.
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40 #include "sipe-sign.h"
41 #include "sip-sec-ntlm.c"
44 #include "dbus-server.h"
49 static int successes
= 0;
50 static int failures
= 0;
52 static void assert_equal(const char * expected
, const guchar
* got
, int len
, gboolean stringify
)
54 const gchar
* res
= (gchar
*) got
;
59 for (i
= 0, j
= 0; i
< len
; i
++, j
+=2) {
60 g_sprintf(&to_str
[j
], "%02X", (got
[i
]&0xff));
66 printf("expected: %s\n", expected
);
67 printf("received: %s\n", res
);
69 if (g_ascii_strncasecmp(expected
, res
, len
) == 0) {
80 printf ("Starting Tests\n");
82 // Initialization that Pidgin would normally do
86 purple_signals_init();
92 purple_ciphers_init();
93 purple_debug_set_enabled(TRUE
);
95 /* These tests are from the MS-SIPE document */
97 const char * password
= "Password";
98 const char * user
= "User";
99 const char * domain
= "Domain";
100 const guchar client_challenge
[] = {0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa};
101 /* server challenge */
102 const guchar nonce
[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
104 const guchar exported_session_key
[] = {0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55};
105 const guchar text
[] = {0x50, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x65, 0x00, 0x78, 0x00, 0x74, 0x00}; //P·l·a·i·n·t·e·x·t·
108 ////// internal Cyphers tests ///////
109 printf ("\nTesting MD4()\n");
111 MD4 ((const unsigned char *)"message digest", 14, md4
);
112 assert_equal("D9130A8164549FE818874806E1C7014B", md4
, 16, TRUE
);
114 printf ("\nTesting MD5()\n");
116 MD5 ((const unsigned char *)"message digest", 14, md5
);
117 assert_equal("F96B697D7CB7938D525A2F31AAF161D0", md5
, 16, TRUE
);
119 printf ("\nTesting HMAC_MD5()\n");
120 guchar hmac_md5
[16];
121 HMAC_MD5 ((const unsigned char *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", 16, (const unsigned char *)"Hi There", 8, hmac_md5
);
122 assert_equal("9294727A3638BB1C13F48EF8158BFC9D", hmac_md5
, 16, TRUE
);
125 ////// NTLMv1 (without Extended Session Security) ///////
128 | NTLMSSP_NEGOTIATE_KEY_EXCH
129 | NTLMSSP_NEGOTIATE_56
130 | NTLMSSP_NEGOTIATE_128
131 | NTLMSSP_NEGOTIATE_VERSION
132 | NTLMSSP_TARGET_TYPE_SERVER
133 | NTLMSSP_NEGOTIATE_ALWAYS_SIGN
134 | NTLMSSP_NEGOTIATE_NTLM
135 | NTLMSSP_NEGOTIATE_SEAL
136 | NTLMSSP_NEGOTIATE_SIGN
137 | NTLMSSP_NEGOTIATE_OEM
138 | NTLMSSP_NEGOTIATE_UNICODE
;
140 printf ("\n\nTesting Negotiation Flags\n");
141 assert_equal("338202E2", (guchar
*)(&flags
), 4, TRUE
);
143 printf ("\n\nTesting LMOWFv1()\n");
144 guchar response_key_lm
[16];
145 LMOWFv1 (password
, user
, domain
, response_key_lm
);
146 assert_equal("E52CAC67419A9A224A3B108F3FA6CB6D", response_key_lm
, 16, TRUE
);
148 printf ("\n\nTesting NTOWFv1()\n");
149 guchar response_key_nt
[16];
150 NTOWFv1 (password
, user
, domain
, response_key_nt
);
151 assert_equal("A4F49C406510BDCAB6824EE7C30FD852", response_key_nt
, 16, TRUE
);
153 printf ("\n\nTesting LM Response Generation\n");
154 printf ("Testing NT Response Generation\n");
155 printf ("Testing Session Base Key\n");
156 guchar nt_challenge_response
[24];
157 guchar lm_challenge_response
[24];
158 guchar session_base_key
[16];
160 compute_response(flags
,
166 NULL
, /* target_info */
167 0, /* target_info_len */
168 lm_challenge_response
, /* out */
169 nt_challenge_response
, /* out */
170 session_base_key
); /* out */
172 assert_equal("98DEF7B87F88AA5DAFE2DF779688A172DEF11C7D5CCDEF13", lm_challenge_response
, 24, TRUE
);
173 assert_equal("67C43011F30298A2AD35ECE64F16331C44BDBED927841F94", nt_challenge_response
, 24, TRUE
);
174 assert_equal("D87262B0CDE4B1CB7499BECCCDF10784", session_base_key
, 16, TRUE
);
176 printf ("\n\nTesting Key Exchange Key\n");
177 guchar key_exchange_key
[16];
178 KXKEY(flags
, session_base_key
, lm_challenge_response
, nonce
, key_exchange_key
);
179 assert_equal("D87262B0CDE4B1CB7499BECCCDF10784", key_exchange_key
, 16, TRUE
);
181 printf ("\n\nTesting Encrypted Session Key Generation\n");
182 guchar encrypted_random_session_key
[16];
183 RC4K (key_exchange_key
, 16, exported_session_key
, 16, encrypted_random_session_key
);
184 assert_equal("518822B1B3F350C8958682ECBB3E3CB7", encrypted_random_session_key
, 16, TRUE
);
186 printf ("\n\nTesting CRC32\n");
187 gint32 crc
= CRC32((char*)text
, 18);
188 assert_equal("7D84AA93", (guchar
*)&crc
, 4, TRUE
);
190 printf ("\n\nTesting Encryption\n");
191 guchar client_seal_key
[16];
192 //SEALKEY (flags, exported_session_key, TRUE, client_seal_key);
193 guchar buff
[18 + 12];
194 memcpy(buff
, text
, 18);
195 guchar text_enc
[18 + 12];
196 guint32
*ptr
= (guint32
*)(buff
+ 18);
197 ptr
[0] = 0; // random pad
200 RC4K (exported_session_key
, 16, buff
, 18 + 12, text_enc
);
201 //The point is to not reinitialize rc4 cypher
203 assert_equal("56FE04D861F9319AF0D7238A2E3B4D457FB8" "45C844E5" "09DCD1DF" "2E459D36", text_enc
, 18 + 12, TRUE
);
205 printf ("\n\nTesting MAC\n");
206 // won't work in the case with sealing because RC4 is re-initialized inside.
207 //gchar *mac = MAC (flags, (gchar*)text, 18, (guchar*)exported_session_key, 16, (guchar*)exported_session_key,16, 0x00000000, 0);
208 ptr
= (guint32
*)(text_enc
+ 18);
210 mac2
[0] = 1; // version
213 mac2
[3] = ptr
[2] ^ ((guint32
)0); // ^ seq
214 assert_equal("0100000045C844E509DCD1DF2E459D36", (guchar
*)mac2
, 16, TRUE
);
217 ////// EXTENDED_SESSIONSECURITY ///////
220 | NTLMSSP_NEGOTIATE_56
221 | NTLMSSP_NEGOTIATE_VERSION
222 | NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY
223 | NTLMSSP_TARGET_TYPE_SERVER
224 | NTLMSSP_NEGOTIATE_ALWAYS_SIGN
225 | NTLMSSP_NEGOTIATE_NTLM
226 | NTLMSSP_NEGOTIATE_SEAL
227 | NTLMSSP_NEGOTIATE_SIGN
228 | NTLMSSP_NEGOTIATE_OEM
229 | NTLMSSP_NEGOTIATE_UNICODE
;
231 printf ("\n\n(Extended session security) Testing Negotiation Flags\n");
232 assert_equal("33820A82", (guchar
*)(&flags
), 4, TRUE
);
234 /* NTOWFv1() is not different from the above test for the same */
236 printf ("\n\n(Extended session security) Testing LM Response\n");
237 printf ("(Extended session security) Testing NT Response\n");
238 printf ("(Extended session security) Testing Session Base Key\n");
239 compute_response(flags
,
245 NULL
, /* target_info */
246 0, /* target_info_len */
247 lm_challenge_response
, /* out */
248 nt_challenge_response
, /* out */
249 session_base_key
); /* out */
251 assert_equal("AAAAAAAAAAAAAAAA00000000000000000000000000000000", lm_challenge_response
, 24, TRUE
);
252 assert_equal("7537F803AE367128CA458204BDE7CAF81E97ED2683267232", nt_challenge_response
, 24, TRUE
);
253 assert_equal("D87262B0CDE4B1CB7499BECCCDF10784", session_base_key
, 16, TRUE
);
255 printf ("\n\n(Extended session seurity) Testing Key Exchange Key\n");
256 KXKEY(flags
, session_base_key
, lm_challenge_response
, nonce
, key_exchange_key
);
257 assert_equal("EB93429A8BD952F8B89C55B87F475EDC", key_exchange_key
, 16, TRUE
);
259 printf ("\n\n(Extended session security) SIGNKEY\n");
260 guchar client_sign_key
[16];
261 SIGNKEY (key_exchange_key
, TRUE
, client_sign_key
);
262 assert_equal("60E799BE5C72FC92922AE8EBE961FB8D", client_sign_key
, 16, TRUE
);
264 printf ("\n\n(Extended session security) SEALKEY\n");
265 SEALKEY (flags
, key_exchange_key
, TRUE
, client_seal_key
);
266 assert_equal("04DD7F014D8504D265A25CC86A3A7C06", client_seal_key
, 16, TRUE
);
268 printf ("\n\n(Extended session security) Testing Encryption\n");
269 RC4K (client_seal_key
, 16, text
, 18, text_enc
);
270 assert_equal("A02372F6530273F3AA1EB90190CE5200C99D", text_enc
, 18, TRUE
);
272 printf ("\n\n(Extended session security) Testing MAC\n");
273 gchar
*mac
= MAC (flags
, (gchar
*)text
,18, client_sign_key
,16, client_seal_key
,16, 0, 0);
274 assert_equal("01000000FF2AEB52F681793A00000000", (guchar
*)mac
, 32, FALSE
);
278 ////// NTLMv2 ///////
281 | NTLMSSP_NEGOTIATE_KEY_EXCH
282 | NTLMSSP_NEGOTIATE_56
283 | NTLMSSP_NEGOTIATE_128
284 | NTLMSSP_NEGOTIATE_VERSION
285 | NTLMSSP_NEGOTIATE_TARGET_INFO
286 | NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY
287 | NTLMSSP_TARGET_TYPE_SERVER
288 | NTLMSSP_NEGOTIATE_ALWAYS_SIGN
289 | NTLMSSP_NEGOTIATE_NTLM
290 | NTLMSSP_NEGOTIATE_SEAL
291 | NTLMSSP_NEGOTIATE_SIGN
292 | NTLMSSP_NEGOTIATE_OEM
293 | NTLMSSP_NEGOTIATE_UNICODE
;
295 printf ("\n\nTesting (NTLMv2) Negotiation Flags\n");
296 assert_equal("33828AE2", (guchar
*)(&flags
), 4, TRUE
);
298 printf ("\n\nTesting NTOWFv2()\n");
299 NTOWFv2 (password
, user
, domain
, response_key_nt
);
300 NTOWFv2 (password
, user
, domain
, response_key_lm
);
301 assert_equal("0C868A403BFD7A93A3001EF22EF02E3F", response_key_nt
, 16, TRUE
);
304 printf ("\n\nTesting (NTLMv2) LM Response Generation\n");
305 printf ("Testing (NTLMv2) NT Response Generation and Session Base Key\n");
308 4e544c4d53535000020000000c000c003800000033828ae20123456789abcdef00000000000000002400240044000000060070170000000f53006500720076006500720002000c0044006f006d00610069006e0001000c0053006500720076006500720000000000
310 NTLMSSP_NEGOTIATE_UNICODE
311 NTLMSSP_NEGOTIATE_OEM
312 NTLMSSP_NEGOTIATE_SIGN
313 NTLMSSP_NEGOTIATE_SEAL
314 NTLMSSP_NEGOTIATE_NTLM
315 NTLMSSP_NEGOTIATE_ALWAYS_SIGN
316 NTLMSSP_TARGET_TYPE_SERVER
317 NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY
318 NTLMSSP_NEGOTIATE_TARGET_INFO
319 NTLMSSP_NEGOTIATE_VERSION
320 NTLMSSP_NEGOTIATE_128
321 NTLMSSP_NEGOTIATE_KEY_EXCH
324 target_name.maxlen: 12
325 target_name.offset: 56
327 target_info.maxlen: 36
328 target_info.offset: 68
329 product: 6.0.6000 (Windows Vista, Windows Server 2008, Windows 7 or Windows Server 2008 R2)
330 ntlm_revision_current: 0x0F (NTLMSSP_REVISION_W2K3)
332 MsvAvNbDomainName: Domain
333 MsvAvNbComputerName: Server
336 530065007200760065007200
338 02000c0044006f006d00610069006e0001000c0053006500720076006500720000000000
341 4e544c4d5353500003000000180018006c00000054005400840000000c000c00480000000800080054000000100010005c00000010001000d8000000358288e20501280a0000000f44006f006d00610069006e00550073006500720043004f004d005000550054004500520086c35097ac9cec102554764a57cccc19aaaaaaaaaaaaaaaa68cd0ab851e51c96aabc927bebef6a1c01010000000000000000000000000000aaaaaaaaaaaaaaaa0000000002000c0044006f006d00610069006e0001000c005300650072007600650072000000000000000000c5dad2544fc9799094ce1ce90bc9d03e
345 const guint64 time_val
= 0;
346 const gchar target_info
[] = {
347 0x02, 0x00, 0x0C, 0x00, //NetBIOS Domain name, 4 bytes
348 0x44, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x69, 0x00, 0x6E, 0x00, //D.o.m.a.i.n. 12bytes
349 0x01, 0x00, 0x0C, 0x00, //NetBIOS Server name, 4 bytes
350 0x53, 0x00, 0x65, 0x00, 0x72, 0x00, 0x76, 0x00, 0x65, 0x00, 0x72, 0x00, //S.e.r.v.e.r. 12bytes
351 0x00, 0x00, 0x00, 0x00, //Av End, 4 bytes
353 const int target_info_len
= 32+4;
354 int ntlmssp_nt_resp_len
= (16 + target_info_len
);
355 guchar nt_challenge_response_v2
[ntlmssp_nt_resp_len
];
357 compute_response(flags
,
363 target_info
, /* target_info */
364 target_info_len
, /* target_info_len */
365 lm_challenge_response
, /* out */
366 nt_challenge_response_v2
, /* out */
367 session_base_key
); /* out */
369 assert_equal("86C35097AC9CEC102554764A57CCCC19AAAAAAAAAAAAAAAA", lm_challenge_response
, 24, TRUE
);
370 assert_equal("68CD0AB851E51C96AABC927BEBEF6A1C", nt_challenge_response_v2
, 16, TRUE
);
371 /* the ref string is taken from binary dump of AUTHENTICATE_MESSAGE */
372 assert_equal("68CD0AB851E51C96AABC927BEBEF6A1C01010000000000000000000000000000AAAAAAAAAAAAAAAA0000000002000C0044006F006D00610069006E0001000C005300650072007600650072000000000000000000", nt_challenge_response_v2
, 84, TRUE
);
373 assert_equal("8DE40CCADBC14A82F15CB0AD0DE95CA3", session_base_key
, 16, TRUE
);
375 printf ("\n\nTesting (NTLMv2) Encrypted Session Key\n");
376 // key_exchange_key = session_base_key for NTLMv2
377 KXKEY(flags
, session_base_key
, lm_challenge_response
, nonce
, key_exchange_key
);
378 //RC4 encryption of the RandomSessionKey with the KeyExchangeKey:
379 RC4K (key_exchange_key
, 16, exported_session_key
, 16, encrypted_random_session_key
);
380 assert_equal("C5DAD2544FC9799094CE1CE90BC9D03E", encrypted_random_session_key
, 16, TRUE
);
382 printf ("\n\nTesting (NTLMv2) SIGNKEY\n");
383 SIGNKEY (exported_session_key
, TRUE
, client_sign_key
);
384 assert_equal("4788DC861B4782F35D43FD98FE1A2D39", client_sign_key
, 16, TRUE
);
386 printf ("\n\nTesting (NTLMv2) SEALKEY\n");
387 SEALKEY (flags
, exported_session_key
, TRUE
, client_seal_key
);
388 assert_equal("59F600973CC4960A25480A7C196E4C58", client_seal_key
, 16, TRUE
);
390 printf ("\n\nTesting (NTLMv2) Encryption\n");
391 RC4K (client_seal_key
, 16, text
, 18, text_enc
);
392 assert_equal("54E50165BF1936DC996020C1811B0F06FB5F", text_enc
, 18, TRUE
);
394 // printf ("\n\nTesting (NTLMv2) Encryption\n");
395 //const guchar text2 [] = {0x50, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x65, 0x00, 0x78, 0x00, 0x74, 0x00
396 // , 0x70, 0x35, 0x28, 0x51, 0xf2, 0x56, 0x43, 0x09}; //P·l·a·i·n·t·e·x·t·
397 //guchar text_enc2 [18+8];
398 // RC4K (client_seal_key, 16, text2, 18+8, text_enc2);
399 // assert_equal("54E50165BF1936DC996020C1811B0F06FB5F", text_enc2, 18+8, TRUE);
401 printf ("\n\nTesting (NTLMv2) MAC (without RC4, as we don't keep its handle yet)\n");
402 mac
= MAC (flags
& ~NTLMSSP_NEGOTIATE_KEY_EXCH
, (gchar
*)text
,18, client_sign_key
,16, client_seal_key
,16, 0, 0);
403 assert_equal("0100000070352851F256430900000000", (guchar
*)mac
, 32, FALSE
);
407 /* End tests from the MS-SIPE document */
410 ////// davenport tests ///////
411 // Test from http://davenport.sourceforge.net/ntlm.html#ntlm1Signing
412 const gchar
*text_j
= "jCIFS";
413 printf ("\n\n(davenport) Testing Signature Algorithm\n");
414 guchar sk
[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0xe5, 0x38, 0xb0};
416 "0100000078010900397420FE0E5A0F89",
417 (guchar
*) MAC(NEGOTIATE_FLAGS
, text_j
, strlen(text_j
), sk
, 8, sk
,8, 0x00090178, 0),
421 // Tests from http://davenport.sourceforge.net/ntlm.html#ntlm2Signing
422 printf ("\n\n(davenport) SIGNKEY\n");
423 const guchar master_key
[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00};
424 SIGNKEY (master_key
, TRUE
, client_sign_key
);
425 assert_equal("F7F97A82EC390F9C903DAC4F6ACEB132", client_sign_key
, 16, TRUE
);
427 printf ("\n\n(davenport) Testing MAC - no Key Exchange flag\n");
428 mac
= MAC (flags
& ~NTLMSSP_NEGOTIATE_KEY_EXCH
, text_j
, strlen(text_j
), client_sign_key
, 16, client_sign_key
,16, 0, 0);
429 assert_equal("010000000A003602317A759A00000000", (guchar
*)mac
, 32, FALSE
);
433 ////// SIPE internal tests ///////
434 // Verify signature of SIPE message received from OCS 2007 after authenticating with pidgin-sipe
435 printf ("\n\nTesting MS-SIPE Example Message Signing\n");
436 char * msg1
= "<NTLM><0878F41B><1><SIP Communications Service><ocs1.ocs.provo.novell.com><8592g5DCBa1694i5887m0D0Bt2247b3F38xAE9Fx><3><REGISTER><sip:gabriel@ocs.provo.novell.com><2947328781><B816D65C2300A32CFA6D371F2AF537FD><900><200>";
437 guchar exported_session_key2
[] = { 0x5F, 0x02, 0x91, 0x53, 0xBC, 0x02, 0x50, 0x58, 0x96, 0x95, 0x48, 0x61, 0x5E, 0x70, 0x99, 0xBA };
439 "0100000000000000BF2E52667DDF6DED",
440 (guchar
*) MAC(NEGOTIATE_FLAGS
, msg1
, strlen(msg1
), exported_session_key2
, 16, exported_session_key2
,16, 0, 100),
444 // Verify parsing of message and signature verification
445 printf ("\n\nTesting MS-SIPE Example Message Parsing, Signing, and Verification\n");
446 char * msg2
= "SIP/2.0 200 OK\r\nms-keep-alive: UAS; tcp=no; hop-hop=yes; end-end=no; timeout=300\r\nAuthentication-Info: NTLM rspauth=\"0100000000000000BF2E52667DDF6DED\", srand=\"0878F41B\", snum=\"1\", opaque=\"4452DFB0\", qop=\"auth\", targetname=\"ocs1.ocs.provo.novell.com\", realm=\"SIP Communications Service\"\r\nFrom: \"Gabriel Burt\"<sip:gabriel@ocs.provo.novell.com>;tag=2947328781;epid=1234567890\r\nTo: <sip:gabriel@ocs.provo.novell.com>;tag=B816D65C2300A32CFA6D371F2AF537FD\r\nCall-ID: 8592g5DCBa1694i5887m0D0Bt2247b3F38xAE9Fx\r\nCSeq: 3 REGISTER\r\nVia: SIP/2.0/TLS 164.99.194.49:10409;branch=z9hG4bKE0E37DBAF252C3255BAD;received=164.99.195.20;ms-received-port=10409;ms-received-cid=1E00\r\nContact: <sip:164.99.195.20:10409;transport=tls;ms-received-cid=1E00>;expires=900\r\nExpires: 900\r\nAllow-Events: vnd-microsoft-provisioning,vnd-microsoft-roaming-contacts,vnd-microsoft-roaming-ACL,presence,presence.wpending,vnd-microsoft-roaming-self,vnd-microsoft-provisioning-v2\r\nSupported: adhoclist\r\nServer: RTC/3.0\r\nSupported: com.microsoft.msrtc.presence\r\nContent-Length: 0\r\n\r\n";
447 struct sipmsg
* msg
= sipmsg_parse_msg(msg2
);
448 struct sipmsg_breakdown msgbd
;
450 sipmsg_breakdown_parse(&msgbd
, "SIP Communications Service", "ocs1.ocs.provo.novell.com");
451 gchar
* msg_str
= sipmsg_breakdown_get_string(&msgbd
);
452 gchar
* sig
= purple_ntlm_sipe_signature_make (NEGOTIATE_FLAGS
, msg_str
, 0, exported_session_key2
, exported_session_key2
);
453 sipmsg_breakdown_free(&msgbd
);
454 assert_equal ("0100000000000000BF2E52667DDF6DED", (guchar
*) sig
, 32, FALSE
);
455 printf("purple_ntlm_verify_signature result = %i\n", purple_ntlm_verify_signature (sig
, "0100000000000000BF2E52667DDF6DED"));
458 ////// UUID tests ///////
459 /* begin tests from MS-SIPRE */
461 const char *testEpid
= "01010101";
462 const char *expectedUUID
= "4b1682a8-f968-5701-83fc-7c6741dc6697";
463 gchar
*calcUUID
= generateUUIDfromEPID(testEpid
);
465 printf("\n\nTesting MS-SIPRE UUID derivation\n");
467 assert_equal(expectedUUID
, (guchar
*) calcUUID
, strlen(expectedUUID
), FALSE
);
474 for (i
= 0,j
=0; i
< 6; i
++,j
+=2) {
475 g_sprintf(&nmac
[j
], "%02X", addr
[i
]);
478 printf("Mac: %s\n", g_strdup(nmac
));
480 /* end tests from MS-SIPRE */
482 printf ("\nFinished With Tests; %d successs %d failures\n", successes
, failures
);