ReactOS 0.4.15-dev-8131-g4988de4
crypt_lmhash.c File Reference
#include <stdio.h>
#include "ntstatus.h"
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
Include dependency graph for crypt_lmhash.c:

Go to the source code of this file.

Classes

struct  ustring
 

Macros

#define WIN32_NO_STATUS
 

Typedefs

typedef int(WINAPIdescrypt) (unsigned char *, unsigned char *, unsigned char *)
 
typedef int(WINAPImemcmpfunc) (unsigned char *, unsigned char *)
 

Functions

static NTSTATUS (WINAPI *pSystemFunction001)(const BYTE *
 
static const struct ustring struct ustring *static const struct ustring struct ustring *static VOID (WINAPI *pSystemFunction006)(PCSTR passwd
 
static void test_SystemFunction006 (void)
 
static void test_SystemFunction008 (void)
 
static void test_SystemFunction001 (void)
 
static void test_SystemFunction002 (void)
 
static void test_SystemFunction032 (void)
 
static void test_SystemFunction003 (void)
 
static void test_SystemFunction004 (void)
 
static void test_SystemFunction005 (void)
 
static void test_SystemFunction009 (void)
 
static void test_SystemFunction_encrypt (descrypt func, int num)
 
static void test_SystemFunction_decrypt (descrypt func, int num)
 
static void test_SystemFunction_enc32 (descrypt func, int num)
 
static void test_SystemFunction_dec32 (descrypt func, int num)
 
static void test_memcmpfunc (memcmpfunc fn)
 
 START_TEST (crypt_lmhash)
 

Variables

static const BYTE LPBYTE
 
static const struct ustring struct ustring *static const struct ustring struct ustring *static PSTR lmhash
 
static const struct ustring *static descrypt pSystemFunction012
 
static descrypt pSystemFunction014
 
static descrypt pSystemFunction016
 
static descrypt pSystemFunction018
 
static descrypt pSystemFunction020
 
static descrypt pSystemFunction022
 
static descrypt pSystemFunction013
 
static descrypt pSystemFunction015
 
static descrypt pSystemFunction017
 
static descrypt pSystemFunction019
 
static descrypt pSystemFunction021
 
static descrypt pSystemFunction023
 
static descrypt pSystemFunction024
 
static descrypt pSystemFunction025
 
static descrypt pSystemFunction026
 
static descrypt pSystemFunction027
 
static memcmpfunc pSystemFunction030
 
static memcmpfunc pSystemFunction031
 
static unsigned char des_key []
 
static unsigned char des_plaintext []
 
static unsigned char des_ciphertext []
 
static unsigned char des_ciphertext32 []
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 25 of file crypt_lmhash.c.

Typedef Documentation

◆ descrypt

typedef int(WINAPI * descrypt) (unsigned char *, unsigned char *, unsigned char *)

Definition at line 37 of file crypt_lmhash.c.

◆ memcmpfunc

typedef int(WINAPI * memcmpfunc) (unsigned char *, unsigned char *)

Definition at line 72 of file crypt_lmhash.c.

Function Documentation

◆ NTSTATUS()

static NTSTATUS ( WINAPI pSystemFunction001) const
static

◆ START_TEST()

START_TEST ( crypt_lmhash  )

Definition at line 530 of file crypt_lmhash.c.

531{
532 HMODULE module = GetModuleHandleA("advapi32.dll");
533
534 pSystemFunction001 = (void *)GetProcAddress( module, "SystemFunction001" );
535 if (pSystemFunction001)
537 else
538 win_skip("SystemFunction001 is not available\n");
539
540 pSystemFunction002 = (void *)GetProcAddress( module, "SystemFunction002" );
541 if (pSystemFunction002)
543 else
544 win_skip("SystemFunction002 is not available\n");
545
546 pSystemFunction003 = (void *)GetProcAddress( module, "SystemFunction003" );
547 if (pSystemFunction003)
549 else
550 win_skip("SystemFunction002 is not available\n");
551
552 pSystemFunction004 = (void *)GetProcAddress( module, "SystemFunction004" );
553 if (pSystemFunction004)
555 else
556 win_skip("SystemFunction004 is not available\n");
557
558 pSystemFunction005 = (void *)GetProcAddress( module, "SystemFunction005" );
559 if (pSystemFunction005)
561 else
562 win_skip("SystemFunction005 is not available\n");
563
564 pSystemFunction006 = (void *)GetProcAddress( module, "SystemFunction006" );
565 if (pSystemFunction006)
567 else
568 win_skip("SystemFunction006 is not available\n");
569
570 pSystemFunction008 = (void *)GetProcAddress( module, "SystemFunction008" );
571 if (pSystemFunction008)
573 else
574 win_skip("SystemFunction008 is not available\n");
575
576 pSystemFunction009 = (void *)GetProcAddress( module, "SystemFunction009" );
577 if (pSystemFunction009)
579 else
580 win_skip("SystemFunction009 is not available\n");
581
582 pSystemFunction012 = (descrypt) GetProcAddress( module, "SystemFunction012");
583 pSystemFunction013 = (descrypt) GetProcAddress( module, "SystemFunction013");
584 pSystemFunction014 = (descrypt) GetProcAddress( module, "SystemFunction014");
585 pSystemFunction015 = (descrypt) GetProcAddress( module, "SystemFunction015");
586 pSystemFunction016 = (descrypt) GetProcAddress( module, "SystemFunction016");
587 pSystemFunction017 = (descrypt) GetProcAddress( module, "SystemFunction017");
588 pSystemFunction018 = (descrypt) GetProcAddress( module, "SystemFunction018");
589 pSystemFunction019 = (descrypt) GetProcAddress( module, "SystemFunction019");
590 pSystemFunction020 = (descrypt) GetProcAddress( module, "SystemFunction020");
591 pSystemFunction021 = (descrypt) GetProcAddress( module, "SystemFunction021");
592 pSystemFunction022 = (descrypt) GetProcAddress( module, "SystemFunction022");
593 pSystemFunction023 = (descrypt) GetProcAddress( module, "SystemFunction023");
594
595 /* these all encrypt two DES blocks */
602
603 /* these all decrypt two DES blocks */
610
611 pSystemFunction024 = (descrypt) GetProcAddress( module, "SystemFunction024");
612 pSystemFunction025 = (descrypt) GetProcAddress( module, "SystemFunction025");
613 pSystemFunction026 = (descrypt) GetProcAddress( module, "SystemFunction026");
614 pSystemFunction027 = (descrypt) GetProcAddress( module, "SystemFunction027");
615
616 /* these encrypt two DES blocks with a short key */
619
620 /* these descrypt two DES blocks with a short key */
623
624 pSystemFunction030 = (memcmpfunc) GetProcAddress( module, "SystemFunction030" );
625 pSystemFunction031 = (memcmpfunc) GetProcAddress( module, "SystemFunction031" );
626
629
630 pSystemFunction032 = (void *)GetProcAddress( module, "SystemFunction032" );
631 if (pSystemFunction032)
633 else
634 win_skip("SystemFunction032 is not available\n");
635}
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static descrypt pSystemFunction027
Definition: crypt_lmhash.c:70
static void test_SystemFunction008(void)
Definition: crypt_lmhash.c:94
static descrypt pSystemFunction015
Definition: crypt_lmhash.c:58
static void test_SystemFunction003(void)
Definition: crypt_lmhash.c:193
static void test_memcmpfunc(memcmpfunc fn)
Definition: crypt_lmhash.c:492
static void test_SystemFunction009(void)
Definition: crypt_lmhash.c:367
static descrypt pSystemFunction013
Definition: crypt_lmhash.c:57
static void test_SystemFunction_encrypt(descrypt func, int num)
Definition: crypt_lmhash.c:401
static descrypt pSystemFunction019
Definition: crypt_lmhash.c:60
static descrypt pSystemFunction023
Definition: crypt_lmhash.c:62
static void test_SystemFunction006(void)
Definition: crypt_lmhash.c:76
int(WINAPI * descrypt)(unsigned char *, unsigned char *, unsigned char *)
Definition: crypt_lmhash.c:37
static descrypt pSystemFunction021
Definition: crypt_lmhash.c:61
static memcmpfunc pSystemFunction031
Definition: crypt_lmhash.c:74
static void test_SystemFunction032(void)
Definition: crypt_lmhash.c:169
static void test_SystemFunction004(void)
Definition: crypt_lmhash.c:219
static descrypt pSystemFunction025
Definition: crypt_lmhash.c:66
static descrypt pSystemFunction022
Definition: crypt_lmhash.c:54
static void test_SystemFunction001(void)
Definition: crypt_lmhash.c:135
static const struct ustring *static descrypt pSystemFunction012
Definition: crypt_lmhash.c:49
static void test_SystemFunction_dec32(descrypt func, int num)
Definition: crypt_lmhash.c:470
static memcmpfunc pSystemFunction030
Definition: crypt_lmhash.c:73
static void test_SystemFunction002(void)
Definition: crypt_lmhash.c:154
static descrypt pSystemFunction016
Definition: crypt_lmhash.c:51
static void test_SystemFunction_enc32(descrypt func, int num)
Definition: crypt_lmhash.c:448
static descrypt pSystemFunction014
Definition: crypt_lmhash.c:50
int(WINAPI * memcmpfunc)(unsigned char *, unsigned char *)
Definition: crypt_lmhash.c:72
static descrypt pSystemFunction026
Definition: crypt_lmhash.c:69
static void test_SystemFunction_decrypt(descrypt func, int num)
Definition: crypt_lmhash.c:422
static descrypt pSystemFunction024
Definition: crypt_lmhash.c:65
static descrypt pSystemFunction018
Definition: crypt_lmhash.c:52
static void test_SystemFunction005(void)
Definition: crypt_lmhash.c:304
static descrypt pSystemFunction017
Definition: crypt_lmhash.c:59
static descrypt pSystemFunction020
Definition: crypt_lmhash.c:53
#define win_skip
Definition: test.h:163

◆ test_memcmpfunc()

static void test_memcmpfunc ( memcmpfunc  fn)
static

Definition at line 492 of file crypt_lmhash.c.

493{
494 unsigned char arg1[0x20], arg2[0x20];
495 int r;
496
497 if (!fn)
498 {
499 win_skip("function is not available\n");
500 return;
501 }
502
503 memset(arg1, 0, sizeof arg1);
504 memset(arg2, 0, sizeof arg2);
505 arg1[0x10] = 1;
506
507 r = fn(arg1, arg2);
508 ok( r == 1, "wrong error code\n");
509
510 memset(arg1, 1, sizeof arg1);
511 memset(arg2, 1, sizeof arg2);
512 arg1[0x10] = 0;
513
514 r = fn(arg1, arg2);
515 ok( r == 1, "wrong error code\n");
516
517 memset(arg1, 0, sizeof arg1);
518 memset(arg2, 1, sizeof arg2);
519
520 r = fn(arg1, arg2);
521 ok( r == 0, "wrong error code\n");
522
523 memset(arg1, 1, sizeof arg1);
524 memset(arg2, 0, sizeof arg2);
525
526 r = fn(arg1, arg2);
527 ok( r == 0, "wrong error code\n");
528}
#define ok(value,...)
Definition: atltest.h:57
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLuint GLuint arg1
Definition: glext.h:9513
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
Definition: glext.h:9514
#define memset(x, y, z)
Definition: compat.h:39
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159

Referenced by START_TEST().

◆ test_SystemFunction001()

static void test_SystemFunction001 ( void  )
static

Definition at line 135 of file crypt_lmhash.c.

136{
137 unsigned char key[8] = { 0xff, 0x37, 0x50, 0xbc, 0xc2, 0xb2, 0x24, 0 };
138 unsigned char data[8] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
139 unsigned char expected[8] = { 0xc3, 0x37, 0xcd, 0x5c, 0xbd, 0x44, 0xfc, 0x97 };
140 unsigned char output[16];
141 NTSTATUS r;
142
143 r = pSystemFunction001(0,0,0);
144 ok( r == STATUS_UNSUCCESSFUL, "wrong error code\n");
145
146 memset(output, 0, sizeof output);
147
148 r = pSystemFunction001(data,key,output);
149 ok( r == STATUS_SUCCESS, "wrong error code\n");
150
151 ok(!memcmp(output, expected, sizeof expected), "response wrong\n");
152}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
LONG NTSTATUS
Definition: precomp.h:26
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
BOOL expected
Definition: store.c:2063
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: copy.c:22
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by START_TEST().

◆ test_SystemFunction002()

static void test_SystemFunction002 ( void  )
static

Definition at line 154 of file crypt_lmhash.c.

155{
156 /* reverse of SystemFunction001 */
157 unsigned char key[8] = { 0xff, 0x37, 0x50, 0xbc, 0xc2, 0xb2, 0x24, 0 };
158 unsigned char expected[8] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
159 unsigned char data[8] = { 0xc3, 0x37, 0xcd, 0x5c, 0xbd, 0x44, 0xfc, 0x97 };
160 unsigned char output[8];
161 int r;
162
163 memset(output, 0, sizeof output);
164 r = pSystemFunction002(data, key, output);
165 ok(r == STATUS_SUCCESS, "function failed\n");
166 ok(!memcmp(output, expected, sizeof expected), "response wrong\n");
167}

Referenced by START_TEST().

◆ test_SystemFunction003()

static void test_SystemFunction003 ( void  )
static

Definition at line 193 of file crypt_lmhash.c.

194{
195 unsigned char output[8], data[8];
196 unsigned char key[7] = { 0xff, 0x37, 0x50, 0xbc, 0xc2, 0xb2, 0x24 };
197 unsigned char exp1[8] = { 0x9d, 0x21, 0xc8, 0x86, 0x6c, 0x21, 0xcf, 0x43 };
198 char exp2[] = "KGS!@#$%";
199 int r;
200
201 r = pSystemFunction003(NULL, NULL);
202 ok(r == STATUS_UNSUCCESSFUL, "function failed\n");
203
204 r = pSystemFunction003(key, NULL);
205 ok(r == STATUS_UNSUCCESSFUL, "function failed\n");
206
207 memset(data, 0, sizeof data);
208 r = pSystemFunction003(key, data);
209 ok(r == STATUS_SUCCESS, "function failed\n");
210 ok( !memcmp(exp1, data, sizeof data), "decrypted message wrong\n");
211
212 memset(output, 0, sizeof output);
213 r = pSystemFunction002(data, key, output);
214 ok(r == STATUS_SUCCESS, "function failed\n");
215
216 ok( !memcmp(exp2, output, sizeof output), "decrypted message wrong\n");
217}
#define NULL
Definition: types.h:112
double __cdecl exp2(double)

Referenced by START_TEST().

◆ test_SystemFunction004()

static void test_SystemFunction004 ( void  )
static

Definition at line 219 of file crypt_lmhash.c.

220{
221 unsigned char inbuf[0x100], keybuf[0x100], resbuf[0x100];
222 unsigned char output[8];
223 int r;
224 struct ustring in, key, out;
225
226 /* crash
227 r = pSystemFunction004(NULL, NULL, NULL);
228 ok(r == STATUS_UNSUCCESSFUL, "function failed\n");
229 */
230
231 memset(inbuf, 0, sizeof inbuf);
232 memset(keybuf, 0, sizeof keybuf);
233 memset(resbuf, 0, sizeof resbuf);
234
235 in.Buffer = NULL;
236 in.Length = in.MaximumLength = 0;
237
238 key.Buffer = NULL;
239 key.Length = key.MaximumLength = 0;
240
241 out.Buffer = NULL;
242 out.Length = out.MaximumLength = 0;
243
244 r = pSystemFunction004(&in, &key, &out);
245 ok(r == STATUS_INVALID_PARAMETER_2, "function failed\n");
246
247 key.Buffer = keybuf;
248 key.Length = 0x100;
249 key.MaximumLength = 0x100;
250
251 r = pSystemFunction004(&in, &key, &out);
252 ok(r == STATUS_BUFFER_TOO_SMALL, "function failed\n");
253
254 in.Buffer = inbuf;
255 in.Length = 0x0c;
256 in.MaximumLength = 0;
257
258 /* add two identical blocks... */
259 inbuf[0] = 1;
260 inbuf[1] = 2;
261 inbuf[2] = 3;
262 inbuf[3] = 4;
263
264 inbuf[8] = 1;
265 inbuf[9] = 2;
266 inbuf[10] = 3;
267 inbuf[11] = 4;
268
269 /* check that the Length field is really obeyed */
270 keybuf[6] = 1;
271
272 key.Buffer = keybuf;
273 key.Length = 6;
274 key.MaximumLength = 0;
275
276 keybuf[1] = 0x33;
277
278 out.Buffer = resbuf;
279 out.Length = 0;
280 out.MaximumLength = 0x40;
281 r = pSystemFunction004(&in, &key, &out);
282 ok(r == STATUS_SUCCESS, "function failed\n");
283
284 keybuf[6] = 0;
285
286 memset(output, 0, sizeof output);
287 r = pSystemFunction002(out.Buffer, key.Buffer, output);
288 ok(r == STATUS_SUCCESS, "function failed\n");
289
290 ok(((unsigned int*)output)[0] == in.Length, "crypted length wrong\n");
291 ok(((unsigned int*)output)[1] == 1, "crypted value wrong\n");
292
293 memset(output, 0, sizeof output);
294 r = pSystemFunction002(out.Buffer+8, key.Buffer, output);
295 ok(r == STATUS_SUCCESS, "function failed\n");
296 ok(!memcmp(output, inbuf, sizeof output), "crypted data wrong\n");
297
298 memset(output, 0, sizeof output);
299 r = pSystemFunction002(out.Buffer+16, key.Buffer, output);
300 ok(r == STATUS_SUCCESS, "function failed\n");
301 ok(!memcmp(output, inbuf, sizeof output), "crypted data wrong\n");
302}
static int inbuf
Definition: adnsresfilter.c:73
GLuint in
Definition: glext.h:9616
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
static FILE * out
Definition: regtests2xml.c:44
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
Definition: config.c:19

Referenced by START_TEST().

◆ test_SystemFunction005()

static void test_SystemFunction005 ( void  )
static

Definition at line 304 of file crypt_lmhash.c.

305{
306 char output[0x40], result[0x40];
307 int r;
308 struct ustring in, key, out, res;
309 static char datastr[] = "twinkle twinkle little star";
310 static char keystr[] = "byolnim";
311
312 in.Buffer = (unsigned char *)datastr;
313 in.Length = strlen(datastr);
314 in.MaximumLength = 0;
315
316 key.Buffer = (unsigned char *)keystr;
317 key.Length = strlen(keystr);
318 key.MaximumLength = 0;
319
320 out.Buffer = (unsigned char *)output;
321 out.Length = out.MaximumLength = sizeof output;
322
323 r = pSystemFunction004(&in, &key, &out);
324 ok(r == STATUS_SUCCESS, "function failed\n");
325
326 memset(result, 0, sizeof result);
327 res.Buffer = (unsigned char *)result;
328 res.Length = 0;
329 res.MaximumLength = sizeof result;
330
331 r = pSystemFunction005(&out, &key, &res);
332 ok(r == STATUS_SUCCESS, "function failed\n");
333
334 r = pSystemFunction005(&out, &key, &res);
335 ok(r == STATUS_SUCCESS, "function failed\n");
336
337 ok(res.Length == in.Length, "Length wrong\n");
338 ok(!memcmp(res.Buffer, in.Buffer, in.Length), "data wrong\n");
339
340 out.Length = 0;
341 out.MaximumLength = 0;
342 r = pSystemFunction005(&out, &key, &res);
343 ok(r == STATUS_SUCCESS ||
344 r == STATUS_INVALID_PARAMETER_1, /* Vista */
345 "Expected STATUS_SUCCESS or STATUS_INVALID_PARAMETER_1, got %08x\n", r);
346
347 ok(res.Length == in.Length, "Length wrong\n");
348 ok(!memcmp(res.Buffer, in.Buffer, in.Length), "data wrong\n");
349
350 res.MaximumLength = 0;
351 r = pSystemFunction005(&out, &key, &res);
353 r == STATUS_INVALID_PARAMETER_1, /* Vista */
354 "Expected STATUS_BUFFER_TOO_SMALL or STATUS_INVALID_PARAMETER_1, got %08x\n", r);
355
356 key.Length = 1;
357 r = pSystemFunction005(&out, &key, &res);
359 r == STATUS_INVALID_PARAMETER_1, /* Vista */
360 "Expected STATUS_UNKNOWN_REVISION or STATUS_INVALID_PARAMETER_1, got %08x\n", r);
361
362 key.Length = 0;
363 r = pSystemFunction005(&out, &key, &res);
364 ok(r == STATUS_INVALID_PARAMETER_2, "function failed\n");
365}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint res
Definition: glext.h:9613
GLuint64EXT * result
Definition: glext.h:11304
#define STATUS_UNKNOWN_REVISION
Definition: ntstatus.h:324
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475

