dssenh/tests: Add tests for CryptDuplicateKey.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2020-10-20 10:13:15 +02:00 committed by Alexandre Julliard
parent c2883d77b8
commit 04acc70df4
1 changed files with 31 additions and 0 deletions

View File

@ -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();
}