ReactOS  0.4.14-dev-368-gfa26425
ksecdd.h File Reference
#include <ntifs.h>
#include <ndk/exfuncs.h>
#include <ndk/ketypes.h>
#include <pseh/pseh2.h>
#include <ntstrsafe.h>
#include <md4.h>
#include <md5.h>
#include <tomcrypt.h>
Include dependency graph for ksecdd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _KSEC_CONNECTION_INFO
 
struct  _KSEC_ENTROPY_DATA
 

Macros

#define _NO_KSECDD_IMPORT_
 
#define STATUS_KSEC_INTERNAL_ERROR   ((NTSTATUS)0x80090304)
 
#define RTL_ENCRYPT_OPTION_SAME_PROCESS   0
 
#define RTL_ENCRYPT_OPTION_CROSS_PROCESS   1
 
#define RTL_ENCRYPT_OPTION_SAME_LOGON   2
 

Typedefs

typedef aes_key AES_KEY
 
typedef aes_keyPAES_KEY
 
typedef des3_key DES3_KEY
 
typedef des3_keyPDES3_KEY
 
typedef struct _KSEC_CONNECTION_INFO KSEC_CONNECTION_INFO
 
typedef ULONG KSEC_MACHINE_SPECIFIC_COUNTERS
 
typedef ULONGPKSEC_MACHINE_SPECIFIC_COUNTERS
 
typedef struct _KSEC_ENTROPY_DATA KSEC_ENTROPY_DATA
 
typedef struct _KSEC_ENTROPY_DATAPKSEC_ENTROPY_DATA
 

Functions

