From: Piotr Caban piotr@codeweavers.com
--- dlls/bcrypt/bcrypt_main.c | 23 +++++++++++++++++++++++ dlls/bcrypt/tests/bcrypt.c | 21 +++++++++++++++++++++ 2 files changed, 44 insertions(+)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c index 353ef081fd1..35474d67125 100644 --- a/dlls/bcrypt/bcrypt_main.c +++ b/dlls/bcrypt/bcrypt_main.c @@ -638,6 +638,26 @@ static NTSTATUS get_dsa_property( enum chain_mode mode, const WCHAR *prop, UCHAR return STATUS_NOT_IMPLEMENTED; }
+static NTSTATUS get_pbkdf2_property( enum chain_mode mode, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size ) +{ + if (!wcscmp( prop, BCRYPT_BLOCK_LENGTH )) return STATUS_NOT_SUPPORTED; + if (!wcscmp( 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 = 0; + key_lengths->dwMaxLength = 16384; + key_lengths->dwIncrement = 8; + } + return STATUS_SUCCESS; + } + FIXME( "unsupported property %s\n", debugstr_w(prop) ); + return STATUS_NOT_IMPLEMENTED; +} + static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size ) { @@ -664,6 +684,9 @@ static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop case ALG_ID_DSA: return get_dsa_property( alg->mode, prop, buf, size, ret_size );
+ case ALG_ID_PBKDF2: + return get_pbkdf2_property( alg->mode, prop, buf, size, ret_size ); + default: break; } diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c index 4d65cd26cb2..640629c4dee 100644 --- a/dlls/bcrypt/tests/bcrypt.c +++ b/dlls/bcrypt/tests/bcrypt.c @@ -4372,8 +4372,10 @@ static void test_RC4(void)
static void test_PBKDF2(void) { + BCRYPT_KEY_LENGTHS_STRUCT key_lengths; BCRYPT_ALG_HANDLE alg; NTSTATUS status; + ULONG val, size;
status = BCryptOpenAlgorithmProvider(&alg, BCRYPT_PBKDF2_ALGORITHM, NULL, 0); if (status == STATUS_NOT_FOUND) @@ -4383,6 +4385,25 @@ static void test_PBKDF2(void) } ok(!status, "got %#lx\n", status);
+ val = size = 0; + status = BCryptGetProperty(alg, BCRYPT_OBJECT_LENGTH, (UCHAR *)&val, sizeof(val), &size, 0); + ok(!status, "got %#lx\n", status); + ok(val, "got %lu\n", val); + ok(size == sizeof(val), "got %lu\n", size); + + val = size = 0; + status = BCryptGetProperty(alg, BCRYPT_BLOCK_LENGTH, (UCHAR *)&val, sizeof(val), &size, 0); + ok(status == STATUS_NOT_SUPPORTED, "got %#lx\n", status); + + memset(&key_lengths, 0xfe, sizeof(key_lengths)); + size = 0; + status = BCryptGetProperty(alg, BCRYPT_KEY_LENGTHS, (UCHAR *)&key_lengths, sizeof(key_lengths), &size, 0); + ok(!status, "got %#lx\n", status); + ok(size == sizeof(key_lengths), "got %lu\n", size); + ok(key_lengths.dwMinLength == 0, "got %lu\n", key_lengths.dwMinLength); + ok(key_lengths.dwMaxLength == 16384, "got %lu\n", key_lengths.dwMaxLength); + ok(key_lengths.dwIncrement == 8, "got %lu\n", key_lengths.dwIncrement); + status = BCryptCloseAlgorithmProvider(alg, 0); ok(status == STATUS_SUCCESS, "got %#lx\n", status); }