Commit b3073dc1 authored by Santino Mazza's avatar Santino Mazza Committed by Alexandre Julliard

bcrypt: Add support for PUBLICKEY blob types.

parent 2c5084e0
......@@ -1775,6 +1775,34 @@ NTSTATUS WINAPI BCryptImportKeyPair( BCRYPT_ALG_HANDLE algorithm, BCRYPT_KEY_HAN
return STATUS_NOT_IMPLEMENTED;
}
if (!wcscmp( type, BCRYPT_PUBLIC_KEY_BLOB ))
{
BCRYPT_KEY_BLOB *key_blob = (BCRYPT_KEY_BLOB *)input;
if (input_len < sizeof(*key_blob)) return STATUS_INVALID_PARAMETER;
switch (key_blob->Magic)
{
case BCRYPT_ECDH_PUBLIC_P256_MAGIC:
case BCRYPT_ECDSA_PUBLIC_P256_MAGIC:
case BCRYPT_ECDSA_PUBLIC_P384_MAGIC:
type = BCRYPT_ECCPUBLIC_BLOB;
break;
case BCRYPT_RSAPUBLIC_MAGIC:
type = BCRYPT_RSAPUBLIC_BLOB;
break;
case BCRYPT_DSA_PUBLIC_MAGIC:
type = BCRYPT_DSA_PUBLIC_BLOB;
break;
default:
FIXME( "unsupported key magic %#lx\n", key_blob->Magic );
return STATUS_NOT_SUPPORTED;
}
}
return key_import_pair( alg, type, ret_key, input, input_len );
}
......
......@@ -1845,6 +1845,10 @@ static void test_ECDSA(void)
ecckey->dwMagic = BCRYPT_ECDSA_PUBLIC_P256_MAGIC;
ecckey->cbKey = 32;
status = BCryptImportKeyPair(alg, NULL, BCRYPT_PUBLIC_KEY_BLOB, &key, buffer, size, 0);
ok(!status, "BCryptImportKeyPair failed: %#lx\n", status);
BCryptDestroyKey(key);
status = BCryptImportKeyPair(alg, NULL, BCRYPT_ECCPUBLIC_BLOB, &key, buffer, size, 0);
ok(!status, "BCryptImportKeyPair failed: %#lx\n", status);
......@@ -2015,6 +2019,10 @@ static void test_RSA(void)
ok(schemes, "schemes not set\n");
ok(size == sizeof(schemes), "got %lu\n", size);
ret = BCryptImportKeyPair(alg, NULL, BCRYPT_PUBLIC_KEY_BLOB, &key, rsaPublicBlob, sizeof(rsaPublicBlob), 0);
ok(!ret, "BCryptImportKeyPair failed: %#lx\n", ret);
BCryptDestroyKey(key);
ret = BCryptImportKeyPair(alg, NULL, BCRYPT_RSAPUBLIC_BLOB, &key, rsaPublicBlob, sizeof(rsaPublicBlob), 0);
ok(!ret, "BCryptImportKeyPair failed: %#lx\n", ret);
......@@ -2341,6 +2349,10 @@ static void test_ECDH(void)
ok(ecckey->cbKey == 32, "got %lu\n", ecckey->cbKey);
ok(size == sizeof(*ecckey) + ecckey->cbKey * 2, "got %lu\n", size);
status = BCryptImportKeyPair(alg, NULL, BCRYPT_PUBLIC_KEY_BLOB, &pubkey, buf, size, 0);
ok(status == STATUS_SUCCESS, "got %#lx\n", status);
BCryptDestroyKey(pubkey);
status = BCryptImportKeyPair(alg, NULL, BCRYPT_ECCPUBLIC_BLOB, &pubkey, buf, size, 0);
ok(status == STATUS_SUCCESS, "got %#lx\n", status);
HeapFree(GetProcessHeap(), 0, buf);
......@@ -2842,6 +2854,10 @@ static void test_DSA(void)
ret = BCryptGetProperty(alg, L"PaddingSchemes", (UCHAR *)&schemes, sizeof(schemes), &size, 0);
ok(ret == STATUS_NOT_SUPPORTED, "got %#lx\n", ret);
ret = BCryptImportKeyPair(alg, NULL, BCRYPT_PUBLIC_KEY_BLOB, &key, dsaPublicBlob, sizeof(dsaPublicBlob), 0);
ok(!ret, "got %#lx\n", ret);
BCryptDestroyKey(key);
ret = BCryptImportKeyPair(alg, NULL, BCRYPT_DSA_PUBLIC_BLOB, &key, dsaPublicBlob, sizeof(dsaPublicBlob), 0);
ok(!ret, "got %#lx\n", ret);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment