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

bcrypt: Implement KeyLength property.

parent 44bce619
......@@ -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);
......
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