ReactOS 0.4.15-dev-7924-g5949c20
sysfunc.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: dll/win32/advapi32/misc/sysfunc.c
5 * PURPOSE: advapi32.dll system functions (undocumented)
6 * PROGRAMMER: Emanuele Aliberti
7 * UPDATE HISTORY:
8 * 19990413 EA created
9 * 19990415 EA
10 * 20080424 Ported from WINE
11 */
12
13#include <advapi32.h>
14#include <ntsecapi.h>
15#include <ksecioctl.h>
16#include <md4.h>
17#include <md5.h>
18#include <rc4.h>
19
20static const unsigned char CRYPT_LMhash_Magic[8] =
21 { 'K', 'G', 'S', '!', '@', '#', '$', '%' };
22static const unsigned char DefaultSessionKey[16] =
23 {'D', 'e', 'f', 'S', 'e', 's', 's', 'i', 'o', 'n', 'K', 'e', 'y', '!', '@', '#'};
24
25/******************************************************************************
26 * SystemFunction001 [ADVAPI32.@]
27 *
28 * Encrypts a single block of data using DES
29 *
30 * PARAMS
31 * data [I] data to encrypt (8 bytes)
32 * key [I] key data (7 bytes)
33 * output [O] the encrypted data (8 bytes)
34 *
35 * RETURNS
36 * Success: STATUS_SUCCESS
37 * Failure: STATUS_UNSUCCESSFUL
38 *
39 */
42{
43 if (!data || !output)
45 CRYPT_DEShash(output, key, data);
46 return STATUS_SUCCESS;
47}
48
49
50/******************************************************************************
51 * SystemFunction002 [ADVAPI32.@]
52 *
53 * Decrypts a single block of data using DES
54 *
55 * PARAMS
56 * data [I] data to decrypt (8 bytes)
57 * key [I] key data (7 bytes)
58 * output [O] the decrypted data (8 bytes)
59 *
60 * RETURNS
61 * Success: STATUS_SUCCESS
62 * Failure: STATUS_UNSUCCESSFUL
63 *
64 */
67{
68 if (!data || !output)
70 CRYPT_DESunhash(output, key, data);
71 return STATUS_SUCCESS;
72}
73
74
75/******************************************************************************
76 * SystemFunction003 [ADVAPI32.@]
77 *
78 * Hashes a key using DES and a fixed datablock
79 *
80 * PARAMS
81 * key [I] key data (7 bytes)
82 * output [O] hashed key (8 bytes)
83 *
84 * RETURNS
85 * Success: STATUS_SUCCESS
86 * Failure: STATUS_UNSUCCESSFUL
87 *
88 */
91{
92 if (!output)
95 return STATUS_SUCCESS;
96}
97
98
99/******************************************************************************
100 * SystemFunction004 [ADVAPI32.@]
101 *
102 * Encrypts a block of data with DES in ECB mode, preserving the length
103 *
104 * PARAMS
105 * data [I] data to encrypt
106 * key [I] key data (up to 7 bytes)
107 * output [O] buffer to receive encrypted data
108 *
109 * RETURNS
110 * Success: STATUS_SUCCESS
111 * Failure: STATUS_BUFFER_TOO_SMALL if the output buffer is too small
112 * Failure: STATUS_INVALID_PARAMETER_2 if the key is zero length
113 *
114 * NOTES
115 * Encrypt buffer size should be input size rounded up to 8 bytes
116 * plus an extra 8 bytes.
117 */
120 const struct ustring *key,
121 struct ustring *out)
122{
123 union {
124 unsigned char uc[8];
125 unsigned int ui[2];
126 } data;
127 unsigned char deskey[7];
128 unsigned int crypt_len, ofs;
129
130 if (key->Length<=0)
132
133 crypt_len = ((in->Length+7)&~7);
134 if (out->MaximumLength < (crypt_len+8))
135 {
136 out->Length = crypt_len + 8;
138 }
139
140 data.ui[0] = in->Length;
141 data.ui[1] = 1;
142
143 if (key->Length<sizeof deskey)
144 {
145 memset(deskey, 0, sizeof deskey);
146 memcpy(deskey, key->Buffer, key->Length);
147 }
148 else
149 memcpy(deskey, key->Buffer, sizeof deskey);
150
151 CRYPT_DEShash(out->Buffer, deskey, data.uc);
152
153 for(ofs=0; ofs<(crypt_len-8); ofs+=8)
154 CRYPT_DEShash(out->Buffer+8+ofs, deskey, in->Buffer+ofs);
155
156 memset(data.uc, 0, sizeof data.uc);
157 memcpy(data.uc, in->Buffer+ofs, in->Length +8-crypt_len);
158 CRYPT_DEShash(out->Buffer+8+ofs, deskey, data.uc);
159
160 out->Length = crypt_len+8;
161
162 return STATUS_SUCCESS;
163}
164
165/******************************************************************************
166 * SystemFunction005 [ADVAPI32.@]
167 *
168 * Decrypts a block of data with DES in ECB mode
169 *
170 * PARAMS
171 * data [I] data to decrypt
172 * key [I] key data (up to 7 bytes)
173 * output [O] buffer to receive decrypted data
174 *
175 * RETURNS
176 * Success: STATUS_SUCCESS
177 * Failure: STATUS_BUFFER_TOO_SMALL if the output buffer is too small
178 * Failure: STATUS_INVALID_PARAMETER_2 if the key is zero length
179 *
180 */
183 const struct ustring *key,
184 struct ustring *out)
185{
186 union {
187 unsigned char uc[8];
188 unsigned int ui[2];
189 } data;
190 unsigned char deskey[7];
191 unsigned int ofs, crypt_len;
192
193 if (key->Length<=0)
195
196 if (key->Length<sizeof deskey)
197 {
198 memset(deskey, 0, sizeof deskey);
199 memcpy(deskey, key->Buffer, key->Length);
200 }
201 else
202 memcpy(deskey, key->Buffer, sizeof deskey);
203
204 CRYPT_DESunhash(data.uc, deskey, in->Buffer);
205
206 if (data.ui[1] != 1)
208
209 crypt_len = data.ui[0];
210 if (crypt_len > out->MaximumLength)
211 {
212 out->Length = crypt_len;
214 }
215
216 for (ofs=0; (ofs+8)<crypt_len; ofs+=8)
217 CRYPT_DESunhash(out->Buffer+ofs, deskey, in->Buffer+ofs+8);
218
219 if (ofs<crypt_len)
220 {
221 CRYPT_DESunhash(data.uc, deskey, in->Buffer+ofs+8);
222 memcpy(out->Buffer+ofs, data.uc, crypt_len-ofs);
223 }
224
225 out->Length = crypt_len;
226
227 return STATUS_SUCCESS;
228}
229
230/******************************************************************************
231 * SystemFunction007 [ADVAPI32.@]
232 *
233 * MD4 hash a unicode string
234 *
235 * PARAMS
236 * string [I] the string to hash
237 * output [O] the md4 hash of the string (16 bytes)
238 *
239 * RETURNS
240 * Success: STATUS_SUCCESS
241 * Failure: STATUS_UNSUCCESSFUL
242 *
243 */
246{
247 MD4_CTX ctx;
248
249 MD4Init( &ctx );
250 MD4Update( &ctx, (const BYTE *)string->Buffer, string->Length );
251 MD4Final( &ctx );
252 memcpy( hash, ctx.digest, 0x10 );
253
254 return STATUS_SUCCESS;
255}
256
257/******************************************************************************
258 * SystemFunction008 [ADVAPI32.@]
259 *
260 * Creates a LM response from a challenge and a password hash
261 *
262 * PARAMS
263 * challenge [I] Challenge from authentication server
264 * hash [I] NTLM hash (from SystemFunction006)
265 * response [O] response to send back to the server
266 *
267 * RETURNS
268 * Success: STATUS_SUCCESS
269 * Failure: STATUS_UNSUCCESSFUL
270 *
271 * NOTES
272 * see http://davenport.sourceforge.net/ntlm.html#theLmResponse
273 *
274 */
276WINAPI SystemFunction008(const BYTE *challenge, const BYTE *hash, LPBYTE response)
277{
278 BYTE key[7*3];
279
280 if (!challenge || !response)
281 return STATUS_UNSUCCESSFUL;
282
283 memset(key, 0, sizeof key);
284 memcpy(key, hash, 0x10);
285
286 CRYPT_DEShash(response, key, challenge);
287 CRYPT_DEShash(response+8, key+7, challenge);
288 CRYPT_DEShash(response+16, key+14, challenge);
289
290 return STATUS_SUCCESS;
291}
292
293/******************************************************************************
294 * SystemFunction009 [ADVAPI32.@]
295 *
296 * Seems to do the same as SystemFunction008...
297 */
299WINAPI SystemFunction009(const BYTE *challenge, const BYTE *hash, LPBYTE response)
300{
301 return SystemFunction008(challenge, hash, response);
302}
303
304/******************************************************************************
305 * SystemFunction010 [ADVAPI32.@]
306 * SystemFunction011 [ADVAPI32.@]
307 *
308 * MD4 hashes 16 bytes of data
309 *
310 * PARAMS
311 * unknown [] seems to have no effect on the output
312 * data [I] pointer to data to hash (16 bytes)
313 * output [O] the md4 hash of the data (16 bytes)
314 *
315 * RETURNS
316 * Success: STATUS_SUCCESS
317 * Failure: STATUS_UNSUCCESSFUL
318 *
319 */
322{
323 MD4_CTX ctx;
324
325 MD4Init( &ctx );
326 MD4Update( &ctx, data, 0x10 );
327 MD4Final( &ctx );
328 memcpy( hash, ctx.digest, 0x10 );
329
330 return STATUS_SUCCESS;
331}
332
333/******************************************************************************
334 * SystemFunction012 [ADVAPI32.@]
335 * SystemFunction014 [ADVAPI32.@]
336 * SystemFunction016 [ADVAPI32.@]
337 * SystemFunction018 [ADVAPI32.@]
338 * SystemFunction020 [ADVAPI32.@]
339 * SystemFunction022 [ADVAPI32.@]
340 *
341 * Encrypts two DES blocks with two keys
342 *
343 * PARAMS
344 * data [I] data to encrypt (16 bytes)
345 * key [I] key data (two lots of 7 bytes)
346 * output [O] buffer to receive encrypted data (16 bytes)
347 *
348 * RETURNS
349 * Success: STATUS_SUCCESS
350 * Failure: STATUS_UNSUCCESSFUL if the input or output buffer is NULL
351 */
354{
355 if (!in || !out)
356 return STATUS_UNSUCCESSFUL;
357
359 CRYPT_DEShash(out+8, key+7, in+8);
360 return STATUS_SUCCESS;
361}
362
363/******************************************************************************
364 * SystemFunction013 [ADVAPI32.@]
365 * SystemFunction015 [ADVAPI32.@]
366 * SystemFunction017 [ADVAPI32.@]
367 * SystemFunction019 [ADVAPI32.@]
368 * SystemFunction021 [ADVAPI32.@]
369 * SystemFunction023 [ADVAPI32.@]
370 *
371 * Decrypts two DES blocks with two keys
372 *
373 * PARAMS
374 * data [I] data to decrypt (16 bytes)
375 * key [I] key data (two lots of 7 bytes)
376 * output [O] buffer to receive decrypted data (16 bytes)
377 *
378 * RETURNS
379 * Success: STATUS_SUCCESS
380 * Failure: STATUS_UNSUCCESSFUL if the input or output buffer is NULL
381 */
384{
385 if (!in || !out)
386 return STATUS_UNSUCCESSFUL;
388 CRYPT_DESunhash(out+8, key+7, in+8);
389 return STATUS_SUCCESS;
390}
391
392/******************************************************************************
393 * SystemFunction024 [ADVAPI32.@]
394 *
395 * Encrypts two DES blocks with a 32 bit key...
396 *
397 * PARAMS
398 * data [I] data to encrypt (16 bytes)
399 * key [I] key data (4 bytes)
400 * output [O] buffer to receive encrypted data (16 bytes)
401 *
402 * RETURNS
403 * Success: STATUS_SUCCESS
404 */
407{
408 BYTE deskey[0x10];
409
410 memcpy(deskey, key, 4);
411 memcpy(deskey+4, key, 4);
412 memcpy(deskey+8, key, 4);
413 memcpy(deskey+12, key, 4);
414
416 CRYPT_DEShash(out+8, deskey+7, in+8);
417
418 return STATUS_SUCCESS;
419}
420
421/******************************************************************************
422 * SystemFunction025 [ADVAPI32.@]
423 *
424 * Decrypts two DES blocks with a 32 bit key...
425 *
426 * PARAMS
427 * data [I] data to encrypt (16 bytes)
428 * key [I] key data (4 bytes)
429 * output [O] buffer to receive encrypted data (16 bytes)
430 *
431 * RETURNS
432 * Success: STATUS_SUCCESS
433 */
436{
437 BYTE deskey[0x10];
438
439 memcpy(deskey, key, 4);
440 memcpy(deskey+4, key, 4);
441 memcpy(deskey+8, key, 4);
442 memcpy(deskey+12, key, 4);
443
445 CRYPT_DESunhash(out+8, deskey+7, in+8);
446
447 return STATUS_SUCCESS;
448}
449
450/**********************************************************************
451 * SystemFunction028 [ADVAPI32.@]
452 *
453 * Retrieves an encryption session key...
454 *
455 * PARAMS
456 * ContextHandle [I] RPC context handle
457 * SessionKey [O] buffer to receive the session key (16 bytes)
458 *
459 * RETURNS
460 * Success: STATUS_LOCAL_USER_SESSION_KEY
461 *
462 * @unimplemented
463 */
465WINAPI
467 _In_ PVOID ContextHandle,
468 _Out_ LPBYTE SessionKey)
469{
470 /* HACK: Always return the default key */
471 memcpy(SessionKey, DefaultSessionKey, sizeof(DefaultSessionKey));
473
474#if 0
475 //NDRCContextBinding();
476 //SystemFunction034()
478 return 28;
479#endif
480}
481
482
483/**********************************************************************
484 *
485 * @unimplemented
486 */
487INT
488WINAPI
490{
491 //I_RpcBindingIsClientLocal()
493 return 29;
494}
495
496
497/******************************************************************************
498 * SystemFunction030 (ADVAPI32.@)
499 *
500 * Tests if two blocks of 16 bytes are equal
501 *
502 * PARAMS
503 * b1,b2 [I] block of 16 bytes
504 *
505 * RETURNS
506 * TRUE if blocks are the same
507 * FALSE if blocks are different
508 */
509BOOL
511{
512 return !memcmp(b1, b2, 0x10);
513}
514
515
516/******************************************************************************
517 * SystemFunction032 [ADVAPI32.@]
518 *
519 * Encrypts a string data using ARC4
520 *
521 * PARAMS
522 * data [I/O] data to encrypt
523 * key [I] key data
524 *
525 * RETURNS
526 * Success: STATUS_SUCCESS
527 * Failure: STATUS_UNSUCCESSFUL
528 *
529 * NOTES
530 * see http://web.it.kth.se/~rom/ntsec.html#crypto-strongavail
531 */
534{
535 RC4_CONTEXT a4i;
536
537 rc4_init(&a4i, key->Buffer, key->Length);
538 rc4_crypt(&a4i, data->Buffer, data->Length);
539
540 return STATUS_SUCCESS;
541}
542
543
544/**********************************************************************
545 *
546 * @unimplemented
547 */
548INT
549WINAPI
551{
553 return 33;
554}
555
556/**********************************************************************
557 *
558 * @unimplemented
559 */
560INT
561WINAPI
563{
564 //RpcBindingToStringBindingW
565 //I_RpcMapWin32Status
566 //RpcStringBindingParseW
567 //RpcStringFreeW
569 return 34;
570}
571
572
573/******************************************************************************
574 * SystemFunction035 (ADVAPI32.@)
575 *
576 * Described here:
577http://disc.server.com/discussion.cgi?disc=148775;article=942;title=Coding%2FASM%2FSystem
578 *
579 * NOTES
580 * Stub, always return TRUE.
581 */
583{
584 //FIXME("%s: stub\n", debugstr_a(lpszDllFilePath));
585 return TRUE;
586}
587
588/******************************************************************************
589 * SystemFunction036 (ADVAPI32.@)
590 *
591 * MSDN documents this function as RtlGenRandom and declares it in ntsecapi.h
592 *
593 * PARAMS
594 * pbBuffer [O] Pointer to memory to receive random bytes.
595 * dwLen [I] Number of random bytes to fetch.
596 *
597 * RETURNS
598 * Always TRUE in my tests
599 */
601WINAPI
603{
606 // This function will output numbers based on the tick count. //
607 // It will NOT OUTPUT CRYPTOGRAPHIC-SAFE RANDOM NUMBERS !!! //
609
610 DWORD dwSeed;
612 ULONG uPseudoRandom;
614 static ULONG uCounter = 17;
615
616 if(!pbBuffer || !dwLen)
617 {
618 /* This function always returns TRUE, even if invalid parameters were passed. (verified under WinXP SP2) */
619 return TRUE;
620 }
621
622 /* Get the first seed from the performance counter */
624 dwSeed = time.LowPart ^ time.HighPart ^ RtlUlongByteSwap(uCounter++);
625
626 /* We will access the buffer bytewise */
627 pBuffer = (PBYTE)pbBuffer;
628
629 do
630 {
631 /* Use the pseudo random number generator RtlRandom, which outputs a 4-byte value and a new seed */
632 uPseudoRandom = RtlRandom(&dwSeed);
633
634 do
635 {
636 /* Get each byte from the pseudo random number and store it in the buffer */
637 *pBuffer = (BYTE)(uPseudoRandom >> 8 * (dwLen % 3) & 0xFF);
638 ++pBuffer;
639 } while(--dwLen % 3);
640 } while(dwLen);
641
642 return TRUE;
643}
644
646
647static
650{
651 UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\KsecDD");
656
658 &DeviceName,
660 NULL,
661 NULL);
668 if (!NT_SUCCESS(Status))
669 {
670 return Status;
671 }
672
674 {
676 }
677
678 return STATUS_SUCCESS;
679}
680
681VOID
683{
684 /* Check if we already opened a handle to ksecdd */
685 if (KsecDeviceHandle != NULL)
686 {
687 /* Close it */
690 }
691}
692
693static
701{
704
705 /* Check if we already have a handle */
706 if (KsecDeviceHandle == NULL)
707 {
708 /* Try to open the device */
710 if (!NT_SUCCESS(Status))
711 {
712 //ERR("Failed to open handle to KsecDd driver!\n");
713 return Status;
714 }
715 }
716
717 /* Call the driver */
719 NULL,
720 NULL,
721 NULL,
728
729 return Status;
730}
731
732/*
733 These functions have nearly identical prototypes to CryptProtectMemory and CryptUnprotectMemory,
734 in crypt32.dll.
735 */
736
737/******************************************************************************
738 * SystemFunction040 (ADVAPI32.@)
739 *
740 * MSDN documents this function as RtlEncryptMemory and declares it in ntsecapi.h.
741 *
742 * PARAMS
743 * memory [I/O] Pointer to memory to encrypt.
744 * length [I] Length of region to encrypt in bytes.
745 * flags [I] Control whether other processes are able to decrypt the memory.
746 * RTL_ENCRYPT_OPTION_SAME_PROCESS
747 * RTL_ENCRYPT_OPTION_CROSS_PROCESS
748 * RTL_ENCRYPT_OPTION_SAME_LOGON
749 *
750 * RETURNS
751 * Success: STATUS_SUCCESS
752 * Failure: NTSTATUS error code
753 *
754 * NOTES
755 * length must be a multiple of RTL_ENCRYPT_MEMORY_SIZE.
756 * If flags are specified when encrypting, the same flag value must be given
757 * when decrypting the memory.
758 */
760WINAPI
763 _In_ ULONG MemoryLength,
764 _In_ ULONG OptionFlags)
765{
767
768 if (OptionFlags == RTL_ENCRYPT_OPTION_SAME_PROCESS)
769 {
771 }
772 else if (OptionFlags == RTL_ENCRYPT_OPTION_CROSS_PROCESS)
773 {
775 }
776 else if (OptionFlags == RTL_ENCRYPT_OPTION_SAME_LOGON)
777 {
779 }
780 else
781 {
783 }
784
785 return KsecDeviceIoControl(IoControlCode, Memory, MemoryLength, Memory, MemoryLength);
786}
787
788/******************************************************************************
789 * SystemFunction041 (ADVAPI32.@)
790 *
791 * MSDN documents this function as RtlDecryptMemory and declares it in ntsecapi.h.
792 *
793 * PARAMS
794 * memory [I/O] Pointer to memory to decrypt.
795 * length [I] Length of region to decrypt in bytes.
796 * flags [I] Control whether other processes are able to decrypt the memory.
797 * RTL_ENCRYPT_OPTION_SAME_PROCESS
798 * RTL_ENCRYPT_OPTION_CROSS_PROCESS
799 * RTL_ENCRYPT_OPTION_SAME_LOGON
800 *
801 * RETURNS
802 * Success: STATUS_SUCCESS
803 * Failure: NTSTATUS error code
804 *
805 * NOTES
806 * length must be a multiple of RTL_ENCRYPT_MEMORY_SIZE.
807 * If flags are specified when encrypting, the same flag value must be given
808 * when decrypting the memory.
809 */
811WINAPI
814 _In_ ULONG MemoryLength,
815 _In_ ULONG OptionFlags)
816{
818
819 if (OptionFlags == RTL_ENCRYPT_OPTION_SAME_PROCESS)
820 {
822 }
823 else if (OptionFlags == RTL_ENCRYPT_OPTION_CROSS_PROCESS)
824 {
826 }
827 else if (OptionFlags == RTL_ENCRYPT_OPTION_SAME_LOGON)
828 {
830 }
831 else
832 {
834 }
835
836 return KsecDeviceIoControl(IoControlCode, Memory, MemoryLength, Memory, MemoryLength);
837}
838
839/* EOF */
unsigned char BOOLEAN
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned char * CRYPT_DESunhash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:299
unsigned char * CRYPT_DEShash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:259
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605
#define CloseHandle
Definition: compat.h:739
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define RtlUlongByteSwap(_x)
Definition: compat.h:815
#define SetLastError(x)
Definition: compat.h:752
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI QueryPerformanceCounter(OUT PLARGE_INTEGER lpPerformanceCount)
Definition: perfcnt.c:23
static void deskey(const unsigned char *key, short edf, ulong32 *keyout)
Definition: des.c:1285
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
Status
Definition: gdiplustypes.h:25
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLuint in
Definition: glext.h:9616
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
VOID WINAPI MD4Final(MD4_CTX *ctx)
Definition: md4.c:113
VOID WINAPI MD4Update(MD4_CTX *ctx, const unsigned char *buf, unsigned int len)
Definition: md4.c:59
VOID WINAPI MD4Init(MD4_CTX *ctx)
Definition: md4.c:45
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
#define RTL_ENCRYPT_OPTION_SAME_LOGON
Definition: ksecdd.h:27
#define RTL_ENCRYPT_OPTION_SAME_PROCESS
Definition: ksecdd.h:25
#define RTL_ENCRYPT_OPTION_CROSS_PROCESS
Definition: ksecdd.h:26
#define IOCTL_KSEC_ENCRYPT_CROSS_PROCESS
Definition: ksecioctl.h:26
#define IOCTL_KSEC_DECRYPT_SAME_LOGON
Definition: ksecioctl.h:38
#define IOCTL_KSEC_DECRYPT_CROSS_PROCESS
Definition: ksecioctl.h:30
#define IOCTL_KSEC_ENCRYPT_SAME_PROCESS
Definition: ksecioctl.h:18
#define IOCTL_KSEC_ENCRYPT_SAME_LOGON
Definition: ksecioctl.h:34
#define IOCTL_KSEC_DECRYPT_SAME_PROCESS
Definition: ksecioctl.h:22
__u16 time
Definition: mkdosfs.c:8
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582
static CRYPT_DATA_BLOB b1[]
Definition: msg.c:573
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define _Inout_
Definition: ms_sal.h:378
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
NTSYSAPI ULONG NTAPI RtlRandom(_Inout_ PULONG Seed)
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3952
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_READ_DATA
Definition: nt_native.h:628
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define STATUS_UNKNOWN_REVISION
Definition: ntstatus.h:324
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
#define STATUS_LOCAL_USER_SESSION_KEY
Definition: ntstatus.h:120
#define L(x)
Definition: ntvdm.h:50
UINT ui
Definition: oleauto.h:49
BYTE * PBYTE
Definition: pedump.c:66
PVOID pBuffer
static FILE * out
Definition: regtests2xml.c:44
void rc4_init(RC4_CONTEXT *a4i, const unsigned char *key, unsigned int keyLen)
Definition: rc4.c:25
void rc4_crypt(RC4_CONTEXT *a4i, unsigned char *inoutString, unsigned int length)
Definition: rc4.c:47
#define memset(x, y, z)
Definition: compat.h:39
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
Definition: util.c:82
Definition: _hash_fun.h:40
Definition: copy.c:22
Definition: config.c:19
HANDLE KsecDeviceHandle
Definition: sysfunc.c:645
NTSTATUS WINAPI SystemFunction012(const BYTE *in, const BYTE *key, LPBYTE out)
Definition: sysfunc.c:353
BOOL WINAPI SystemFunction035(LPCSTR lpszDllFilePath)
Definition: sysfunc.c:582
static const unsigned char DefaultSessionKey[16]
Definition: sysfunc.c:22
INT WINAPI SystemFunction034(INT a, INT b)
Definition: sysfunc.c:562
NTSTATUS WINAPI SystemFunction040(_Inout_ PVOID Memory, _In_ ULONG MemoryLength, _In_ ULONG OptionFlags)
Definition: sysfunc.c:761
static NTSTATUS KsecDeviceIoControl(ULONG IoControlCode, PVOID InputBuffer, SIZE_T InputBufferLength, PVOID OutputBuffer, SIZE_T OutputBufferLength)
Definition: sysfunc.c:695
INT WINAPI SystemFunction029(INT a, INT b)
Definition: sysfunc.c:489
VOID CloseKsecDdHandle(VOID)
Definition: sysfunc.c:682
NTSTATUS WINAPI SystemFunction024(const BYTE *in, const BYTE *key, LPBYTE out)
Definition: sysfunc.c:406
NTSTATUS WINAPI SystemFunction041(_Inout_ PVOID Memory, _In_ ULONG MemoryLength, _In_ ULONG OptionFlags)
Definition: sysfunc.c:812
NTSTATUS WINAPI SystemFunction013(const BYTE *in, const BYTE *key, LPBYTE out)
Definition: sysfunc.c:383
NTSTATUS WINAPI SystemFunction010(LPVOID unknown, const BYTE *data, LPBYTE hash)
Definition: sysfunc.c:321
NTSTATUS WINAPI SystemFunction032(struct ustring *data, const struct ustring *key)
Definition: sysfunc.c:533
NTSTATUS WINAPI SystemFunction025(const BYTE *in, const BYTE *key, LPBYTE out)
Definition: sysfunc.c:435
INT WINAPI SystemFunction033(INT a, INT b)
Definition: sysfunc.c:550
static const unsigned char CRYPT_LMhash_Magic[8]
Definition: sysfunc.c:20
BOOL WINAPI SystemFunction030(LPCVOID b1, LPCVOID b2)
Definition: sysfunc.c:510
NTSTATUS WINAPI SystemFunction008(const BYTE *challenge, const BYTE *hash, LPBYTE response)
Definition: sysfunc.c:276
NTSTATUS WINAPI SystemFunction007(const UNICODE_STRING *string, LPBYTE hash)
Definition: sysfunc.c:245
NTSTATUS WINAPI SystemFunction001(const BYTE *data, const BYTE *key, LPBYTE output)
Definition: sysfunc.c:41
NTSTATUS WINAPI SystemFunction028(_In_ PVOID ContextHandle, _Out_ LPBYTE SessionKey)
Definition: sysfunc.c:466
NTSTATUS WINAPI SystemFunction005(const struct ustring *in, const struct ustring *key, struct ustring *out)
Definition: sysfunc.c:182
NTSTATUS WINAPI SystemFunction002(const BYTE *data, const BYTE *key, LPBYTE output)
Definition: sysfunc.c:66
NTSTATUS WINAPI SystemFunction004(const struct ustring *in, const struct ustring *key, struct ustring *out)
Definition: sysfunc.c:119
BOOLEAN WINAPI SystemFunction036(PVOID pbBuffer, ULONG dwLen)
Definition: sysfunc.c:602
NTSTATUS WINAPI SystemFunction009(const BYTE *challenge, const BYTE *hash, LPBYTE response)
Definition: sysfunc.c:299
static NTSTATUS KsecOpenDevice()
Definition: sysfunc.c:649
NTSTATUS WINAPI SystemFunction003(const BYTE *key, LPBYTE output)
Definition: sysfunc.c:90
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
unsigned char * LPBYTE
Definition: typedefs.h:53
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
Definition: wdfmemory.h:169
CONST void * LPCVOID
Definition: windef.h:191
#define WINAPI
Definition: msvc.h:6
const char * LPCSTR
Definition: xmlstorage.h:183
unsigned char BYTE
Definition: xxhash.c:193