From 01c7d3e8e745c3b443e0a8e712f32eadc56f59a8 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Tue, 5 Feb 2019 10:09:59 +1100
Subject: [PATCH 2/2] bcrypt: Add BCryptDeriveKey stub

---
 dlls/bcrypt/bcrypt.spec   |  2 +-
 dlls/bcrypt/bcrypt_main.c |  7 +++++++
 dlls/ncrypt/ncrypt.spec   |  2 +-
 include/bcrypt.h          | 15 +++++++++++++++
 4 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/dlls/bcrypt/bcrypt.spec b/dlls/bcrypt/bcrypt.spec
index dfe08e7..4946ee5 100644
--- a/dlls/bcrypt/bcrypt.spec
+++ b/dlls/bcrypt/bcrypt.spec
@@ -7,7 +7,7 @@
 @ stdcall BCryptCreateHash(ptr ptr ptr long ptr long long)
 @ stdcall BCryptDecrypt(ptr ptr long ptr ptr long ptr long ptr long)
 @ stub BCryptDeleteContext
-@ stub BCryptDeriveKey
+@ stdcall BCryptDeriveKey(ptr wstr ptr ptr long ptr long)
 @ stdcall BCryptDeriveKeyPBKDF2(ptr ptr long ptr long int64 ptr long long)
 @ stdcall BCryptDestroyHash(ptr)
 @ stdcall BCryptDestroyKey(ptr)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 18783f0..399626d 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -1596,6 +1596,13 @@ NTSTATUS WINAPI BCryptDestroySecret(BCRYPT_SECRET_HANDLE secret)
     return STATUS_SUCCESS;
 }
 
+NTSTATUS WINAPI BCryptDeriveKey(BCRYPT_SECRET_HANDLE secret, LPCWSTR kdf, BCryptBufferDesc *parameter,
+        PUCHAR derived, ULONG derived_size, ULONG *result, ULONG flags)
+{
+    FIXME( "%p, %s, %p, %p, %d, %p, %08x\n", secret, debugstr_w(kdf), parameter, derived, derived_size, result, flags );
+    return STATUS_INTERNAL_ERROR;
+}
+
 BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
 {
     switch (reason)
diff --git a/dlls/ncrypt/ncrypt.spec b/dlls/ncrypt/ncrypt.spec
index d4a32ed..d35f8a9 100644
--- a/dlls/ncrypt/ncrypt.spec
+++ b/dlls/ncrypt/ncrypt.spec
@@ -7,7 +7,7 @@
 @ stdcall BCryptCreateHash(ptr ptr ptr long ptr long long) bcrypt.BCryptCreateHash
 @ stdcall BCryptDecrypt(ptr ptr long ptr ptr long ptr long ptr long) bcrypt.BCryptDecrypt
 @ stub BCryptDeleteContext
-@ stub BCryptDeriveKey
+@ stdcall BCryptDeriveKey(ptr wstr ptr ptr long ptr long) bcrypt.BCryptDeriveKey
 @ stub BCryptDeriveKeyCapi
 @ stdcall BCryptDeriveKeyPBKDF2(ptr ptr long ptr long int64 ptr long long) bcrypt.BCryptDeriveKeyPBKDF2
 @ stdcall BCryptDestroyHash(ptr) bcrypt.BCryptDestroyHash
diff --git a/include/bcrypt.h b/include/bcrypt.h
index f0185d1..b1799d0 100644
--- a/include/bcrypt.h
+++ b/include/bcrypt.h
@@ -204,6 +204,20 @@ typedef struct _BCRYPT_KEY_DATA_BLOB_HEADER
     ULONG cbKeyData;
 } BCRYPT_KEY_DATA_BLOB_HEADER, *PBCRYPT_KEY_DATA_BLOB_HEADER;
 
+typedef struct _BCryptBuffer
+{
+    ULONG cbBuffer;
+    ULONG BufferType;
+    void  *pvBuffer;
+} BCryptBuffer, *PBCryptBuffer;
+
+typedef struct _BCryptBufferDesc
+{
+    ULONG ulVersion;
+    ULONG cBuffers;
+    PBCryptBuffer pBuffers;
+} BCryptBufferDesc, *PBCryptBufferDesc;
+
 #define BCRYPT_KEY_DATA_BLOB_MAGIC    0x4d42444b
 #define BCRYPT_KEY_DATA_BLOB_VERSION1 1
 
@@ -229,6 +243,7 @@ typedef PVOID BCRYPT_SECRET_HANDLE;
 NTSTATUS WINAPI BCryptCloseAlgorithmProvider(BCRYPT_ALG_HANDLE, ULONG);
 NTSTATUS WINAPI BCryptCreateHash(BCRYPT_ALG_HANDLE, BCRYPT_HASH_HANDLE *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG);
 NTSTATUS WINAPI BCryptDecrypt(BCRYPT_KEY_HANDLE, PUCHAR, ULONG, VOID *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG *, ULONG);
+NTSTATUS WINAPI BCryptDeriveKey(BCRYPT_SECRET_HANDLE, LPCWSTR, BCryptBufferDesc*, PUCHAR, ULONG, ULONG *, ULONG);
 NTSTATUS WINAPI BCryptDeriveKeyPBKDF2(BCRYPT_ALG_HANDLE, PUCHAR, ULONG, PUCHAR, ULONG, ULONGLONG, PUCHAR, ULONG, ULONG);
 NTSTATUS WINAPI BCryptDestroyHash(BCRYPT_HASH_HANDLE);
 NTSTATUS WINAPI BCryptDestroyKey(BCRYPT_KEY_HANDLE);
-- 
1.9.1

