2014-01-22 16:58:36 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Drivers
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PURPOSE: Kernel Security Support Provider Interface Driver
|
|
|
|
*
|
|
|
|
* PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define _NO_KSECDD_IMPORT_
|
|
|
|
#include <ntifs.h>
|
2014-09-15 21:05:38 +00:00
|
|
|
#include <ndk/exfuncs.h>
|
2015-05-16 11:30:28 +00:00
|
|
|
#include <ndk/ketypes.h>
|
2014-09-15 21:05:38 +00:00
|
|
|
#include <pseh/pseh2.h>
|
2014-09-14 19:40:15 +00:00
|
|
|
#include <ntstrsafe.h>
|
|
|
|
|
2014-09-15 21:05:38 +00:00
|
|
|
#include <md4.h>
|
|
|
|
#include <md5.h>
|
|
|
|
#include <tomcrypt.h>
|
|
|
|
typedef aes_key AES_KEY, *PAES_KEY;
|
|
|
|
typedef des3_key DES3_KEY, *PDES3_KEY;
|
|
|
|
|
2014-09-14 19:40:15 +00:00
|
|
|
#define STATUS_KSEC_INTERNAL_ERROR ((NTSTATUS)0x80090304)
|
|
|
|
|
|
|
|
/* FIXME: this should be in some shared header */
|
|
|
|
#define RTL_ENCRYPT_OPTION_SAME_PROCESS 0
|
|
|
|
#define RTL_ENCRYPT_OPTION_CROSS_PROCESS 1
|
|
|
|
#define RTL_ENCRYPT_OPTION_SAME_LOGON 2
|
|
|
|
|
|
|
|
typedef struct _KSEC_CONNECTION_INFO
|
|
|
|
{
|
|
|
|
ULONG Unknown0;
|
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG_PTR Information;
|
|
|
|
CHAR ConnectionString[128];
|
|
|
|
ULONG Flags;
|
|
|
|
} KSEC_CONNECTION_INFO;
|
2014-01-22 16:58:36 +00:00
|
|
|
|
2014-01-26 20:30:06 +00:00
|
|
|
#if defined(_M_IX86) || defined(_M_AMD64)
|
|
|
|
typedef struct _KSEC_MACHINE_SPECIFIC_COUNTERS
|
|
|
|
{
|
|
|
|
ULONG64 Tsc;
|
|
|
|
ULONG64 Pmc0;
|
|
|
|
ULONG64 Pmc1;
|
|
|
|
ULONG64 Ctr0;
|
|
|
|
ULONG64 Ctr1;
|
|
|
|
} KSEC_MACHINE_SPECIFIC_COUNTERS, *PKSEC_MACHINE_SPECIFIC_COUNTERS;
|
2015-05-14 22:32:35 +00:00
|
|
|
#elif defined(_M_ARM)
|
|
|
|
typedef struct _KSEC_MACHINE_SPECIFIC_COUNTERS
|
|
|
|
{
|
|
|
|
ULONG Ccr;
|
|
|
|
} KSEC_MACHINE_SPECIFIC_COUNTERS, *PKSEC_MACHINE_SPECIFIC_COUNTERS;
|
2014-01-26 20:30:06 +00:00
|
|
|
#else
|
2015-05-14 22:32:35 +00:00
|
|
|
typedef ULONG KSEC_MACHINE_SPECIFIC_COUNTERS, *PKSEC_MACHINE_SPECIFIC_COUNTERS;
|
2014-01-26 20:30:06 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct _KSEC_ENTROPY_DATA
|
|
|
|
{
|
|
|
|
HANDLE CurrentProcessId;
|
|
|
|
HANDLE CurrentThreadId;
|
|
|
|
LARGE_INTEGER TickCount;
|
|
|
|
LARGE_INTEGER SystemTime;
|
|
|
|
LARGE_INTEGER PerformanceCounter;
|
|
|
|
LARGE_INTEGER PerformanceFrequency;
|
|
|
|
UCHAR EnvironmentHash[16];
|
|
|
|
KSEC_MACHINE_SPECIFIC_COUNTERS MachineSpecificCounters;
|
|
|
|
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SystemProcessorPerformanceInformation;
|
|
|
|
SYSTEM_PERFORMANCE_INFORMATION SystemPerformanceInformation;
|
|
|
|
SYSTEM_EXCEPTION_INFORMATION SystemExceptionInformation;
|
|
|
|
SYSTEM_LOOKASIDE_INFORMATION SystemLookasideInformation;
|
|
|
|
SYSTEM_INTERRUPT_INFORMATION SystemInterruptInformation;
|
|
|
|
SYSTEM_PROCESS_INFORMATION SystemProcessInformation;
|
|
|
|
} KSEC_ENTROPY_DATA, *PKSEC_ENTROPY_DATA;
|
|
|
|
|
2016-02-04 20:42:07 +00:00
|
|
|
extern PEPROCESS KsecLsaProcess;
|
2014-09-14 19:40:15 +00:00
|
|
|
extern HANDLE KsecLsaProcessHandle;
|
|
|
|
|
2014-01-22 16:58:36 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
KsecDdDispatch(
|
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PIRP Irp);
|
|
|
|
|
2014-09-15 21:05:38 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
KsecGatherEntropyData(
|
|
|
|
PKSEC_ENTROPY_DATA EntropyData);
|
2014-01-22 16:58:36 +00:00
|
|
|
|
2014-01-22 23:41:04 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
KsecGenRandom(
|
|
|
|
PVOID Buffer,
|
|
|
|
SIZE_T Length);
|
|
|
|
|
2014-09-15 21:05:38 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
KsecInitializeEncryptionSupport (
|
|
|
|
VOID);
|
|
|
|
|
2014-09-14 19:40:15 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
KsecEncryptMemory (
|
|
|
|
_Inout_ PVOID Buffer,
|
|
|
|
_In_ ULONG Length,
|
|
|
|
_In_ ULONG OptionFlags);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
KsecDecryptMemory (
|
|
|
|
_Inout_ PVOID Buffer,
|
|
|
|
_In_ ULONG Length,
|
|
|
|
_In_ ULONG OptionFlags);
|
|
|
|
|