NTSTATUS NTAPI KsecDdDispatch (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI KsecGatherEntropyData (PKSEC_ENTROPY_DATA EntropyData)
 
NTSTATUS NTAPI KsecGenRandom (PVOID Buffer, SIZE_T Length)
 
VOID NTAPI KsecInitializeEncryptionSupport (VOID)
 
NTSTATUS NTAPI KsecEncryptMemory (_Inout_ PVOID Buffer, _In_ ULONG Length, _In_ ULONG OptionFlags)
 
NTSTATUS NTAPI KsecDecryptMemory (_Inout_ PVOID Buffer, _In_ ULONG Length, _In_ ULONG OptionFlags)
 

Variables

PEPROCESS KsecLsaProcess
 
HANDLE KsecLsaProcessHandle
 

Macro Definition Documentation

◆ _NO_KSECDD_IMPORT_

#define _NO_KSECDD_IMPORT_

Definition at line 9 of file ksecdd.h.

◆ RTL_ENCRYPT_OPTION_CROSS_PROCESS

#define RTL_ENCRYPT_OPTION_CROSS_PROCESS   1

Definition at line 26 of file ksecdd.h.

◆ RTL_ENCRYPT_OPTION_SAME_LOGON

#define RTL_ENCRYPT_OPTION_SAME_LOGON   2

Definition at line 27 of file ksecdd.h.

◆ RTL_ENCRYPT_OPTION_SAME_PROCESS

#define RTL_ENCRYPT_OPTION_SAME_PROCESS   0

Definition at line 25 of file ksecdd.h.

◆ STATUS_KSEC_INTERNAL_ERROR

#define STATUS_KSEC_INTERNAL_ERROR   ((NTSTATUS)0x80090304)

Definition at line 22 of file ksecdd.h.

Typedef Documentation

◆ AES_KEY

typedef aes_key AES_KEY

Definition at line 19 of file ksecdd.h.

◆ DES3_KEY

typedef des3_key DES3_KEY

Definition at line 20 of file ksecdd.h.

◆ KSEC_CONNECTION_INFO

◆ KSEC_ENTROPY_DATA

◆ KSEC_MACHINE_SPECIFIC_COUNTERS

Definition at line 53 of file ksecdd.h.

◆ PAES_KEY

typedef aes_key * PAES_KEY

Definition at line 19 of file ksecdd.h.

◆ PDES3_KEY

typedef des3_key * PDES3_KEY

Definition at line 20 of file ksecdd.h.

◆ PKSEC_ENTROPY_DATA

◆ PKSEC_MACHINE_SPECIFIC_COUNTERS

Definition at line 53 of file ksecdd.h.

Function Documentation

◆ KsecDdDispatch()

NTSTATUS NTAPI KsecDdDispatch ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 184 of file dispatch.c.

187 {
188  PIO_STACK_LOCATION IoStackLocation;
191  PVOID Buffer;
192  SIZE_T InputLength, OutputLength;
193  FILE_INFORMATION_CLASS FileInfoClass;
194  FS_INFORMATION_CLASS FsInfoClass;
196 
197  IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
198 
199  switch (IoStackLocation->MajorFunction)
200  {
201  case IRP_MJ_CREATE:
202  case IRP_MJ_CLOSE:
203 
204  /* Just return success */
206  Information = 0;
207  break;
208 
209  case IRP_MJ_READ:
210 
211  /* There is nothing to read */
213  Information = 0;
214  break;
215 
216  case IRP_MJ_WRITE:
217 
218  /* Pretend to have written everything */
220  Information = IoStackLocation->Parameters.Write.Length;
221  break;
222 
224 
225  /* Extract the parameters */
226  Buffer = Irp->AssociatedIrp.SystemBuffer;
227  OutputLength = IoStackLocation->Parameters.QueryFile.Length;
228  FileInfoClass = IoStackLocation->Parameters.QueryFile.FileInformationClass;
229 
230  /* Call the internal function */
232  FileInfoClass,
233  &OutputLength);
234  Information = OutputLength;
235  break;
236 
238 
239  /* Extract the parameters */
240  Buffer = Irp->AssociatedIrp.SystemBuffer;
241  OutputLength = IoStackLocation->Parameters.QueryVolume.Length;
242  FsInfoClass = IoStackLocation->Parameters.QueryVolume.FsInformationClass;
243 
244  /* Call the internal function */
246  FsInfoClass,
247  &OutputLength);
248  Information = OutputLength;
249  break;
250 
252 
253  /* Extract the parameters */
254  InputLength = IoStackLocation->Parameters.DeviceIoControl.InputBufferLength;
255  OutputLength = IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength;
256  IoControlCode = IoStackLocation->Parameters.DeviceIoControl.IoControlCode;
257 
258  /* Check for METHOD_OUT_DIRECT method */
260  (OutputLength != 0))
261  {
262  /* Use the provided MDL */
263  OutputLength = Irp->MdlAddress->ByteCount;
266  if (Buffer == NULL)
267  {
269  Information = 0;
270  break;
271  }
272  }
273  else
274  {
275  /* Otherwise this is METHOD_BUFFERED, use the SystemBuffer */
276  Buffer = Irp->AssociatedIrp.SystemBuffer;
277  }
278 
279  /* Call the internal function */
281  Buffer,
282  InputLength,
283  &OutputLength);
284  Information = OutputLength;
285  break;
286 
287  default:
288  DPRINT1("Unhandled major function %lu!\n",
289  IoStackLocation->MajorFunction);
290  ASSERT(FALSE);
292  }
293 
294  /* Return the information */
295  Irp->IoStatus.Status = Status;
296  Irp->IoStatus.Information = Information;
297 
298  /* Complete the request */
300 
301  return Status;
302 }
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
#define METHOD_FROM_CTL_CODE(ctrlCode)
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
static NTSTATUS KsecQueryVolumeInformation(PVOID InfoBuffer, FS_INFORMATION_CLASS FsInformationClass, PSIZE_T BufferLength)
Definition: dispatch.c:56
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
#define STATUS_END_OF_FILE
Definition: shellext.h:67
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
Definition: bufpool.h:45
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
enum _FSINFOCLASS FS_INFORMATION_CLASS
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
#define METHOD_OUT_DIRECT
Definition: nt_native.h:596
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
ULONG_PTR SIZE_T
Definition: typedefs.h:78
static NTSTATUS KsecQueryFileInformation(PVOID InfoBuffer, FILE_INFORMATION_CLASS FileInformationClass, PSIZE_T BufferLength)
Definition: dispatch.c:22
#define DPRINT1
Definition: precomp.h:8
#define IRP_MJ_READ
Definition: rdpdr.c:46
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
static NTSTATUS KsecDeviceControl(ULONG IoControlCode, PVOID Buffer, SIZE_T InputLength, PSIZE_T OutputLength)
Definition: dispatch.c:87
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
Iosb Information
Definition: create.c:4377
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

Referenced by DriverEntry().

◆ KsecDecryptMemory()

NTSTATUS NTAPI KsecDecryptMemory ( _Inout_ PVOID  Buffer,
_In_ ULONG  Length,
_In_ ULONG  OptionFlags 
)

Definition at line 302 of file crypt.c.

