Hans Leidekker : dssenh/tests: Add tests for CryptDuplicateKey.
Alexandre Julliard
julliard at winehq.org
Tue Oct 20 15:57:17 CDT 2020
Module: wine
Branch: master
Commit: 04acc70df45dbff7d244134016d1a2172b1a8f59
URL: https://source.winehq.org/git/wine.git/?a=commit;h=04acc70df45dbff7d244134016d1a2172b1a8f59
Author: Hans Leidekker <hans at codeweavers.com>
Date: Tue Oct 20 10:13:15 2020 +0200
dssenh/tests: Add tests for CryptDuplicateKey.
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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();
}
More information about the wine-cvs
mailing list