Referenced by START_TEST().

◆ test_SystemFunction006()

static void test_SystemFunction006 ( void  )
static

Definition at line 76 of file crypt_lmhash.c.

77{
78 char lmhash[16 + 1];
79
80 char passwd[] = { 's','e','c','r','e','t', 0, 0, 0, 0, 0, 0, 0, 0 };
81 unsigned char expect[] =
82 { 0x85, 0xf5, 0x28, 0x9f, 0x09, 0xdc, 0xa7, 0xeb,
83 0xaa, 0xd3, 0xb4, 0x35, 0xb5, 0x14, 0x04, 0xee };
84
85 pSystemFunction006( passwd, lmhash );
86
87 ok( !memcmp( lmhash, expect, sizeof(expect) ),
88 "lmhash: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
89 lmhash[0], lmhash[1], lmhash[2], lmhash[3], lmhash[4], lmhash[5],
90 lmhash[6], lmhash[7], lmhash[8], lmhash[9], lmhash[10], lmhash[11],
91 lmhash[12], lmhash[13], lmhash[14], lmhash[15] );
92}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
static const struct ustring struct ustring *static const struct ustring struct ustring *static PSTR lmhash
Definition: crypt_lmhash.c:43

Referenced by START_TEST().

◆ test_SystemFunction008()