306 {
307  /* Validate parameter */
308  if (OptionFlags > RTL_ENCRYPT_OPTION_SAME_LOGON)
309  {
311  }
312 
313  /* Check if the length is not 16 bytes aligned */
314  if (Length & 15)
315  {
316  /* Is it at least 8 bytes aligned? */
317  if (Length & 7)
318  {
319  /* No, we can't deal with it! */
321  }
322 
323  /* Use triple DES encryption */
324  KsecDecryptMemoryDes3(Buffer, Length, OptionFlags);
325  }
326  else
327  {
328  /* Use AES encryption */
329  KsecDecryptMemoryAes(Buffer, Length, OptionFlags);
330  }
331 
332  return STATUS_SUCCESS;
333 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static VOID KsecDecryptMemoryDes3(_Inout_ PVOID Buffer, _In_ ULONG Length, _In_ ULONG OptionFlags)
Definition: crypt.c:189
Definition: bufpool.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define RTL_ENCRYPT_OPTION_SAME_LOGON
Definition: ksecdd.h:27
static VOID KsecDecryptMemoryAes(_Inout_ PVOID Buffer, _In_ ULONG Length, _In_ ULONG OptionFlags)
Definition: crypt.c:241
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by KsecDeviceControl().

◆ KsecEncryptMemory()

NTSTATUS NTAPI KsecEncryptMemory ( _Inout_ PVOID  Buffer,
_In_ ULONG  Length,
_In_ ULONG  OptionFlags 
)

Definition at line 267 of file crypt.c.

271 {
272  /* Validate parameter */
273  if (OptionFlags > RTL_ENCRYPT_OPTION_SAME_LOGON)
274  {
276  }
277 
278  /* Check if the length is not 16 bytes aligned */
279  if (Length & 15)
280  {
281  /* Is it at least 8 bytes aligned? */
282  if (Length & 7)
283  {
284  /* No, we can't deal with it! */
286  }
287 
288  /* Use triple DES encryption */
289  KsecEncryptMemoryDes3(Buffer, Length, OptionFlags);
290  }
291  else
292  {
293  /* Use AES encryption */
294  KsecEncryptMemoryAes(Buffer, Length, OptionFlags);
295  }
296 
297  return STATUS_SUCCESS;
298 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static VOID KsecEncryptMemoryAes(_Inout_ PVOID Buffer, _In_ ULONG Length, _In_ ULONG OptionFlags)
Definition: crypt.c:215
Definition: bufpool.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define RTL_ENCRYPT_OPTION_SAME_LOGON
Definition: ksecdd.h:27
return STATUS_SUCCESS
Definition: btrfs.c:2938
static VOID KsecEncryptMemoryDes3(_Inout_ PVOID Buffer, _In_ ULONG Length, _In_ ULONG OptionFlags)
Definition: crypt.c:163

Referenced by KsecDeviceControl().

◆ KsecGatherEntropyData()

NTSTATUS NTAPI KsecGatherEntropyData ( PKSEC_ENTROPY_DATA  EntropyData)
See also
http://blogs.msdn.com/b/michael_howard/archive/2005/01/14/353379.aspx

Definition at line 92 of file random.c.

94 {
95  MD4_CTX Md4Context;
96  PTEB Teb;
97  PPEB Peb;
98  PWSTR String;
101 
102  /* Query some generic values */
103  EntropyData->CurrentProcessId = PsGetCurrentProcessId();
104  EntropyData->CurrentThreadId = PsGetCurrentThreadId();
105  KeQueryTickCount(&EntropyData->TickCount);
106  KeQuerySystemTime(&EntropyData->SystemTime);
108  &EntropyData->PerformanceFrequency);
109 
110  /* Check if we have a TEB/PEB for the process environment */
111  Teb = PsGetCurrentThread()->Tcb.Teb;
112  if (Teb != NULL)
113  {
115 
116  /* Initialize the MD4 context */
117  MD4Init(&Md4Context);
118  _SEH2_TRY
119  {
120  /* Get the end of the environment */
122  while (*String)
123  {
124  String += wcslen(String) + 1;
125  }
126 
127  /* Update the MD4 context from the environment data */
128  MD4Update(&Md4Context,
131  }
133  {
134  /* Simply ignore the exception */
135  }
136  _SEH2_END;
137 
138  /* Finalize and copy the MD4 hash */
139  MD4Final(&Md4Context);
140  RtlCopyMemory(&EntropyData->EnvironmentHash, Md4Context.digest, 16);
141  }
142 
143  /* Read some machine specific hardware counters */
145 
146  /* Query processor performance information */
150  &ReturnLength);
151  if (!NT_SUCCESS(Status))
152  {
153  return Status;
154  }
155 
156  /* Query system performance information */
158  &EntropyData->SystemPerformanceInformation,
160  &ReturnLength);
161  if (!NT_SUCCESS(Status))
162  {
163  return Status;
164  }
165 
166  /* Query exception information */
168  &EntropyData->SystemExceptionInformation,
170  &ReturnLength);
171  if (!NT_SUCCESS(Status))
172  {
173  return Status;
174  }
175 
176  /* Query lookaside information */
178  &EntropyData->SystemLookasideInformation,
180  &ReturnLength);
181  if (!NT_SUCCESS(Status))
182  {
183  return Status;
184  }
185 
186  /* Query interrupt information */
188  &EntropyData->SystemInterruptInformation,
190  &ReturnLength);
191  if (!NT_SUCCESS(Status))
192  {
193  return Status;
194  }
195 
196  /* Query process information */
198  &EntropyData->SystemProcessInformation,
200  &ReturnLength);
201  if (!NT_SUCCESS(Status))
202  {
203  return Status;
204  }
205 
206  return STATUS_SUCCESS;
207 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
unsigned char digest[16]
Definition: util.c:86
LARGE_INTEGER NTAPI KeQueryPerformanceCounter(IN PLARGE_INTEGER PerformanceFreq)
Definition: timer.c:138
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
PPEB Peb
Definition: dllmain.c:27
PPEB ProcessEnvironmentBlock
Definition: ntddk_ex.h:337
SYSTEM_PROCESS_INFORMATION SystemProcessInformation
Definition: ksecdd.h:71
SYSTEM_EXCEPTION_INFORMATION SystemExceptionInformation
Definition: ksecdd.h:68
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
uint16_t * PWSTR
Definition: typedefs.h:54
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
static WCHAR String[]
Definition: stringtable.c:55
_SEH2_TRY
Definition: create.c:4250
SYSTEM_PERFORMANCE_INFORMATION SystemPerformanceInformation
Definition: ksecdd.h:67
VOID WINAPI MD4Init(MD4_CTX *ctx)
Definition: md4.c:45
SYSTEM_INTERRUPT_INFORMATION SystemInterruptInformation
Definition: ksecdd.h:70
HANDLE CurrentProcessId
Definition: ksecdd.h:58
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
NTSYSAPI NTSTATUS NTAPI ZwQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
smooth NULL
Definition: ftsmooth.c:416
LARGE_INTEGER PerformanceFrequency
Definition: ksecdd.h:63
PsGetCurrentThreadId
Definition: CrNtStubs.h:7
#define SystemPerformanceInformation
Definition: memtest.h:87
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
UCHAR EnvironmentHash[16]
Definition: ksecdd.h:64
VOID NTAPI KsecReadMachineSpecificCounters(_Out_ PKSEC_MACHINE_SPECIFIC_COUNTERS MachineSpecificCounters)
Definition: random.c:56
LARGE_INTEGER SystemTime
Definition: ksecdd.h:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID WINAPI MD4Final(MD4_CTX *ctx)
Definition: md4.c:113
LARGE_INTEGER TickCount
Definition: ksecdd.h:60
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1890
Status
Definition: gdiplustypes.h:24
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SystemProcessorPerformanceInformation
Definition: ksecdd.h:66
Definition: compat.h:492
KSEC_MACHINE_SPECIFIC_COUNTERS MachineSpecificCounters
Definition: ksecdd.h:65
_SEH2_END
Definition: create.c:4424
Definition: util.c:81
SYSTEM_LOOKASIDE_INFORMATION SystemLookasideInformation
Definition: ksecdd.h:69
HANDLE NTAPI PsGetCurrentProcessId(VOID)
Definition: process.c:1123
unsigned int ULONG
Definition: retypes.h:1
VOID WINAPI MD4Update(MD4_CTX *ctx, const unsigned char *buf, unsigned int len)
Definition: md4.c:59
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
return STATUS_SUCCESS
Definition: btrfs.c:2938
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
HANDLE CurrentThreadId
Definition: ksecdd.h:59
LARGE_INTEGER PerformanceCounter
Definition: ksecdd.h:62

