From c822cb995e0b362460c09d1d1297aef93840ba83 Mon Sep 17 00:00:00 2001
From: Hans Leidekker <hans@codeweavers.com>
Date: Mon, 12 Oct 2020 16:11:11 +0200
Subject: [PATCH] dssenh: Implement CPGenRandom.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
---
 dlls/dssenh/dssenh.spec |  2 +-
 dlls/dssenh/main.c      | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/dlls/dssenh/dssenh.spec b/dlls/dssenh/dssenh.spec
index e74650c9bb7..eb9ef06337a 100644
--- a/dlls/dssenh/dssenh.spec
+++ b/dlls/dssenh/dssenh.spec
@@ -9,7 +9,7 @@
 @ stub CPEncrypt
 @ stdcall CPExportKey(ptr ptr ptr long long ptr ptr)
 @ stdcall CPGenKey(ptr long long ptr)
-@ stub CPGenRandom
+@ stdcall CPGenRandom(ptr long ptr)
 @ stdcall CPGetHashParam(ptr ptr long ptr ptr long)
 @ stub CPGetKeyParam
 @ stdcall CPGetProvParam(ptr long ptr ptr long)
diff --git a/dlls/dssenh/main.c b/dlls/dssenh/main.c
index 38ee325b8ee..ce7b15f7a66 100644
--- a/dlls/dssenh/main.c
+++ b/dlls/dssenh/main.c
@@ -27,6 +27,7 @@
 #include "bcrypt.h"
 #include "objbase.h"
 #include "rpcproxy.h"
+#include "ntsecapi.h"
 
 #include "wine/debug.h"
 #include "wine/heap.h"
@@ -498,6 +499,17 @@ BOOL WINAPI CPDuplicateKey( HCRYPTPROV hprov, HCRYPTKEY hkey, DWORD *reserved, D
     return TRUE;
 }
 
+BOOL WINAPI CPGenRandom( HCRYPTPROV hprov, DWORD len, BYTE *buffer )
+{
+    struct container *container = (struct container *)hprov;
+
+    TRACE( "%p, %u, %p\n", (void *)hprov, len, buffer );
+
+    if (container->magic != MAGIC_CONTAINER) return FALSE;
+
+    return RtlGenRandom( buffer, len );
+}
+
 static struct hash *create_hash( ALG_ID algid )
 {
     struct hash *ret;
-- 
GitLab