Commit ba1ed443 authored by Michael Müller's avatar Michael Müller Committed by Alexandre Julliard

bcrypt: Implement BCryptGetProperty for BCRYPT_CHAINING_MODE.

parent 7ec0892a
...@@ -540,17 +540,18 @@ static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop ...@@ -540,17 +540,18 @@ static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop
} }
if (!strcmpW( prop, BCRYPT_CHAINING_MODE )) if (!strcmpW( prop, BCRYPT_CHAINING_MODE ))
{ {
if (size >= sizeof(BCRYPT_CHAIN_MODE_CBC) * sizeof(WCHAR)) const WCHAR *mode;
switch (alg->mode)
{ {
memcpy(buf, BCRYPT_CHAIN_MODE_CBC, sizeof(BCRYPT_CHAIN_MODE_CBC)); case MODE_ID_GCM: mode = BCRYPT_CHAIN_MODE_GCM; break;
*ret_size = sizeof(BCRYPT_CHAIN_MODE_CBC) * sizeof(WCHAR); case MODE_ID_CBC: mode = BCRYPT_CHAIN_MODE_CBC; break;
return STATUS_SUCCESS; default: return STATUS_NOT_IMPLEMENTED;
}
else
{
*ret_size = sizeof(BCRYPT_CHAIN_MODE_CBC) * sizeof(WCHAR);
return STATUS_BUFFER_TOO_SMALL;
} }
*ret_size = 64;
if (size < *ret_size) return STATUS_BUFFER_TOO_SMALL;
memcpy( buf, mode, (strlenW(mode) + 1) * sizeof(WCHAR) );
return STATUS_SUCCESS;
} }
if (!strcmpW( prop, BCRYPT_KEY_LENGTHS )) if (!strcmpW( prop, BCRYPT_KEY_LENGTHS ))
{ {
......
...@@ -483,7 +483,7 @@ static void test_aes(void) ...@@ -483,7 +483,7 @@ static void test_aes(void)
memset(mode, 0, sizeof(mode)); memset(mode, 0, sizeof(mode));
ret = pBCryptGetProperty(alg, BCRYPT_CHAINING_MODE, mode, sizeof(mode), &size, 0); ret = pBCryptGetProperty(alg, BCRYPT_CHAINING_MODE, mode, sizeof(mode), &size, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret); ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
todo_wine ok(!lstrcmpW((const WCHAR *)mode, BCRYPT_CHAIN_MODE_GCM), "got %s\n", wine_dbgstr_w((const WCHAR *)mode)); ok(!lstrcmpW((const WCHAR *)mode, BCRYPT_CHAIN_MODE_GCM), "got %s\n", wine_dbgstr_w((const WCHAR *)mode));
ok(size == 64, "got %u\n", size); ok(size == 64, "got %u\n", size);
test_alg_name(alg, "AES"); test_alg_name(alg, "AES");
......
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