bcrypt: Implement BCryptGetProperty for BCRYPT_AUTH_TAG_LENGTH.

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:14 +00:00 committed by Alexandre Julliard
parent ba1ed4432c
commit 313c06bfbf
2 changed files with 22 additions and 8 deletions

View File

@ -566,6 +566,20 @@ static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop
}
return STATUS_SUCCESS;
}
if (!strcmpW( prop, BCRYPT_AUTH_TAG_LENGTH ))
{
BCRYPT_AUTH_TAG_LENGTHS_STRUCT *tag_length = (void *)buf;
if (alg->mode != MODE_ID_GCM) return STATUS_NOT_SUPPORTED;
*ret_size = sizeof(*tag_length);
if (tag_length && size < *ret_size) return STATUS_BUFFER_TOO_SMALL;
if (tag_length)
{
tag_length->dwMinLength = 12;
tag_length->dwMaxLength = 16;
tag_length->dwIncrement = 1;
}
return STATUS_SUCCESS;
}
break;
default:

View File

@ -709,24 +709,24 @@ static void test_BCryptEncrypt(void)
size = 0;
ret = BCryptGetProperty(aes, BCRYPT_AUTH_TAG_LENGTH, NULL, 0, &size, 0);
todo_wine ok(ret == STATUS_NOT_SUPPORTED, "got %08x\n", ret);
ok(ret == STATUS_NOT_SUPPORTED, "got %08x\n", ret);
ret = BCryptSetProperty(aes, BCRYPT_CHAINING_MODE, (UCHAR*)BCRYPT_CHAIN_MODE_GCM, sizeof(BCRYPT_CHAIN_MODE_GCM), 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
size = 0;
ret = BCryptGetProperty(aes, BCRYPT_AUTH_TAG_LENGTH, NULL, 0, &size, 0);
todo_wine ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
todo_wine ok(size == sizeof(tag_length), "got %u\n", size);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
ok(size == sizeof(tag_length), "got %u\n", size);
size = 0;
memset(&tag_length, 0, sizeof(tag_length));
ret = BCryptGetProperty(aes, BCRYPT_AUTH_TAG_LENGTH, (UCHAR*)&tag_length, sizeof(tag_length), &size, 0);
todo_wine ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
todo_wine ok(size == sizeof(tag_length), "got %u\n", size);
todo_wine ok(tag_length.dwMinLength == 12, "Expected 12, got %d\n", tag_length.dwMinLength);
todo_wine ok(tag_length.dwMaxLength == 16, "Expected 16, got %d\n", tag_length.dwMaxLength);
todo_wine ok(tag_length.dwIncrement == 1, "Expected 1, got %d\n", tag_length.dwIncrement);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
ok(size == sizeof(tag_length), "got %u\n", size);
ok(tag_length.dwMinLength == 12, "Expected 12, got %d\n", tag_length.dwMinLength);
ok(tag_length.dwMaxLength == 16, "Expected 16, got %d\n", tag_length.dwMaxLength);
ok(tag_length.dwIncrement == 1, "Expected 1, got %d\n", tag_length.dwIncrement);
len = 0xdeadbeef;
size = sizeof(len);