static void test_SystemFunction008 ( void  )
static

Definition at line 94 of file crypt_lmhash.c.

95{
96 /* example data from http://davenport.sourceforge.net/ntlm.html */
97 unsigned char hash[0x40] = {
98 0xff, 0x37, 0x50, 0xbc, 0xc2, 0xb2, 0x24, 0x12,
99 0xc2, 0x26, 0x5b, 0x23, 0x73, 0x4e, 0x0d, 0xac };
100 unsigned char challenge[0x40] = {
101 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
102 unsigned char expected[0x18] = {
103 0xc3, 0x37, 0xcd, 0x5c, 0xbd, 0x44, 0xfc, 0x97,
104 0x82, 0xa6, 0x67, 0xaf, 0x6d, 0x42, 0x7c, 0x6d,
105 0xe6, 0x7c, 0x20, 0xc2, 0xd3, 0xe7, 0x7c, 0x56 };
106 unsigned char output[0x18];
107 NTSTATUS r;
108
109 r = pSystemFunction008(0,0,0);
110 ok( r == STATUS_UNSUCCESSFUL, "wrong error code\n");
111
112 r = pSystemFunction008(challenge,0,0);
113 ok( r == STATUS_UNSUCCESSFUL, "wrong error code\n");
114
115 r = pSystemFunction008(challenge, hash, 0);
116 ok( r == STATUS_UNSUCCESSFUL, "wrong error code\n");
117
118 /* crashes */
119 if (0)
120 {
121 r = pSystemFunction008(challenge, 0, output);
122 ok( r == STATUS_UNSUCCESSFUL, "wrong error code\n");
123 }
124
125 r = pSystemFunction008(0, 0, output);
126 ok( r == STATUS_UNSUCCESSFUL, "wrong error code\n");
127
128 memset(output, 0, sizeof output);
129 r = pSystemFunction008(challenge, hash, output);
130 ok( r == STATUS_SUCCESS, "wrong error code\n");
131
132 ok( !memcmp(output, expected, sizeof expected), "response wrong\n");
133}
Definition: _hash_fun.h:40

Referenced by START_TEST().

◆ test_SystemFunction009()

static void test_SystemFunction009 ( void  )
static

Definition at line 367 of file crypt_lmhash.c.

368{
369 unsigned char hash[0x10] = {
370 0xff, 0x37, 0x50, 0xbc, 0xc2, 0xb2, 0x24, 0x12,
371 0xc2, 0x26, 0x5b, 0x23, 0x73, 0x4e, 0x0d, 0xac };
372 unsigned char challenge[8] = {
373 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
374 unsigned char expected[0x18] = {
375 0xc3, 0x37, 0xcd, 0x5c, 0xbd, 0x44, 0xfc, 0x97,
376 0x82, 0xa6, 0x67, 0xaf, 0x6d, 0x42, 0x7c, 0x6d,
377 0xe6, 0x7c, 0x20, 0xc2, 0xd3, 0xe7, 0x7c, 0x56 };
378 unsigned char output[0x18];
379 int r;
380
381 memset(output, 0, sizeof output);
382 r = pSystemFunction009(challenge, hash, output);
383 ok( r == STATUS_SUCCESS, "wrong error code\n");
384 ok(!memcmp(output, expected, sizeof expected), "response wrong\n");
385}

Referenced by START_TEST().

◆ test_SystemFunction032()

static void test_SystemFunction032 ( void  )
static

Definition at line 169 of file crypt_lmhash.c.

170{
171 struct ustring key, data;
172 unsigned char szKey[] = { 'f','o','o',0 };
173 unsigned char szData[8] = { 'b','a','r',0 };
174 unsigned char expected[] = {0x28, 0xb9, 0xf8, 0xe1};
175 int r;
176
177 /* crashes: pSystemFunction032(NULL,NULL); */
178
179 key.Buffer = szKey;
180 key.Length = sizeof szKey;
181 key.MaximumLength = key.Length;
182
183 data.Buffer = szData;
184 data.Length = 4;
185 data.MaximumLength = 8;
186
187 r = pSystemFunction032(&data, &key);
188 ok(r == STATUS_SUCCESS, "function failed\n");
189
190 ok(!memcmp(expected, data.Buffer, data.Length), "wrong result\n");
191}

Referenced by START_TEST().

◆ test_SystemFunction_dec32()

static void test_SystemFunction_dec32 ( descrypt  func,
int  num 
)
static

Definition at line 470 of file crypt_lmhash.c.

471{
472 unsigned char key[4], output[0x11];
473 int r;
474
475 if (!func)
476 {
477 win_skip("SystemFunction%03d is not available\n", num);
478 return;
479 }
480
481 memset(output, 0, sizeof output);
482
483 /* two keys are generated using 4 bytes, repeated 4 times ... */
484 memcpy(key, "foo", 4);
485
486 r = func(des_ciphertext32, key, output);
487 ok( r == STATUS_SUCCESS, "wrong error code (%d)\n", num);
488
489 ok( !memcmp( output, des_plaintext, sizeof des_plaintext), "plaintext wrong (%d)\n", num);
490}
GLenum func
Definition: glext.h:6028
GLuint GLuint num
Definition: glext.h:9618
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static unsigned char des_plaintext[]
Definition: crypt_lmhash.c:391
static unsigned char des_ciphertext32[]
Definition: crypt_lmhash.c:443

Referenced by START_TEST().

◆ test_SystemFunction_decrypt()

static void test_SystemFunction_decrypt ( descrypt  func,
int  num 
)
static

Definition at line 422 of file crypt_lmhash.c.

423{
424 unsigned char output[0x11];
425 int r;
426
427 if (!func)
428 {
429 win_skip("SystemFunction%03d is not available\n", num);
430 return;
431 }
432
433 r = func(NULL, NULL, NULL);
434 ok( r == STATUS_UNSUCCESSFUL, "wrong error code\n");
435
436 memset(output, 0, sizeof output);
437
438 r = func(des_ciphertext, des_key, output);
439 ok( r == STATUS_SUCCESS, "wrong error code\n");
440 ok( !memcmp(des_plaintext, output, sizeof des_plaintext), "plaintext wrong (%d)\n", num);
441}
static unsigned char des_ciphertext[]
Definition: crypt_lmhash.c:395

Referenced by START_TEST().

◆ test_SystemFunction_enc32()

static void test_SystemFunction_enc32 ( descrypt  func,
int  num 
)
static

Definition at line 448 of file crypt_lmhash.c.

449{
450 unsigned char key[4], output[0x11];
451 int r;
452
453 if (!func)
454 {
455 win_skip("SystemFunction%03d is not available\n", num);
456 return;
457 }
458
459 memset(output, 0, sizeof output);
460
461 /* two keys are generated using 4 bytes, repeated 4 times ... */
462 memcpy(key, "foo", 4);
463
464 r = func(des_plaintext, key, output);
465 ok( r == STATUS_SUCCESS, "wrong error code (%d)\n", num);
466
467 ok( !memcmp( output, des_ciphertext32, sizeof des_ciphertext32), "ciphertext wrong (%d)\n", num);
468}

Referenced by START_TEST().

◆ test_SystemFunction_encrypt()

static void test_SystemFunction_encrypt ( descrypt  func,
int  num 
)
static

Definition at line 401 of file crypt_lmhash.c.

402{
403 unsigned char output[0x11];
404 int r;
405
406 if (!func)
407 {
408 win_skip("SystemFunction%03d is not available\n", num);
409 return;
410 }
411
412 r = func(NULL, NULL, NULL);
413 ok( r == STATUS_UNSUCCESSFUL, "wrong error code\n");
414
415 memset(output, 0, sizeof output);
416 r = func(des_plaintext, des_key, output);
417 ok( r == STATUS_SUCCESS, "wrong error code\n");
418 ok( !memcmp(des_ciphertext, output, sizeof des_ciphertext), "ciphertext wrong (%d)\n", num);
419}

Referenced by START_TEST().

◆ VOID()

static const struct ustring struct ustring *static const struct ustring struct ustring *static VOID ( WINAPI pSystemFunction006)
static

Variable Documentation

◆ des_ciphertext

unsigned char des_ciphertext[]
static
Initial value:
= {
0xc3, 0x37, 0xcd, 0x5c, 0xbd, 0x44, 0xfc, 0x97,
0xc3, 0x37, 0xcd, 0x5c, 0xbd, 0x44, 0xfc, 0x97, 0
}

Definition at line 395 of file crypt_lmhash.c.

Referenced by test_SystemFunction_decrypt(), and test_SystemFunction_encrypt().

◆ des_ciphertext32

unsigned char des_ciphertext32[]
static
Initial value:
= {
0x69, 0x51, 0x35, 0x69, 0x0d, 0x29, 0x24, 0xad,
0x23, 0x6d, 0xfd, 0x43, 0x0d, 0xd3, 0x25, 0x81, 0
}

Definition at line 443 of file crypt_lmhash.c.

Referenced by test_SystemFunction_dec32(), and test_SystemFunction_enc32().

◆ des_key

unsigned char des_key[]
static
Initial value:
= {
0xff, 0x37, 0x50, 0xbc, 0xc2, 0xb2, 0x24,
0xff, 0x37, 0x50, 0xbc, 0xc2, 0xb2, 0x24,
}

Definition at line 387 of file crypt_lmhash.c.

◆ des_plaintext

unsigned char des_plaintext[]
static
Initial value:
= {
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0
}

Definition at line 391 of file crypt_lmhash.c.

Referenced by test_SystemFunction_dec32(), test_SystemFunction_decrypt(), test_SystemFunction_enc32(), and test_SystemFunction_encrypt().

◆ lmhash

Definition at line 43 of file crypt_lmhash.c.

Referenced by test_SystemFunction006().

◆ LPBYTE

Definition at line 38 of file crypt_lmhash.c.

◆ pSystemFunction012

const struct ustring* static descrypt pSystemFunction012
static

Definition at line 49 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction013

descrypt pSystemFunction013
static

Definition at line 57 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction014

descrypt pSystemFunction014
static

Definition at line 50 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction015

descrypt pSystemFunction015
static

Definition at line 58 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction016

descrypt pSystemFunction016
static

Definition at line 51 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction017

descrypt pSystemFunction017
static

Definition at line 59 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction018

descrypt pSystemFunction018
static

Definition at line 52 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction019

descrypt pSystemFunction019
static

Definition at line 60 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction020

descrypt pSystemFunction020
static

Definition at line 53 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction021

descrypt pSystemFunction021
static

Definition at line 61 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction022

descrypt pSystemFunction022
static

Definition at line 54 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction023

descrypt pSystemFunction023
static

Definition at line 62 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction024

descrypt pSystemFunction024
static

Definition at line 65 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction025

descrypt pSystemFunction025
static

Definition at line 66 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction026

descrypt pSystemFunction026
static

Definition at line 69 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction027

descrypt pSystemFunction027
static

Definition at line 70 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction030

memcmpfunc pSystemFunction030
static

Definition at line 73 of file crypt_lmhash.c.

Referenced by START_TEST().

◆ pSystemFunction031

memcmpfunc pSystemFunction031
static

Definition at line 74 of file crypt_lmhash.c.

Referenced by START_TEST().