From 313c06bfbfde54894a47db69608a193ca5cbcdd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Mon, 19 Mar 2018 11:16:14 +0000 Subject: [PATCH] bcrypt: Implement BCryptGetProperty for BCRYPT_AUTH_TAG_LENGTH. Signed-off-by: Alistair Leslie-Hughes Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/bcrypt/bcrypt_main.c | 14 ++++++++++++++ dlls/bcrypt/tests/bcrypt.c | 16 ++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c index 55901f9beff..fa80318f28f 100644 --- a/dlls/bcrypt/bcrypt_main.c +++ b/dlls/bcrypt/bcrypt_main.c @@ -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: diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c index f235cc7b9ee..ba2011f5dfc 100644 --- a/dlls/bcrypt/tests/bcrypt.c +++ b/dlls/bcrypt/tests/bcrypt.c @@ -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);