From 04acc70df45dbff7d244134016d1a2172b1a8f59 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Tue, 20 Oct 2020 10:13:15 +0200 Subject: [PATCH] dssenh/tests: Add tests for CryptDuplicateKey. Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/dssenh/tests/dssenh.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/dlls/dssenh/tests/dssenh.c b/dlls/dssenh/tests/dssenh.c index d3f3172230e..e9c62cb99de 100644 --- a/dlls/dssenh/tests/dssenh.c +++ b/dlls/dssenh/tests/dssenh.c @@ -1514,6 +1514,36 @@ static void test_userkey(void) ok(!hprov, "got %08x\n", (DWORD)hprov); } +static void test_duplicate_key(void) +{ + HCRYPTPROV hprov; + HCRYPTKEY hkey, hkey2; + DWORD len; + BOOL result; + BYTE buf[512]; + + result = CryptAcquireContextA(&hprov, NULL, MS_DEF_DSS_PROV_A, PROV_DSS, CRYPT_VERIFYCONTEXT); + ok(result, "got %08x\n", GetLastError()); + + result = CryptImportKey(hprov, DSS_SIGN_PrivateKey, sizeof(DSS_SIGN_PrivateKey), 0, CRYPT_EXPORTABLE, &hkey); + ok(result, "got %08x\n", GetLastError()); + + result = CryptDuplicateKey(hkey, NULL, 0, &hkey2); + ok(result, "got %08x\n", GetLastError()); + + len = sizeof(buf); + result = CryptExportKey(hkey2, 0, PRIVATEKEYBLOB, 0, buf, &len); + ok(result, "got %08x\n", GetLastError()); + ok(len == sizeof(DSS_SIGN_PrivateKey), "got %u\n", len); + ok(!memcmp(buf, DSS_SIGN_PrivateKey, sizeof(DSS_SIGN_PrivateKey)), "wrong data\n"); + + result = CryptDestroyKey(hkey2); + ok(result, "got %08x\n", GetLastError()); + + result = CryptDestroyKey(hkey); + ok(result, "got %08x\n", GetLastError()); +} + START_TEST(dssenh) { test_acquire_context(); @@ -1525,4 +1555,5 @@ START_TEST(dssenh) test_key_exchange(); test_duplicate_hash(); test_userkey(); + test_duplicate_key(); } -- 2.11.4.GIT