[KSECDD]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 22 Jan 2014 16:58:36 +0000 (16:58 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 22 Jan 2014 16:58:36 +0000 (16:58 +0000)
Start implementing ksecdd

svn path=/trunk/; revision=61754

reactos/drivers/CMakeLists.txt
reactos/drivers/crypto/CMakeLists.txt [new file with mode: 0644]
reactos/drivers/crypto/ksecdd/CMakeLists.txt [new file with mode: 0644]
reactos/drivers/crypto/ksecdd/dispatch.c [new file with mode: 0644]
reactos/drivers/crypto/ksecdd/ksecdd.c [new file with mode: 0644]
reactos/drivers/crypto/ksecdd/ksecdd.h [new file with mode: 0644]
reactos/drivers/crypto/ksecdd/ksecdd.rc [new file with mode: 0644]
reactos/drivers/crypto/ksecdd/ksecdd.spec [new file with mode: 0644]
reactos/drivers/crypto/ksecdd/stubs.c [new file with mode: 0644]

index be7f2a0..1479792 100644 (file)
@@ -5,6 +5,7 @@ add_subdirectory(base)
 add_subdirectory(battery)
 add_subdirectory(bluetooth)
 add_subdirectory(bus)
+add_subdirectory(crypto)
 add_subdirectory(filesystems)
 add_subdirectory(filters)
 add_subdirectory(hid)
diff --git a/reactos/drivers/crypto/CMakeLists.txt b/reactos/drivers/crypto/CMakeLists.txt
new file mode 100644 (file)
index 0000000..cfa3cb8
--- /dev/null
@@ -0,0 +1,2 @@
+
+add_subdirectory(ksecdd)
diff --git a/reactos/drivers/crypto/ksecdd/CMakeLists.txt b/reactos/drivers/crypto/ksecdd/CMakeLists.txt
new file mode 100644 (file)
index 0000000..29163b4
--- /dev/null
@@ -0,0 +1,13 @@
+
+spec2def(ksecdd.sys ksecdd.spec)
+
+list(APPEND SOURCE
+     ksecdd.c
+     dispatch.c
+     stubs.c
+     ksecdd.rc)
+
+add_library(ksecdd SHARED ${SOURCE})
+set_module_type(ksecdd kernelmodedriver)
+add_importlibs(ksecdd ntoskrnl hal)
+add_cd_file(TARGET ksecdd DESTINATION reactos/system32/drivers NO_CAB FOR all)
diff --git a/reactos/drivers/crypto/ksecdd/dispatch.c b/reactos/drivers/crypto/ksecdd/dispatch.c
new file mode 100644 (file)
index 0000000..a03069f
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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)
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include "ksecdd.h"
+
+#define NDEBUG
+#include <debug.h>
+
+
+/* FUNCTIONS ******************************************************************/
+
+NTSTATUS
+NTAPI
+KsecDdDispatch(
+    PDEVICE_OBJECT DeviceObject,
+    PIRP Irp)
+{
+    PIO_STACK_LOCATION IoStackLocation;
+    ULONG_PTR Information;
+    NTSTATUS Status;
+
+    IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
+
+    switch (IoStackLocation->MajorFunction)
+    {
+        case IRP_MJ_CREATE:
+        case IRP_MJ_CLOSE:
+
+            /* Just return success */
+            Status = STATUS_SUCCESS;
+            Information = 0;
+            break;
+
+        case IRP_MJ_READ:
+
+            /* There is nothing to read */
+            Status = STATUS_END_OF_FILE;
+            Information = 0;
+            break;
+
+        case IRP_MJ_WRITE:
+
+            /* Pretend to have written everything */
+            Status = STATUS_SUCCESS;
+            Information = IoStackLocation->Parameters.Write.Length;
+            break;
+
+        default:
+            DPRINT1("Unhandled major function %lu!\n",
+                    IoStackLocation->MajorFunction);
+            ASSERT(FALSE);
+    }
+
+    /* Return the information */
+    Irp->IoStatus.Status = Status;
+    Irp->IoStatus.Information = Information;
+
+    /* Complete the request */
+    IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+    return Status;
+}
diff --git a/reactos/drivers/crypto/ksecdd/ksecdd.c b/reactos/drivers/crypto/ksecdd/ksecdd.c
new file mode 100644 (file)
index 0000000..a010f24
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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)
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include "ksecdd.h"
+
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+PDEVICE_OBJECT KsecDeviceObject;
+
+
+/* FUNCTIONS ******************************************************************/
+
+NTSTATUS
+NTAPI
+DriverEntry(
+    _In_ PDRIVER_OBJECT DriverObject,
+    _In_ PUNICODE_STRING RegistryPath)
+{
+    UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\KsecDD");
+    NTSTATUS Status;
+
+    /* Create the KsecDD device */
+    Status = IoCreateDevice(DriverObject,
+                            0,
+                            &DeviceName,
+                            FILE_DEVICE_KSEC,
+                            0x100u,
+                            FALSE,
+                            &KsecDeviceObject);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("Failed to create KsecDD device: 0x%lx\n", Status);
+        return Status;
+    }
+
+    /* Set up dispatch table */
+    DriverObject->MajorFunction[IRP_MJ_CREATE] = KsecDdDispatch;
+    DriverObject->MajorFunction[IRP_MJ_CLOSE] = KsecDdDispatch;
+    DriverObject->MajorFunction[IRP_MJ_READ] = KsecDdDispatch;
+    DriverObject->MajorFunction[IRP_MJ_WRITE] = KsecDdDispatch;
+
+    return STATUS_SUCCESS;
+}
diff --git a/reactos/drivers/crypto/ksecdd/ksecdd.h b/reactos/drivers/crypto/ksecdd/ksecdd.h
new file mode 100644 (file)
index 0000000..098c77c
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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>
+
+NTSTATUS
+NTAPI
+KsecDdDispatch(
+    PDEVICE_OBJECT DeviceObject,
+    PIRP Irp);
+
+
diff --git a/reactos/drivers/crypto/ksecdd/ksecdd.rc b/reactos/drivers/crypto/ksecdd/ksecdd.rc
new file mode 100644 (file)
index 0000000..48a7d14
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * PROJECT:         ReactOS Drivers
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PURPOSE:         Resource File for KsecDD
+ * PROGRAMMERS:     Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+#include <winver.h>
+#include <ntverp.h>
+
+/* Version Data */
+#define VER_FILETYPE             VFT_DRV
+#define VER_FILESUBTYPE          VFT2_DRV_SYSTEM
+#define VER_FILEDESCRIPTION_STR  "Kernel Security Support Provider Interface"
+#define VER_INTERNALNAME_STR     "ksecdd.sys"
+#define VER_ORIGINALFILENAME_STR "ksecdd.sys"
+#define VER_LANGNEUTRAL
+#include <common.ver>
diff --git a/reactos/drivers/crypto/ksecdd/ksecdd.spec b/reactos/drivers/crypto/ksecdd/ksecdd.spec
new file mode 100644 (file)
index 0000000..796edb8
--- /dev/null
@@ -0,0 +1,39 @@
+@ stdcall AcceptSecurityContext(ptr ptr ptr long long ptr ptr ptr ptr)
+@ stdcall AcquireCredentialsHandleW(ptr ptr long ptr ptr long ptr ptr ptr)
+@ stdcall AddCredentialsW(ptr ptr ptr long ptr long ptr ptr)
+@ stdcall ApplyControlToken(ptr ptr)
+@ stdcall CredMarshalTargetInfo()
+@ stdcall DeleteSecurityContext(ptr)
+@ stdcall EfsDecryptFek()
+@ stdcall EfsGenerateKey()
+@ stdcall EnumerateSecurityPackagesW(ptr ptr)
+@ stdcall ExportSecurityContext(ptr long ptr ptr)
+@ stdcall FreeContextBuffer(ptr)
+@ stdcall FreeCredentialsHandle(ptr)
+@ stdcall GenerateDirEfs()
+@ stdcall GenerateSessionKey()
+@ stdcall GetSecurityUserInfo()
+@ stdcall ImpersonateSecurityContext(ptr)
+@ stdcall ImportSecurityContextW(ptr ptr ptr ptr)
+@ stdcall InitSecurityInterfaceW()
+@ stdcall InitializeSecurityContextW(ptr ptr ptr long long long ptr long ptr ptr ptr ptr)
+@ stdcall KSecRegisterSecurityProvider()
+@ stdcall KSecValidateBuffer()
+@ stdcall LsaEnumerateLogonSessions()
+@ stdcall LsaGetLogonSessionData()
+@ stdcall MakeSignature(ptr long ptr long)
+@ stdcall MapSecurityError()
+@ stdcall QueryContextAttributesW(ptr long ptr)
+@ stdcall QueryCredentialsAttributesW(ptr long ptr)
+@ stdcall QuerySecurityContextToken(ptr ptr)
+@ stdcall QuerySecurityPackageInfoW(ptr ptr)
+@ stdcall RevertSecurityContext(ptr)
+@ stdcall SealMessage()
+@ stdcall SecLookupAccountName(ptr ptr ptr ptr ptr ptr)
+@ stdcall SecLookupAccountSid(ptr ptr ptr ptr ptr ptr)
+@ stdcall SecLookupWellKnownSid(long ptr long ptr)
+@ stdcall SecMakeSPN(ptr ptr ptr long ptr ptr ptr long)
+@ stdcall SecMakeSPNEx(ptr ptr ptr long ptr ptr ptr ptr long)
+@ stdcall SecSetPagingMode()
+@ stdcall UnsealMessage()
+@ stdcall VerifySignature(ptr ptr long ptr)
diff --git a/reactos/drivers/crypto/ksecdd/stubs.c b/reactos/drivers/crypto/ksecdd/stubs.c
new file mode 100644 (file)
index 0000000..1a031e2
--- /dev/null
@@ -0,0 +1,412 @@
+/*
+ * 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)
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include "ksecdd.h"
+
+#define NDEBUG
+#include <debug.h>
+
+
+/* FUNCTIONS ******************************************************************/
+
+SECURITY_STATUS
+SEC_ENTRY
+AcceptSecurityContext(
+    _In_opt_ PCredHandle phCredential,
+    _In_opt_ PCtxtHandle phContext,
+    _In_opt_ PSecBufferDesc pInput,
+    _In_ ULONG fContextReq,
+    _In_ ULONG TargetDataRep,
+    _In_opt_ PCtxtHandle phNewContext,
+    _In_opt_ PSecBufferDesc pOutput,
+    _Out_ PULONG pfContextAttr,
+    _Out_opt_ PTimeStamp ptsExpiry)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+AcquireCredentialsHandleW(
+    _In_opt_ PSSPI_SEC_STRING pPrincipal,
+    _In_ PSSPI_SEC_STRING pPackage,
+    _In_ ULONG fCredentialUse,
+    _In_opt_ PVOID pvLogonId,
+    _In_opt_ PVOID pAuthData,
+    _In_opt_ SEC_GET_KEY_FN pGetKeyFn,
+    _In_opt_ PVOID pvGetKeyArgument,
+    _Out_ PCredHandle phCredential,
+    _Out_opt_ PTimeStamp ptsExpiry)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+AddCredentialsW(
+    _In_ PCredHandle hCredentials,
+    _In_opt_ PSSPI_SEC_STRING pPrincipal,
+    _In_ PSSPI_SEC_STRING pPackage,
+    _In_ ULONG fCredentialUse,
+    _In_opt_ PVOID pAuthData,
+    _In_opt_ SEC_GET_KEY_FN pGetKeyFn,
+    _In_opt_ PVOID pvGetKeyArgument,
+    _Out_opt_ PTimeStamp ptsExpiry)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+ApplyControlToken(
+    _In_ PCtxtHandle phContext,
+    _In_ PSecBufferDesc pInput)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+VOID
+SEC_ENTRY
+CredMarshalTargetInfo(VOID)
+{
+    UNIMPLEMENTED_DBGBREAK();
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+DeleteSecurityContext(
+    _In_ PCtxtHandle phContext)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+VOID
+SEC_ENTRY
+EfsDecryptFek(VOID)
+{
+    UNIMPLEMENTED_DBGBREAK();
+}
+
+VOID
+SEC_ENTRY
+EfsGenerateKey(VOID)
+{
+    UNIMPLEMENTED_DBGBREAK();
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+EnumerateSecurityPackagesW(
+    _Out_ PULONG pcPackages,
+    _Deref_out_ PSecPkgInfoW* ppPackageInfo)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+ExportSecurityContext(
+    _In_ PCtxtHandle phContext,
+    _In_ ULONG fFlags,
+    _Out_ PSecBuffer pPackedContext,
+    _Out_ PVOID* pToken)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+FreeContextBuffer(
+    _Inout_ PVOID pvContextBuffer)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+FreeCredentialsHandle(
+    _In_ PCredHandle phCredential)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+VOID
+SEC_ENTRY
+GenerateDirEfs(VOID)
+{
+    UNIMPLEMENTED_DBGBREAK();
+}
+
+VOID
+SEC_ENTRY
+GenerateSessionKey(VOID)
+{
+    UNIMPLEMENTED_DBGBREAK();
+}
+
+VOID
+SEC_ENTRY
+GetSecurityUserInfo(VOID)
+{
+    UNIMPLEMENTED_DBGBREAK();
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+ImpersonateSecurityContext(
+    _In_ PCtxtHandle phContext)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+ImportSecurityContextW(
+    _In_ PSSPI_SEC_STRING pszPackage,
+    _In_ PSecBuffer pPackedContext,
+    _In_ PVOID Token,
+    _Out_ PCtxtHandle phContext)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+InitializeSecurityContextW(
+    _In_opt_ PCredHandle phCredential,
+    _In_opt_ PCtxtHandle phContext,
+    _In_opt_ PSSPI_SEC_STRING pTargetName,
+    _In_ ULONG fContextReq,
+    _In_ ULONG Reserved1,
+    _In_ ULONG TargetDataRep,
+    _In_opt_ PSecBufferDesc pInput,
+    _In_ ULONG Reserved2,
+    _Inout_opt_ PCtxtHandle phNewContext,
+    _Inout_opt_ PSecBufferDesc pOutput,
+    _Out_ PULONG pfContextAttr,
+    _Out_opt_ PTimeStamp ptsExpiry)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+VOID
+SEC_ENTRY
+KSecRegisterSecurityProvider(VOID)
+{
+    UNIMPLEMENTED_DBGBREAK();
+}
+
+VOID
+SEC_ENTRY
+KSecValidateBuffer(VOID)
+{
+    UNIMPLEMENTED_DBGBREAK();
+}
+
+VOID
+SEC_ENTRY
+LsaEnumerateLogonSessions(VOID)
+{
+    UNIMPLEMENTED_DBGBREAK();
+}
+
+VOID
+SEC_ENTRY
+LsaGetLogonSessionData(VOID)
+{
+    UNIMPLEMENTED_DBGBREAK();
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+MakeSignature(
+    _In_ PCtxtHandle phContext,
+    _In_ ULONG fQOP,
+    _In_ PSecBufferDesc pMessage,
+    _In_ ULONG MessageSeqNo)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+VOID
+SEC_ENTRY
+MapSecurityError(VOID)
+{
+    UNIMPLEMENTED_DBGBREAK();
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+QueryContextAttributesW(
+    _In_ PCtxtHandle phContext,
+    _In_ ULONG ulAttribute,
+    _Out_ PVOID pBuffer)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+QueryCredentialsAttributesW(
+    _In_ PCredHandle phCredential,
+    _In_ ULONG ulAttribute,
+    _Inout_ PVOID pBuffer)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+QuerySecurityContextToken(
+    _In_ PCtxtHandle phContext,
+    _Out_ PVOID* Token)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+QuerySecurityPackageInfoW(
+    _In_ PSSPI_SEC_STRING pPackageName,
+    _Deref_out_ PSecPkgInfoW *ppPackageInfo)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+RevertSecurityContext(
+    _In_ PCtxtHandle phContext)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+VOID
+SEC_ENTRY
+SealMessage(VOID)
+{
+    UNIMPLEMENTED_DBGBREAK();
+}
+
+NTSTATUS
+SEC_ENTRY
+SecLookupAccountName(
+    _In_ PUNICODE_STRING Name,
+    _Inout_ PULONG SidSize,
+    _Out_ PSID Sid,
+    _Out_ PSID_NAME_USE NameUse,
+    _Out_opt_ PULONG DomainSize,
+    _Inout_opt_ PUNICODE_STRING ReferencedDomain)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+NTSTATUS
+SEC_ENTRY
+SecLookupAccountSid(
+    _In_ PSID Sid,
+    _Out_ PULONG NameSize,
+    _Inout_ PUNICODE_STRING NameBuffer,
+    _Out_ PULONG DomainSize OPTIONAL,
+    _Out_opt_ PUNICODE_STRING DomainBuffer,
+    _Out_ PSID_NAME_USE NameUse)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+NTSTATUS
+SEC_ENTRY
+SecLookupWellKnownSid(
+    _In_ WELL_KNOWN_SID_TYPE SidType,
+    _Out_ PSID Sid,
+    _In_ ULONG SidBufferSize,
+    _Inout_opt_ PULONG SidSize)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+NTSTATUS
+NTAPI
+SecMakeSPN(
+    _In_ PUNICODE_STRING ServiceClass,
+    _In_ PUNICODE_STRING ServiceName,
+    _In_opt_ PUNICODE_STRING InstanceName,
+    _In_opt_ USHORT InstancePort,
+    _In_opt_ PUNICODE_STRING Referrer,
+    _Inout_ PUNICODE_STRING Spn,
+    _Out_opt_ PULONG Length,
+    _In_ BOOLEAN Allocate)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+NTSTATUS
+NTAPI
+SecMakeSPNEx(
+    _In_ PUNICODE_STRING ServiceClass,
+    _In_ PUNICODE_STRING ServiceName,
+    _In_opt_ PUNICODE_STRING InstanceName,
+    _In_opt_ USHORT InstancePort,
+    _In_opt_ PUNICODE_STRING Referrer,
+    _In_opt_ PUNICODE_STRING TargetInfo,
+    _Inout_ PUNICODE_STRING Spn,
+    _Out_opt_ PULONG Length,
+    _In_ BOOLEAN Allocate)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}
+
+VOID
+SEC_ENTRY
+SecSetPagingMode(VOID)
+{
+    UNIMPLEMENTED_DBGBREAK();
+}
+VOID
+SEC_ENTRY
+UnsealMessage(VOID)
+{
+    UNIMPLEMENTED_DBGBREAK();
+}
+
+SECURITY_STATUS
+SEC_ENTRY
+VerifySignature(
+    _In_ PCtxtHandle phContext,
+    _In_ PSecBufferDesc pMessage,
+    _In_ ULONG MessageSeqNo,
+    _Out_ PULONG pfQOP)
+{
+    UNIMPLEMENTED_DBGBREAK();
+    return 0;
+}