Referenced by KsecInitializeEncryptionSupport().

◆ KsecGenRandom()

NTSTATUS NTAPI KsecGenRandom ( PVOID  Buffer,
SIZE_T  Length 
)

Definition at line 26 of file random.c.

29 {
30  LARGE_INTEGER TickCount;
31  ULONG i, RandomValue;
32  PULONG P;
33 
34  /* Try to generate a more random seed */
35  KeQueryTickCount(&TickCount);
36  KsecRandomSeed ^= _rotl(TickCount.LowPart, (KsecRandomSeed % 23));
37 
38  P = Buffer;
39  for (i = 0; i < Length / sizeof(ULONG); i++)
40  {
42  }
43 
44  Length &= (sizeof(ULONG) - 1);
45  if (Length > 0)
46  {
47  RandomValue = RtlRandomEx(&KsecRandomSeed);
48  RtlCopyMemory(&P[i], &RandomValue, Length);
49  }
50 
51  return STATUS_SUCCESS;
52 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
ULONG NTAPI RtlRandomEx(IN OUT PULONG Seed)
Definition: random.c:150
static ULONG KsecRandomSeed
Definition: random.c:19
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ULONG LowPart
Definition: typedefs.h:104
#define P(row, col)
unsigned int * PULONG
Definition: retypes.h:1
_Check_return_ unsigned int __cdecl _rotl(_In_ unsigned int _Value, _In_ int _Shift)
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by KsecDeviceControl().

◆ KsecInitializeEncryptionSupport()

VOID NTAPI KsecInitializeEncryptionSupport ( VOID  )

Definition at line 32 of file crypt.c.

34 {
35  KSEC_ENTROPY_DATA EntropyData;
36  MD5_CTX Md5Context;
37  UCHAR KeyDataBuffer[32];
38 
39  KsecGatherEntropyData(&EntropyData);
40  MD5Init(&Md5Context);
41  MD5Update(&Md5Context, (PVOID)&EntropyData, sizeof(EntropyData));
42  KsecLoadTimeStartMd5s[0] = Md5Context;
43  MD5Final(&Md5Context);
44  RtlCopyMemory(KeyDataBuffer, &Md5Context.digest, 16);
45 
46  KsecGatherEntropyData(&EntropyData);
47  Md5Context = KsecLoadTimeStartMd5s[0];
48  MD5Update(&Md5Context, (PVOID)&EntropyData, sizeof(EntropyData));
49  KsecLoadTimeStartMd5s[1] = Md5Context;
50  MD5Final(&Md5Context);
51  RtlCopyMemory(&KeyDataBuffer[16], &Md5Context.digest, 16);
52 
53  /* Create the global keys */
54  aes_setup(KeyDataBuffer, 32, 0, &KsecGlobalAesKey);
55  des3_setup(KeyDataBuffer, 24, 0, &KsecGlobalDes3Key);
56 
57  /* Erase the temp data */
58  RtlSecureZeroMemory(KeyDataBuffer, sizeof(KeyDataBuffer));
59  RtlSecureZeroMemory(&Md5Context, sizeof(Md5Context));
60 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
VOID WINAPI MD5Init(MD5_CTX *)
Definition: md5.c:45
VOID WINAPI MD5Final(MD5_CTX *)
Definition: md5.c:113
VOID WINAPI MD5Update(MD5_CTX *, const unsigned char *, unsigned int)
Definition: md5.c:59
unsigned char digest[16]
Definition: msi.c:4083
unsigned char UCHAR
Definition: xmlstorage.h:181
DES3_KEY KsecGlobalDes3Key
Definition: crypt.c:14
AES_KEY KsecGlobalAesKey
Definition: crypt.c:15
Definition: msi.c:4078
MD5_CTX KsecLoadTimeStartMd5s[2]
Definition: crypt.c:13
NTSTATUS NTAPI KsecGatherEntropyData(PKSEC_ENTROPY_DATA EntropyData)
Definition: random.c:92
FORCEINLINE PVOID RtlSecureZeroMemory(_Out_writes_bytes_all_(Size) PVOID Pointer, _In_ SIZE_T Size)
Definition: rtlfuncs.h:3127
int aes_setup(const unsigned char *key, int keylen, int rounds, aes_key *skey)
Definition: aes.c:937
int des3_setup(const unsigned char *key, int keylen, int num_rounds, des3_key *des3)
Definition: des.c:1432

Referenced by DriverEntry().

Variable Documentation

◆ KsecLsaProcess

PEPROCESS KsecLsaProcess

◆ KsecLsaProcessHandle

HANDLE KsecLsaProcessHandle