bcrypt/tests: Add basic tests for BCryptDuplicateHash.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
da8853f062
commit
bc20b546ef
|
@ -33,6 +33,7 @@ static NTSTATUS (WINAPI *pBCryptCreateHash)(BCRYPT_ALG_HANDLE, BCRYPT_HASH_HANDL
|
|||
ULONG, ULONG);
|
||||
static NTSTATUS (WINAPI *pBCryptHash)(BCRYPT_ALG_HANDLE, UCHAR *, ULONG, UCHAR *, ULONG, UCHAR *, ULONG);
|
||||
static NTSTATUS (WINAPI *pBCryptHashData)(BCRYPT_HASH_HANDLE, PUCHAR, ULONG, ULONG);
|
||||
static NTSTATUS (WINAPI *pBCryptDuplicateHash)(BCRYPT_HASH_HANDLE, BCRYPT_HASH_HANDLE *, UCHAR *, ULONG, ULONG);
|
||||
static NTSTATUS (WINAPI *pBCryptFinishHash)(BCRYPT_HASH_HANDLE, PUCHAR, ULONG, ULONG);
|
||||
static NTSTATUS (WINAPI *pBCryptDestroyHash)(BCRYPT_HASH_HANDLE);
|
||||
static NTSTATUS (WINAPI *pBCryptGenRandom)(BCRYPT_ALG_HANDLE, PUCHAR, ULONG, ULONG);
|
||||
|
@ -208,9 +209,9 @@ static void test_sha1(void)
|
|||
{
|
||||
static const char expected[] = "961fa64958818f767707072755d7018dcd278e94";
|
||||
static const char expected_hmac[] = "2472cf65d0e090618d769d3e46f0d9446cf212da";
|
||||
UCHAR buf[512], buf_hmac[1024], buf_hmac2[1024], sha1[20], sha1_hmac[20];
|
||||
BCRYPT_HASH_HANDLE hash, hash2;
|
||||
BCRYPT_ALG_HANDLE alg;
|
||||
BCRYPT_HASH_HANDLE hash;
|
||||
UCHAR buf[512], buf_hmac[1024], sha1[20], sha1_hmac[20];
|
||||
char str[41];
|
||||
NTSTATUS ret;
|
||||
ULONG len;
|
||||
|
@ -268,6 +269,29 @@ static void test_sha1(void)
|
|||
test_hash_length(hash, 20);
|
||||
test_alg_name(hash, "SHA1");
|
||||
|
||||
len = sizeof(buf_hmac2);
|
||||
ret = pBCryptDuplicateHash(NULL, &hash2, buf_hmac2, len, 0);
|
||||
ok(ret == STATUS_INVALID_HANDLE, "got %08x\n", ret);
|
||||
|
||||
len = sizeof(buf_hmac2);
|
||||
ret = pBCryptDuplicateHash(hash, NULL, buf_hmac2, len, 0);
|
||||
ok(ret == STATUS_INVALID_PARAMETER, "got %08x\n", ret);
|
||||
|
||||
hash2 = NULL;
|
||||
len = sizeof(buf_hmac2);
|
||||
ret = pBCryptDuplicateHash(hash, &hash2, buf_hmac2, len, 0);
|
||||
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
|
||||
ok(hash2 != NULL, "hash not set\n");
|
||||
|
||||
memset(sha1_hmac, 0, sizeof(sha1_hmac));
|
||||
ret = pBCryptFinishHash(hash2, sha1_hmac, sizeof(sha1_hmac), 0);
|
||||
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
|
||||
format_hash( sha1_hmac, sizeof(sha1_hmac), str );
|
||||
ok(!strcmp(str, expected_hmac), "got %s\n", str);
|
||||
|
||||
ret = pBCryptDestroyHash(hash2);
|
||||
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
|
||||
|
||||
memset(sha1_hmac, 0, sizeof(sha1_hmac));
|
||||
ret = pBCryptFinishHash(hash, sha1_hmac, sizeof(sha1_hmac), 0);
|
||||
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
|
||||
|
@ -990,6 +1014,7 @@ START_TEST(bcrypt)
|
|||
pBCryptCreateHash = (void *)GetProcAddress(module, "BCryptCreateHash");
|
||||
pBCryptHash = (void *)GetProcAddress(module, "BCryptHash");
|
||||
pBCryptHashData = (void *)GetProcAddress(module, "BCryptHashData");
|
||||
pBCryptDuplicateHash = (void *)GetProcAddress(module, "BCryptDuplicateHash");
|
||||
pBCryptFinishHash = (void *)GetProcAddress(module, "BCryptFinishHash");
|
||||
pBCryptDestroyHash = (void *)GetProcAddress(module, "BCryptDestroyHash");
|
||||
pBCryptGenRandom = (void *)GetProcAddress(module, "BCryptGenRandom");
|
||||
|
|
Loading…
Reference in New Issue