Commit a71062b9 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

bcrypt: Support BCRYPT_KEY_LENGTHS property for AES.

parent ab575f3d
......@@ -474,6 +474,19 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf,
return STATUS_BUFFER_TOO_SMALL;
}
}
if (!strcmpW( prop, BCRYPT_KEY_LENGTHS ))
{
BCRYPT_KEY_LENGTHS_STRUCT *key_lengths = (void *)buf;
*ret_size = sizeof(*key_lengths);
if (key_lengths && size < *ret_size) return STATUS_BUFFER_TOO_SMALL;
if (key_lengths)
{
key_lengths->dwMinLength = 128;
key_lengths->dwMaxLength = 256;
key_lengths->dwIncrement = 64;
}
return STATUS_SUCCESS;
}
break;
default:
......
......@@ -700,6 +700,7 @@ static void test_rng(void)
static void test_aes(void)
{
BCRYPT_KEY_LENGTHS_STRUCT key_lengths;
BCRYPT_ALG_HANDLE alg;
ULONG size, len;
UCHAR mode[64];
......@@ -733,6 +734,15 @@ static void test_aes(void)
ok(!lstrcmpW((const WCHAR *)mode, BCRYPT_CHAIN_MODE_CBC), "got %s\n", mode);
ok(size == 64, "got %u\n", size);
size = 0;
memset(&key_lengths, 0, sizeof(key_lengths));
ret = BCryptGetProperty(alg, BCRYPT_KEY_LENGTHS, (UCHAR*)&key_lengths, sizeof(key_lengths), &size, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
ok(size == sizeof(key_lengths), "got %u\n", size);
ok(key_lengths.dwMinLength == 128, "Expected 128, got %d\n", key_lengths.dwMinLength);
ok(key_lengths.dwMaxLength == 256, "Expected 256, got %d\n", key_lengths.dwMaxLength);
ok(key_lengths.dwIncrement == 64, "Expected 64, got %d\n", key_lengths.dwIncrement);
test_alg_name(alg, "AES");
ret = pBCryptCloseAlgorithmProvider(alg, 0);
......@@ -962,6 +972,7 @@ static void test_BCryptDecrypt(void)
{0xc6,0xa1,0x3b,0x37,0x87,0x8f,0x5b,0x82,0x6f,0x4f,0x81,0x62,0xa1,0xc8,0xd8,0x79,
0xb1,0xa2,0x92,0x73,0xbe,0x2c,0x42,0x07,0xa5,0xac,0xe3,0x93,0x39,0x8c,0xb6,0xfb,
0x87,0x5d,0xea,0xa3,0x7e,0x0f,0xde,0xfa,0xd9,0xec,0x6c,0x4e,0x3c,0x76,0x86,0xe4};
BCRYPT_KEY_LENGTHS_STRUCT key_lengths;
BCRYPT_ALG_HANDLE aes;
BCRYPT_KEY_HANDLE key;
UCHAR *buf, plaintext[48], ivbuf[16];
......@@ -971,6 +982,15 @@ static void test_BCryptDecrypt(void)
ret = pBCryptOpenAlgorithmProvider(&aes, BCRYPT_AES_ALGORITHM, NULL, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
size = 0;
memset(&key_lengths, 0, sizeof(key_lengths));
ret = BCryptGetProperty(aes, BCRYPT_KEY_LENGTHS, (UCHAR*)&key_lengths, sizeof(key_lengths), &size, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
ok(size == sizeof(key_lengths), "got %u\n", size);
ok(key_lengths.dwMinLength == 128, "Expected 128, got %d\n", key_lengths.dwMinLength);
ok(key_lengths.dwMaxLength == 256, "Expected 256, got %d\n", key_lengths.dwMaxLength);
ok(key_lengths.dwIncrement == 64, "Expected 64, got %d\n", key_lengths.dwIncrement);
len = 0xdeadbeef;
size = sizeof(len);
ret = pBCryptGetProperty(aes, BCRYPT_OBJECT_LENGTH, (UCHAR *)&len, sizeof(len), &size, 0);
......
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