NLTM: fix compilation error in tests
[siplcs.git] / src / core / tests.c
blobbadfbf188f1e2ed5d0d1f896c2521da42178ec45
1 /**
2 * @file tests.c
4 * pidgin-sipe
6 * Copyright (C) 2008 Novell, Inc.
8 * Implemented with reference to the follow documentation:
9 * - http://davenport.sourceforge.net/ntlm.html
10 * - MS-NLMP: http://msdn.microsoft.com/en-us/library/cc207842.aspx
11 * - MS-SIP : http://msdn.microsoft.com/en-us/library/cc246115.aspx
13 * Build and run with (adjust as needed to your build platform!)
15 * $ gcc -I /usr/include/libpurple \
16 * -I /usr/include/dbus-1.0 -I /usr/lib/dbus-1.0/include \
17 * -I /usr/include/glib-2.0 -I /usr/lib/glib-2.0/include \
18 * -o tests tests.c sipe-sign.c sipmsg.c sip-sec.c uuid.c -lpurple
19 * ./tests
21 * This program is free software; you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation; either version 2 of the License, or
24 * (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 #include <glib.h>
37 #include <stdlib.h>
39 #include "sipe-sign.h"
40 #include "sip-sec-ntlm.c"
42 #ifndef _WIN32
43 #include "dbus-server.h"
44 #endif
46 #include "uuid.h"
48 static int successes = 0;
49 static int failures = 0;
51 static void assert_equal(const char * expected, const guchar * got, int len, gboolean stringify)
53 const gchar * res = (gchar *) got;
54 gchar to_str[len*2];
56 if (stringify) {
57 int i, j;
58 for (i = 0, j = 0; i < len; i++, j+=2) {
59 g_sprintf(&to_str[j], "%02X", (got[i]&0xff));
61 len *= 2;
62 res = to_str;
65 printf("expected: %s\n", expected);
66 printf("received: %s\n", res);
68 if (strncmp(expected, res, len) == 0) {
69 successes++;
70 printf("PASSED\n");
71 } else {
72 failures++;
73 printf("FAILED\n");
77 int main()
79 printf ("Starting Tests\n");
81 // Initialization that Pidgin would normally do
82 #ifndef _WIN32
83 g_type_init();
84 #endif
85 purple_signals_init();
86 purple_util_init();
87 purple_debug_init();
88 #ifndef _WIN32
89 purple_dbus_init();
90 #endif
91 purple_ciphers_init();
92 purple_debug_set_enabled(TRUE);
94 /* These tests are from the MS-SIPE document */
96 const char * password = "Password";
97 const char * user = "User";
98 const char * domain = "Domain";
99 const guchar client_challenge [] = {0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa};
100 /* server challenge */
101 const guchar nonce [] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
102 /* 16 bytes */
103 const guchar exported_session_key[] = {0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55};
104 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·
107 ////// internal Cyphers tests ///////
108 printf ("\nTesting MD4()\n");
109 guchar md4 [16];
110 MD4 ((const unsigned char *)"message digest", 14, md4);
111 assert_equal("D9130A8164549FE818874806E1C7014B", md4, 16, TRUE);
113 printf ("\nTesting MD5()\n");
114 guchar md5 [16];
115 MD5 ((const unsigned char *)"message digest", 14, md5);
116 assert_equal("F96B697D7CB7938D525A2F31AAF161D0", md5, 16, TRUE);
118 printf ("\nTesting HMAC_MD5()\n");
119 guchar hmac_md5 [16];
120 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);
121 assert_equal("9294727A3638BB1C13F48EF8158BFC9D", hmac_md5, 16, TRUE);
124 ////// NTLMv1 (without Extended Session Security) ///////
125 use_ntlm_v2 = FALSE;
126 guint32 flags = 0
127 | NTLMSSP_NEGOTIATE_KEY_EXCH
128 | NTLMSSP_NEGOTIATE_56
129 | NTLMSSP_NEGOTIATE_128
130 | NTLMSSP_NEGOTIATE_VERSION
131 | NTLMSSP_TARGET_TYPE_SERVER
132 | NTLMSSP_NEGOTIATE_ALWAYS_SIGN
133 | NTLMSSP_NEGOTIATE_NTLM
134 | NTLMSSP_NEGOTIATE_SEAL
135 | NTLMSSP_NEGOTIATE_SIGN
136 | NTLMSSP_NEGOTIATE_OEM
137 | NTLMSSP_NEGOTIATE_UNICODE;
139 printf ("\n\nTesting Negotiation Flags\n");
140 assert_equal("338202E2", (guchar*)(&flags), 4, TRUE);
142 printf ("\n\nTesting LMOWFv1()\n");
143 guchar response_key_lm [16];
144 LMOWFv1 (password, user, domain, response_key_lm);
145 assert_equal("E52CAC67419A9A224A3B108F3FA6CB6D", response_key_lm, 16, TRUE);
147 printf ("\n\nTesting NTOWFv1()\n");
148 guchar response_key_nt [16];
149 NTOWFv1 (password, user, domain, response_key_nt);
150 assert_equal("A4F49C406510BDCAB6824EE7C30FD852", response_key_nt, 16, TRUE);
152 printf ("\n\nTesting LM Response Generation\n");
153 printf ("Testing NT Response Generation\n");
154 printf ("Testing Session Base Key\n");
155 guchar nt_challenge_response [24];
156 guchar lm_challenge_response [24];
157 guchar session_base_key [16];
159 compute_response(flags,
160 response_key_nt,
161 response_key_lm,
162 nonce,
163 client_challenge,
165 NULL, /* target_info */
166 0, /* target_info_len */
167 lm_challenge_response, /* out */
168 nt_challenge_response, /* out */
169 session_base_key); /* out */
171 assert_equal("98DEF7B87F88AA5DAFE2DF779688A172DEF11C7D5CCDEF13", lm_challenge_response, 24, TRUE);
172 assert_equal("67C43011F30298A2AD35ECE64F16331C44BDBED927841F94", nt_challenge_response, 24, TRUE);
173 assert_equal("D87262B0CDE4B1CB7499BECCCDF10784", session_base_key, 16, TRUE);
175 printf ("\n\nTesting Key Exchange Key\n");
176 guchar key_exchange_key [16];
177 KXKEY(flags, session_base_key, lm_challenge_response, nonce, key_exchange_key);
178 assert_equal("D87262B0CDE4B1CB7499BECCCDF10784", key_exchange_key, 16, TRUE);
180 printf ("\n\nTesting Encrypted Session Key Generation\n");
181 guchar encrypted_random_session_key [16];
182 RC4K (key_exchange_key, 16, exported_session_key, 16, encrypted_random_session_key);
183 assert_equal("518822B1B3F350C8958682ECBB3E3CB7", encrypted_random_session_key, 16, TRUE);
185 printf ("\n\nTesting CRC32\n");
186 gint32 crc = CRC32((char*)text, 18);
187 assert_equal("7D84AA93", (guchar *)&crc, 4, TRUE);
189 printf ("\n\nTesting Encryption\n");
190 guchar client_seal_key [16];
191 //SEALKEY (flags, exported_session_key, TRUE, client_seal_key);
192 guchar buff [18 + 12];
193 memcpy(buff, text, 18);
194 guchar text_enc [18 + 12];
195 guint32 *ptr = (guint32 *)(buff + 18);
196 ptr[0] = 0; // random pad
197 ptr[1] = crc;
198 ptr[2] = 0; // zero
199 RC4K (exported_session_key, 16, buff, 18 + 12, text_enc);
200 //The point is to not reinitialize rc4 cypher
201 // 0 crc 0 (zero)
202 assert_equal("56FE04D861F9319AF0D7238A2E3B4D457FB8" "45C844E5" "09DCD1DF" "2E459D36", text_enc, 18 + 12, TRUE);
204 printf ("\n\nTesting MAC\n");
205 // won't work in the case with sealing because RC4 is re-initialized inside.
206 //gchar *mac = MAC (flags, (gchar*)text, 18, (guchar*)exported_session_key, 16, (guchar*)exported_session_key,16, 0x00000000, 0);
207 ptr = (guint32 *)(text_enc + 18);
208 guint32 mac2 [4];
209 mac2 [0] = 1; // version
210 mac2 [1] = ptr [0];
211 mac2 [2] = ptr [1];
212 mac2 [3] = ptr [2] ^ ((guint32)0); // ^ seq
213 assert_equal("0100000045C844E509DCD1DF2E459D36", (guchar*)mac2, 16, TRUE);
216 ////// EXTENDED_SESSIONSECURITY ///////
217 use_ntlm_v2 = FALSE;
218 flags = 0
219 | NTLMSSP_NEGOTIATE_56
220 | NTLMSSP_NEGOTIATE_VERSION
221 | NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY
222 | NTLMSSP_TARGET_TYPE_SERVER
223 | NTLMSSP_NEGOTIATE_ALWAYS_SIGN
224 | NTLMSSP_NEGOTIATE_NTLM
225 | NTLMSSP_NEGOTIATE_SEAL
226 | NTLMSSP_NEGOTIATE_SIGN
227 | NTLMSSP_NEGOTIATE_OEM
228 | NTLMSSP_NEGOTIATE_UNICODE;
230 printf ("\n\n(Extended session security) Testing Negotiation Flags\n");
231 assert_equal("33820A82", (guchar*)(&flags), 4, TRUE);
233 /* NTOWFv1() is not different from the above test for the same */
235 printf ("\n\n(Extended session security) Testing LM Response\n");
236 printf ("(Extended session security) Testing NT Response\n");
237 printf ("(Extended session security) Testing Session Base Key\n");
238 compute_response(flags,
239 response_key_nt,
240 response_key_lm,
241 nonce,
242 client_challenge,
244 NULL, /* target_info */
245 0, /* target_info_len */
246 lm_challenge_response, /* out */
247 nt_challenge_response, /* out */
248 session_base_key); /* out */
250 assert_equal("AAAAAAAAAAAAAAAA00000000000000000000000000000000", lm_challenge_response, 24, TRUE);
251 assert_equal("7537F803AE367128CA458204BDE7CAF81E97ED2683267232", nt_challenge_response, 24, TRUE);
252 assert_equal("D87262B0CDE4B1CB7499BECCCDF10784", session_base_key, 16, TRUE);
254 printf ("\n\n(Extended session seurity) Testing Key Exchange Key\n");
255 KXKEY(flags, session_base_key, lm_challenge_response, nonce, key_exchange_key);
256 assert_equal("EB93429A8BD952F8B89C55B87F475EDC", key_exchange_key, 16, TRUE);
258 printf ("\n\n(Extended session security) SIGNKEY\n");
259 guchar client_sign_key [16];
260 SIGNKEY (key_exchange_key, TRUE, client_sign_key);
261 assert_equal("60E799BE5C72FC92922AE8EBE961FB8D", client_sign_key, 16, TRUE);
263 printf ("\n\n(Extended session security) SEALKEY\n");
264 SEALKEY (flags, key_exchange_key, TRUE, client_seal_key);
265 assert_equal("04DD7F014D8504D265A25CC86A3A7C06", client_seal_key, 16, TRUE);
267 printf ("\n\n(Extended session security) Testing Encryption\n");
268 RC4K (client_seal_key, 16, text, 18, text_enc);
269 assert_equal("A02372F6530273F3AA1EB90190CE5200C99D", text_enc, 18, TRUE);
271 printf ("\n\n(Extended session security) Testing MAC\n");
272 gchar *mac = MAC (flags, (gchar*)text,18, client_sign_key,16, client_seal_key,16, 0, 0);
273 assert_equal("01000000FF2AEB52F681793A00000000", (guchar*)mac, 32, FALSE);
274 g_free(mac);
277 ////// NTLMv2 ///////
278 use_ntlm_v2 = TRUE;
279 flags = 0
280 | NTLMSSP_NEGOTIATE_KEY_EXCH
281 | NTLMSSP_NEGOTIATE_56
282 | NTLMSSP_NEGOTIATE_128
283 | NTLMSSP_NEGOTIATE_VERSION
284 | NTLMSSP_NEGOTIATE_TARGET_INFO
285 | NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY
286 | NTLMSSP_TARGET_TYPE_SERVER
287 | NTLMSSP_NEGOTIATE_ALWAYS_SIGN
288 | NTLMSSP_NEGOTIATE_NTLM
289 | NTLMSSP_NEGOTIATE_SEAL
290 | NTLMSSP_NEGOTIATE_SIGN
291 | NTLMSSP_NEGOTIATE_OEM
292 | NTLMSSP_NEGOTIATE_UNICODE;
294 printf ("\n\nTesting (NTLMv2) Negotiation Flags\n");
295 assert_equal("33828AE2", (guchar*)(&flags), 4, TRUE);
297 printf ("\n\nTesting NTOWFv2()\n");
298 NTOWFv2 (password, user, domain, response_key_nt);
299 NTOWFv2 (password, user, domain, response_key_lm);
300 assert_equal("0C868A403BFD7A93A3001EF22EF02E3F", response_key_nt, 16, TRUE);
303 printf ("\n\nTesting (NTLMv2) LM Response Generation\n");
304 printf ("Testing (NTLMv2) NT Response Generation and Session Base Key\n");
306 Challenge:
307 4e544c4d53535000020000000c000c003800000033828ae20123456789abcdef00000000000000002400240044000000060070170000000f53006500720076006500720002000c0044006f006d00610069006e0001000c0053006500720076006500720000000000
309 NTLMSSP_NEGOTIATE_UNICODE
310 NTLMSSP_NEGOTIATE_OEM
311 NTLMSSP_NEGOTIATE_SIGN
312 NTLMSSP_NEGOTIATE_SEAL
313 NTLMSSP_NEGOTIATE_NTLM
314 NTLMSSP_NEGOTIATE_ALWAYS_SIGN
315 NTLMSSP_TARGET_TYPE_SERVER
316 NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY
317 NTLMSSP_NEGOTIATE_TARGET_INFO
318 NTLMSSP_NEGOTIATE_VERSION
319 NTLMSSP_NEGOTIATE_128
320 NTLMSSP_NEGOTIATE_KEY_EXCH
321 NTLMSSP_NEGOTIATE_56
322 target_name.len : 12
323 target_name.maxlen: 12
324 target_name.offset: 56
325 target_info.len : 36
326 target_info.maxlen: 36
327 target_info.offset: 68
328 product: 6.0.6000 (Windows Vista, Windows Server 2008, Windows 7 or Windows Server 2008 R2)
329 ntlm_revision_current: 0x0F (NTLMSSP_REVISION_W2K3)
330 target_name: Server
331 MsvAvNbDomainName: Domain
332 MsvAvNbComputerName: Server
334 target_name:
335 530065007200760065007200
336 target_info:
337 02000c0044006f006d00610069006e0001000c0053006500720076006500720000000000
339 const guint64 time_val = 0;
340 const gchar target_info [] = {
341 0x02, 0x00, 0x0C, 0x00, //NetBIOS Domain name, 4 bytes
342 0x44, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x69, 0x00, 0x6E, 0x00, //D.o.m.a.i.n. 12bytes
343 0x01, 0x00, 0x0C, 0x00, //NetBIOS Server name, 4 bytes
344 0x53, 0x00, 0x65, 0x00, 0x72, 0x00, 0x76, 0x00, 0x65, 0x00, 0x72, 0x00, //S.e.r.v.e.r. 12bytes
345 0x00, 0x00, 0x00, 0x00, //Av End, 4 bytes
347 const int target_info_len = 32+4;
349 compute_response(flags,
350 response_key_nt,
351 response_key_lm,
352 nonce,
353 client_challenge,
354 time_val,
355 target_info, /* target_info */
356 target_info_len, /* target_info_len */
357 lm_challenge_response, /* out */
358 nt_challenge_response, /* out */
359 session_base_key); /* out */
361 assert_equal("86C35097AC9CEC102554764A57CCCC19AAAAAAAAAAAAAAAA", lm_challenge_response, 24, TRUE);
362 assert_equal("68CD0AB851E51C96AABC927BEBEF6A1C", nt_challenge_response, 16, TRUE);
363 assert_equal("8DE40CCADBC14A82F15CB0AD0DE95CA3", session_base_key, 16, TRUE);
365 printf ("\n\nTesting (NTLMv2) Encrypted Session Key\n");
366 // key_exchange_key = session_base_key for NTLMv2
367 KXKEY(flags, session_base_key, lm_challenge_response, nonce, key_exchange_key);
368 //RC4 encryption of the RandomSessionKey with the KeyExchangeKey:
369 RC4K (key_exchange_key, 16, exported_session_key, 16, encrypted_random_session_key);
370 assert_equal("C5DAD2544FC9799094CE1CE90BC9D03E", encrypted_random_session_key, 16, TRUE);
372 printf ("\n\nTesting (NTLMv2) SIGNKEY\n");
373 SIGNKEY (exported_session_key, TRUE, client_sign_key);
374 assert_equal("4788DC861B4782F35D43FD98FE1A2D39", client_sign_key, 16, TRUE);
376 printf ("\n\nTesting (NTLMv2) SEALKEY\n");
377 SEALKEY (flags, exported_session_key, TRUE, client_seal_key);
378 assert_equal("59F600973CC4960A25480A7C196E4C58", client_seal_key, 16, TRUE);
380 printf ("\n\nTesting (NTLMv2) Encryption\n");
381 RC4K (client_seal_key, 16, text, 18, text_enc);
382 assert_equal("54E50165BF1936DC996020C1811B0F06FB5F", text_enc, 18, TRUE);
384 // printf ("\n\nTesting (NTLMv2) Encryption\n");
385 //const guchar text2 [] = {0x50, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x65, 0x00, 0x78, 0x00, 0x74, 0x00
386 // , 0x70, 0x35, 0x28, 0x51, 0xf2, 0x56, 0x43, 0x09}; //P·l·a·i·n·t·e·x·t·
387 //guchar text_enc2 [18+8];
388 // RC4K (client_seal_key, 16, text2, 18+8, text_enc2);
389 // assert_equal("54E50165BF1936DC996020C1811B0F06FB5F", text_enc2, 18+8, TRUE);
391 printf ("\n\nTesting (NTLMv2) MAC (without RC4, as we don't keep its handle yet)\n");
392 mac = MAC (flags & ~NTLMSSP_NEGOTIATE_KEY_EXCH, (gchar*)text,18, client_sign_key,16, client_seal_key,16, 0, 0);
393 assert_equal("0100000070352851F256430900000000", (guchar*)mac, 32, FALSE);
394 g_free(mac);
397 /* End tests from the MS-SIPE document */
400 ////// davenport tests ///////
401 // Test from http://davenport.sourceforge.net/ntlm.html#ntlm1Signing
402 const gchar *text_j = "jCIFS";
403 printf ("\n\n(davenport) Testing Signature Algorithm\n");
404 guchar sk [] = {0x01, 0x02, 0x03, 0x04, 0x05, 0xe5, 0x38, 0xb0};
405 assert_equal (
406 "0100000078010900397420FE0E5A0F89",
407 (guchar *) MAC(NEGOTIATE_FLAGS, text_j, strlen(text_j), sk, 8, sk,8, 0x00090178, 0),
408 32, FALSE
411 // Tests from http://davenport.sourceforge.net/ntlm.html#ntlm2Signing
412 printf ("\n\n(davenport) SIGNKEY\n");
413 const guchar master_key [] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00};
414 SIGNKEY (master_key, TRUE, client_sign_key);
415 assert_equal("F7F97A82EC390F9C903DAC4F6ACEB132", client_sign_key, 16, TRUE);
417 printf ("\n\n(davenport) Testing MAC - no Key Exchange flag\n");
418 mac = MAC (flags & ~NTLMSSP_NEGOTIATE_KEY_EXCH, text_j, strlen(text_j), client_sign_key, 16, client_sign_key,16, 0, 0);
419 assert_equal("010000000A003602317A759A00000000", (guchar*)mac, 32, FALSE);
420 g_free(mac);
423 ////// SIPE internal tests ///////
424 // Verify signature of SIPE message received from OCS 2007 after authenticating with pidgin-sipe
425 printf ("\n\nTesting MS-SIPE Example Message Signing\n");
426 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>";
427 guchar exported_session_key2 [] = { 0x5F, 0x02, 0x91, 0x53, 0xBC, 0x02, 0x50, 0x58, 0x96, 0x95, 0x48, 0x61, 0x5E, 0x70, 0x99, 0xBA };
428 assert_equal (
429 "0100000000000000BF2E52667DDF6DED",
430 (guchar *) MAC(NEGOTIATE_FLAGS, msg1, strlen(msg1), exported_session_key2, 16, exported_session_key2,16, 0, 100),
431 32, FALSE
434 // Verify parsing of message and signature verification
435 printf ("\n\nTesting MS-SIPE Example Message Parsing, Signing, and Verification\n");
436 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";
437 struct sipmsg * msg = sipmsg_parse_msg(msg2);
438 struct sipmsg_breakdown msgbd;
439 msgbd.msg = msg;
440 sipmsg_breakdown_parse(&msgbd, "SIP Communications Service", "ocs1.ocs.provo.novell.com");
441 gchar * msg_str = sipmsg_breakdown_get_string(&msgbd);
442 gchar * sig = purple_ntlm_sipe_signature_make (NEGOTIATE_FLAGS, msg_str, 0, exported_session_key2, exported_session_key2);
443 sipmsg_breakdown_free(&msgbd);
444 assert_equal ("0100000000000000BF2E52667DDF6DED", (guchar *) sig, 32, FALSE);
445 printf("purple_ntlm_verify_signature result = %i\n", purple_ntlm_verify_signature (sig, "0100000000000000BF2E52667DDF6DED"));
448 ////// UUID tests ///////
449 /* begin tests from MS-SIPRE */
451 const char *testEpid = "01010101";
452 const char *expectedUUID = "4b1682a8-f968-5701-83fc-7c6741dc6697";
453 gchar *calcUUID = generateUUIDfromEPID(testEpid);
455 printf("\n\nTesting MS-SIPRE UUID derivation\n");
457 assert_equal(expectedUUID, (guchar *) calcUUID, strlen(expectedUUID), FALSE);
458 g_free(calcUUID);
460 guchar addr[6];
461 gchar nmac[6];
463 int i,j;
464 for (i = 0,j=0; i < 6; i++,j+=2) {
465 g_sprintf(&nmac[j], "%02X", addr[i]);
468 printf("Mac: %s\n", g_strdup(nmac));
470 /* end tests from MS-SIPRE */
472 printf ("\nFinished With Tests; %d successs %d failures\n", successes, failures);
474 return(0);
478 Local Variables:
479 mode: c
480 c-file-style: "bsd"
481 indent-tabs-mode: t
482 tab-width: 8
483 End: