Hans Leidekker : dssenh: Implement CPDuplicateKey.

Alexandre Julliard julliard at winehq.org
Mon Oct 12 15:20:51 CDT 2020


Module: wine
Branch: master
Commit: e32b29a3fd2d611a1c978bfe9c7630a735e3f201
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e32b29a3fd2d611a1c978bfe9c7630a735e3f201

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Mon Oct 12 16:11:10 2020 +0200

dssenh: Implement CPDuplicateKey.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dssenh/dssenh.spec |  2 +-
 dlls/dssenh/main.c      | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/dlls/dssenh/dssenh.spec b/dlls/dssenh/dssenh.spec
index a045a7e04e..e74650c9bb 100644
--- a/dlls/dssenh/dssenh.spec
+++ b/dlls/dssenh/dssenh.spec
@@ -5,7 +5,7 @@
 @ stdcall CPDestroyHash(ptr ptr)
 @ stdcall CPDestroyKey(ptr ptr)
 @ stdcall CPDuplicateHash(ptr ptr ptr long ptr)
-@ stub CPDuplicateKey
+@ stdcall CPDuplicateKey(ptr ptr ptr long ptr)
 @ stub CPEncrypt
 @ stdcall CPExportKey(ptr ptr ptr long long ptr ptr)
 @ stdcall CPGenKey(ptr long long ptr)
diff --git a/dlls/dssenh/main.c b/dlls/dssenh/main.c
index d40dedf41b..38ee325b8e 100644
--- a/dlls/dssenh/main.c
+++ b/dlls/dssenh/main.c
@@ -471,6 +471,33 @@ BOOL WINAPI CPExportKey( HCRYPTPROV hprov, HCRYPTKEY hkey, HCRYPTKEY hexpkey, DW
     return FALSE;
 }
 
+static struct key *duplicate_key( const struct key *key )
+{
+    struct key *ret;
+
+    if (!(ret = create_key( key->algid, key->flags ))) return NULL;
+
+    if (BCryptDuplicateKey( key->handle, &ret->handle, NULL, 0, 0 ))
+    {
+        heap_free( ret );
+        return NULL;
+    }
+    return ret;
+}
+
+BOOL WINAPI CPDuplicateKey( HCRYPTPROV hprov, HCRYPTKEY hkey, DWORD *reserved, DWORD flags, HCRYPTKEY *ret_key )
+{
+    struct key *key = (struct key *)hkey, *ret;
+
+    TRACE( "%p, %p, %p, %08x, %p\n", (void *)hprov, (void *)hkey, reserved, flags, ret_key );
+
+    if (key->magic != MAGIC_KEY) return FALSE;
+
+    if (!(ret = duplicate_key( key ))) return FALSE;
+    *ret_key = (HCRYPTKEY)ret;
+    return TRUE;
+}
+
 static struct hash *create_hash( ALG_ID algid )
 {
     struct hash *ret;




More information about the wine-cvs mailing list