Signed-off-by: Hans Leidekker hans@codeweavers.com --- 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 a045a7e04ee..e74650c9bb7 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 d40dedf41b2..38ee325b8ee 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;