bcrypt: Implement BCryptGetProperty for BCRYPT_CHAINING_MODE.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Müller 2018-03-19 11:16:12 +00:00 committed by Alexandre Julliard
parent 7ec0892ab7
commit ba1ed4432c
2 changed files with 11 additions and 10 deletions

View File

@ -540,17 +540,18 @@ static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop
}
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));
*ret_size = sizeof(BCRYPT_CHAIN_MODE_CBC) * sizeof(WCHAR);
return STATUS_SUCCESS;
}
else
{
*ret_size = sizeof(BCRYPT_CHAIN_MODE_CBC) * sizeof(WCHAR);
return STATUS_BUFFER_TOO_SMALL;
case MODE_ID_GCM: mode = BCRYPT_CHAIN_MODE_GCM; break;
case MODE_ID_CBC: mode = BCRYPT_CHAIN_MODE_CBC; break;
default: return STATUS_NOT_IMPLEMENTED;
}
*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 ))
{

View File

@ -483,7 +483,7 @@ static void test_aes(void)
memset(mode, 0, sizeof(mode));
ret = pBCryptGetProperty(alg, BCRYPT_CHAINING_MODE, mode, sizeof(mode), &size, 0);
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);
test_alg_name(alg, "AES");