bcrypt: Implement KeyLength property.
Signed-off-by: Santino Mazza <mazzasantino1206@gmail.com> Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
44bce619ef
commit
bae287a1aa
|
@ -701,6 +701,12 @@ static NTSTATUS set_key_property( struct key *key, const WCHAR *prop, UCHAR *val
|
|||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
}
|
||||
else if (!wcscmp( prop, BCRYPT_KEY_LENGTH ))
|
||||
{
|
||||
if (size < sizeof(DWORD)) return STATUS_INVALID_PARAMETER;
|
||||
key->u.a.bitlen = *(DWORD*)value;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
FIXME( "unsupported key property %s\n", debugstr_w(prop) );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
|
|
|
@ -672,6 +672,7 @@ static void test_BCryptGenerateSymmetricKey(void)
|
|||
BCRYPT_KEY_LENGTHS_STRUCT key_lengths;
|
||||
ULONG size, len, i;
|
||||
NTSTATUS ret;
|
||||
DWORD keylen;
|
||||
|
||||
ret = BCryptOpenAlgorithmProvider(&aes, BCRYPT_AES_ALGORITHM, NULL, 0);
|
||||
ok(ret == STATUS_SUCCESS, "got %#lx\n", ret);
|
||||
|
@ -706,6 +707,13 @@ static void test_BCryptGenerateSymmetricKey(void)
|
|||
sizeof(BCRYPT_CHAIN_MODE_CBC), 0);
|
||||
ok(ret == STATUS_SUCCESS, "got %#lx\n", ret);
|
||||
|
||||
todo_wine
|
||||
{
|
||||
keylen = 512;
|
||||
ret = BCryptSetProperty(aes, BCRYPT_KEY_LENGTH, (UCHAR *)&keylen, sizeof(keylen), 0);
|
||||
ok(ret == STATUS_NOT_SUPPORTED, "got %#lx\n", ret);
|
||||
}
|
||||
|
||||
size = 0;
|
||||
memset(mode, 0, sizeof(mode));
|
||||
ret = BCryptGetProperty(key, BCRYPT_CHAINING_MODE, mode, sizeof(mode), &size, 0);
|
||||
|
@ -2005,6 +2013,7 @@ static void test_RSA(void)
|
|||
ULONG len, size, size2, schemes;
|
||||
NTSTATUS ret;
|
||||
BYTE *buf;
|
||||
DWORD keylen;
|
||||
|
||||
ret = BCryptOpenAlgorithmProvider(&alg, BCRYPT_RSA_ALGORITHM, NULL, 0);
|
||||
if (ret)
|
||||
|
@ -2052,12 +2061,21 @@ static void test_RSA(void)
|
|||
ok(!ret, "BCryptDestroyKey failed: %#lx\n", ret);
|
||||
|
||||
/* sign/verify with export/import round-trip */
|
||||
ret = BCryptGenerateKeyPair(alg, &key, 512, 0);
|
||||
ret = BCryptGenerateKeyPair(alg, &key, 1024, 0);
|
||||
ok(ret == STATUS_SUCCESS, "got %#lx\n", ret);
|
||||
|
||||
keylen = 512;
|
||||
ret = BCryptSetProperty(key, BCRYPT_KEY_LENGTH, (UCHAR *)&keylen, 2, 0);
|
||||
ok(ret == STATUS_INVALID_PARAMETER, "got %#lx\n", ret);
|
||||
ret = BCryptSetProperty(key, BCRYPT_KEY_LENGTH, (UCHAR *)&keylen, sizeof(keylen), 0);
|
||||
ok(ret == STATUS_SUCCESS, "got %#lx\n", ret);
|
||||
|
||||
ret = BCryptFinalizeKeyPair(key, 0);
|
||||
ok(ret == STATUS_SUCCESS, "got %#lx\n", ret);
|
||||
|
||||
ret = BCryptSetProperty(key, BCRYPT_KEY_LENGTH, (UCHAR *)&keylen, sizeof(keylen), 0);
|
||||
ok(ret == STATUS_SUCCESS, "got %#lx\n", ret);
|
||||
|
||||
pad.pszAlgId = BCRYPT_SHA1_ALGORITHM;
|
||||
memset(sig, 0, sizeof(sig));
|
||||
ret = BCryptSignHash(key, &pad, hash, sizeof(hash), sig, sizeof(sig), &len, BCRYPT_PAD_PKCS1);
|
||||
|
|
Loading…
Reference in New Issue