bcrypt/tests: Add AES provider tests.

Signed-off-by: Bruno Jesus <00cpxxx@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2016-12-02 18:36:41 -02:00 committed by Alexandre Julliard
parent 8d8936cbb6
commit 9fcdc5ec75
2 changed files with 62 additions and 0 deletions

View File

@ -765,6 +765,62 @@ static void test_rng(void)
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
}
static void test_aes(void)
{
BCRYPT_ALG_HANDLE alg;
ULONG size, len;
UCHAR mode[64];
NTSTATUS ret;
todo_wine {
alg = NULL;
ret = pBCryptOpenAlgorithmProvider(&alg, BCRYPT_AES_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
ok(alg != NULL, "alg not set\n");
len = size = 0;
ret = pBCryptGetProperty(alg, BCRYPT_OBJECT_LENGTH, (UCHAR *)&len, sizeof(len), &size, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
if (sizeof(void *) == 4)
{
ok(len == 618 /* >= Win 8 */
|| broken(len == 610) /* Win 7 */
|| broken(len == 582) /* < Win 7 */,
"got %u\n", len);
ok(size == sizeof(len), "got %u\n", size);
}
else
{
ok(len == 654 /* >= Win 8 */
|| broken(len == 622) /* Win 7 */
|| broken(len == 598) /* < Win 7 */,
"got %u\n", len);
ok(size == sizeof(len), "got %u\n", size);
}
len = size = 0;
ret = pBCryptGetProperty(alg, BCRYPT_BLOCK_LENGTH, (UCHAR *)&len, sizeof(len), &size, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
ok(len == 16, "got %u\n", len);
ok(size == sizeof(len), "got %u\n", size);
size = 0;
ret = pBCryptGetProperty(alg, BCRYPT_CHAINING_MODE, mode, 0, &size, 0);
ok(ret == STATUS_BUFFER_TOO_SMALL, "got %08x\n", ret);
ok(size == 64, "got %u\n", size);
size = 0;
ret = pBCryptGetProperty(alg, BCRYPT_CHAINING_MODE, mode, sizeof(mode), &size, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
ok(!lstrcmpW((const WCHAR *)mode, BCRYPT_CHAIN_MODE_CBC), "got %s\n", mode);
ok(size == 64, "got %u\n", size);
test_alg_name(alg, "AES");
ret = pBCryptCloseAlgorithmProvider(alg, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
}
}
START_TEST(bcrypt)
{
HMODULE module;
@ -795,6 +851,7 @@ START_TEST(bcrypt)
test_sha512();
test_md5();
test_rng();
test_aes();
if (pBCryptHash) /* >= Win 10 */
test_BcryptHash();

View File

@ -63,6 +63,7 @@ typedef LONG NTSTATUS;
#define MS_PLATFORM_CRYPTO_PROVIDER (const WCHAR [])\
{'M','i','c','r','o','s','o','f','t',' ','P','l','a','t','f','o','r','m',' ','C','r','y','p','t','o',' ','P','r','o','v','i','d','e','r',0}
#define BCRYPT_AES_ALGORITHM (const WCHAR []){'A','E','S',0}
#define BCRYPT_MD5_ALGORITHM (const WCHAR []){'M','D','5',0}
#define BCRYPT_RNG_ALGORITHM (const WCHAR []){'R','N','G',0}
#define BCRYPT_SHA1_ALGORITHM (const WCHAR []){'S','H','A','1',0}
@ -70,6 +71,10 @@ typedef LONG NTSTATUS;
#define BCRYPT_SHA384_ALGORITHM (const WCHAR []){'S','H','A','3','8','4',0}
#define BCRYPT_SHA512_ALGORITHM (const WCHAR []){'S','H','A','5','1','2',0}
#define BCRYPT_CHAIN_MODE_NA (const WCHAR []){'C','h','a','i','n','i','n','g','M','o','d','e','N','/','A',0}
#define BCRYPT_CHAIN_MODE_CBC (const WCHAR []){'C','h','a','i','n','i','n','g','M','o','d','e','C','B','C',0}
#define BCRYPT_CHAIN_MODE_ECB (const WCHAR []){'C','h','a','i','n','i','n','g','M','o','d','e','E','C','B',0}
typedef struct _BCRYPT_ALGORITHM_IDENTIFIER
{
LPWSTR pszName;