xref: /reactos/drivers/crypto/ksecdd/ksecdd.h (revision c2c66aff)
1 /*
2  * PROJECT:         ReactOS Drivers
3  * COPYRIGHT:       See COPYING in the top level directory
4  * PURPOSE:         Kernel Security Support Provider Interface Driver
5  *
6  * PROGRAMMERS:     Timo Kreuzer (timo.kreuzer@reactos.org)
7  */
8 
9 #define _NO_KSECDD_IMPORT_
10 #include <ntifs.h>
11 #include <ndk/exfuncs.h>
12 #include <ndk/ketypes.h>
13 #include <pseh/pseh2.h>
14 #include <ntstrsafe.h>
15 
16 #include <md4.h>
17 #include <md5.h>
18 #include <tomcrypt.h>
19 typedef aes_key AES_KEY, *PAES_KEY;
20 typedef des3_key DES3_KEY, *PDES3_KEY;
21 
22 #define STATUS_KSEC_INTERNAL_ERROR ((NTSTATUS)0x80090304)
23 
24 /* FIXME: this should be in some shared header */
25 #define RTL_ENCRYPT_OPTION_SAME_PROCESS   0
26 #define RTL_ENCRYPT_OPTION_CROSS_PROCESS  1
27 #define RTL_ENCRYPT_OPTION_SAME_LOGON     2
28 
29 typedef struct _KSEC_CONNECTION_INFO
30 {
31     ULONG Unknown0;
32     NTSTATUS Status;
33     ULONG_PTR Information;
34     CHAR ConnectionString[128];
35     ULONG Flags;
36 } KSEC_CONNECTION_INFO;
37 
38 #if defined(_M_IX86) || defined(_M_AMD64)
39 typedef struct _KSEC_MACHINE_SPECIFIC_COUNTERS
40 {
41     ULONG64 Tsc;
42     ULONG64 Pmc0;
43     ULONG64 Pmc1;
44     ULONG64 Ctr0;
45     ULONG64 Ctr1;
46 } KSEC_MACHINE_SPECIFIC_COUNTERS, *PKSEC_MACHINE_SPECIFIC_COUNTERS;
47 #elif defined(_M_ARM)
48 typedef struct _KSEC_MACHINE_SPECIFIC_COUNTERS
49 {
50     ULONG Ccr;
51 } KSEC_MACHINE_SPECIFIC_COUNTERS, *PKSEC_MACHINE_SPECIFIC_COUNTERS;
52 #else
53 typedef ULONG KSEC_MACHINE_SPECIFIC_COUNTERS, *PKSEC_MACHINE_SPECIFIC_COUNTERS;
54 #endif
55 
56 typedef struct _KSEC_ENTROPY_DATA
57 {
58     HANDLE CurrentProcessId;
59     HANDLE CurrentThreadId;
60     LARGE_INTEGER TickCount;
61     LARGE_INTEGER SystemTime;
62     LARGE_INTEGER PerformanceCounter;
63     LARGE_INTEGER PerformanceFrequency;
64     UCHAR EnvironmentHash[16];
65     KSEC_MACHINE_SPECIFIC_COUNTERS MachineSpecificCounters;
66     SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SystemProcessorPerformanceInformation;
67     SYSTEM_PERFORMANCE_INFORMATION SystemPerformanceInformation;
68     SYSTEM_EXCEPTION_INFORMATION SystemExceptionInformation;
69     SYSTEM_LOOKASIDE_INFORMATION SystemLookasideInformation;
70     SYSTEM_INTERRUPT_INFORMATION SystemInterruptInformation;
71     SYSTEM_PROCESS_INFORMATION SystemProcessInformation;
72 } KSEC_ENTROPY_DATA, *PKSEC_ENTROPY_DATA;
73 
74 extern PEPROCESS KsecLsaProcess;
75 extern HANDLE KsecLsaProcessHandle;
76 
77 NTSTATUS
78 NTAPI
79 KsecDdDispatch(
80     PDEVICE_OBJECT DeviceObject,
81     PIRP Irp);
82 
83 NTSTATUS
84 NTAPI
85 KsecGatherEntropyData(
86     PKSEC_ENTROPY_DATA EntropyData);
87 
88 NTSTATUS
89 NTAPI
90 KsecGenRandom(
91     PVOID Buffer,
92     SIZE_T Length);
93 
94 VOID
95 NTAPI
96 KsecInitializeEncryptionSupport (
97     VOID);
98 
99 NTSTATUS
100 NTAPI
101 KsecEncryptMemory (
102     _Inout_ PVOID Buffer,
103     _In_ ULONG Length,
104     _In_ ULONG OptionFlags);
105 
106 NTSTATUS
107 NTAPI
108 KsecDecryptMemory (
109     _Inout_ PVOID Buffer,
110     _In_ ULONG Length,
111     _In_ ULONG OptionFlags);
112 
113