bcrypt: Add more BCryptSignHash tests.
Signed-off-by: Derek Lesho <dlesho@codeweavers.com> Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1703ac54fa
commit
741f8ae24e
|
@ -2049,6 +2049,9 @@ static void test_BCryptSignHash(void)
|
||||||
{
|
{
|
||||||
static UCHAR hash[] =
|
static UCHAR hash[] =
|
||||||
{0x7e,0xe3,0x74,0xe7,0xc5,0x0b,0x6b,0x70,0xdb,0xab,0x32,0x6d,0x1d,0x51,0xd6,0x74,0x79,0x8e,0x5b,0x4b};
|
{0x7e,0xe3,0x74,0xe7,0xc5,0x0b,0x6b,0x70,0xdb,0xab,0x32,0x6d,0x1d,0x51,0xd6,0x74,0x79,0x8e,0x5b,0x4b};
|
||||||
|
static UCHAR hash_sha256[] =
|
||||||
|
{0x25,0x2f,0x10,0xc8,0x36,0x10,0xeb,0xca,0x1a,0x05,0x9c,0x0b,0xae,0x82,0x55,0xeb,0xa2,0xf9,0x5b,0xe4,
|
||||||
|
0xd1,0xd7,0xbC,0xfA,0x89,0xd7,0x24,0x8a,0x82,0xd9,0xf1,0x11};
|
||||||
BCRYPT_PKCS1_PADDING_INFO pad;
|
BCRYPT_PKCS1_PADDING_INFO pad;
|
||||||
BCRYPT_ALG_HANDLE alg;
|
BCRYPT_ALG_HANDLE alg;
|
||||||
BCRYPT_KEY_HANDLE key;
|
BCRYPT_KEY_HANDLE key;
|
||||||
|
@ -2056,6 +2059,8 @@ static void test_BCryptSignHash(void)
|
||||||
NTSTATUS ret;
|
NTSTATUS ret;
|
||||||
ULONG len;
|
ULONG len;
|
||||||
|
|
||||||
|
/* RSA */
|
||||||
|
|
||||||
ret = pBCryptOpenAlgorithmProvider(&alg, BCRYPT_RSA_ALGORITHM, NULL, 0);
|
ret = pBCryptOpenAlgorithmProvider(&alg, BCRYPT_RSA_ALGORITHM, NULL, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
|
@ -2087,6 +2092,14 @@ static void test_BCryptSignHash(void)
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(sig, 0, sizeof(sig));
|
memset(sig, 0, sizeof(sig));
|
||||||
|
|
||||||
|
/* inference of padding info on RSA not supported */
|
||||||
|
ret = pBCryptSignHash(key, NULL, hash, sizeof(hash), sig, sizeof(sig), &len, 0);
|
||||||
|
ok(ret == STATUS_INVALID_PARAMETER, "got %08x\n", ret);
|
||||||
|
|
||||||
|
ret = pBCryptSignHash(key, &pad, hash, sizeof(hash), sig, 0, &len, BCRYPT_PAD_PKCS1);
|
||||||
|
ok(ret == STATUS_BUFFER_TOO_SMALL, "got %08x\n", ret);
|
||||||
|
|
||||||
ret = pBCryptSignHash(key, &pad, hash, sizeof(hash), sig, sizeof(sig), &len, BCRYPT_PAD_PKCS1);
|
ret = pBCryptSignHash(key, &pad, hash, sizeof(hash), sig, sizeof(sig), &len, BCRYPT_PAD_PKCS1);
|
||||||
ok(!ret, "got %08x\n", ret);
|
ok(!ret, "got %08x\n", ret);
|
||||||
ok(len == 64, "got %u\n", len);
|
ok(len == 64, "got %u\n", len);
|
||||||
|
@ -2099,6 +2112,42 @@ static void test_BCryptSignHash(void)
|
||||||
|
|
||||||
ret = pBCryptCloseAlgorithmProvider(alg, 0);
|
ret = pBCryptCloseAlgorithmProvider(alg, 0);
|
||||||
ok(!ret, "got %08x\n", ret);
|
ok(!ret, "got %08x\n", ret);
|
||||||
|
|
||||||
|
/* ECDSA */
|
||||||
|
|
||||||
|
ret = pBCryptOpenAlgorithmProvider(&alg, BCRYPT_ECDSA_P256_ALGORITHM, NULL, 0);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
win_skip("failed to open ECDSA provider: %08x\n", ret);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = pBCryptGenerateKeyPair(alg, &key, 256, 0);
|
||||||
|
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
|
||||||
|
|
||||||
|
ret = pBCryptFinalizeKeyPair(key, 0);
|
||||||
|
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
|
||||||
|
|
||||||
|
memset(sig, 0, sizeof(sig));
|
||||||
|
len = 0;
|
||||||
|
|
||||||
|
/* automatically detects padding info */
|
||||||
|
ret = pBCryptSignHash(key, NULL, hash, sizeof(hash), sig, sizeof(sig), &len, 0);
|
||||||
|
ok (!ret, "got %08x\n", ret);
|
||||||
|
ok (len == 64, "got %u\n", len);
|
||||||
|
|
||||||
|
ret = pBCryptVerifySignature(key, NULL, hash, sizeof(hash), sig, len, 0);
|
||||||
|
ok(!ret, "got %08x\n", ret);
|
||||||
|
|
||||||
|
/* mismatch info (SHA-1 != SHA-256) */
|
||||||
|
ret = pBCryptSignHash(key, &pad, hash_sha256, sizeof(hash_sha256), sig, sizeof(sig), &len, BCRYPT_PAD_PKCS1);
|
||||||
|
ok (ret == STATUS_INVALID_PARAMETER, "got %08x\n", ret);
|
||||||
|
|
||||||
|
ret = pBCryptDestroyKey(key);
|
||||||
|
ok(!ret, "got %08x\n", ret);
|
||||||
|
|
||||||
|
ret = pBCryptCloseAlgorithmProvider(alg, 0);
|
||||||
|
ok(!ret, "got %08x\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_BCryptEnumAlgorithms(void)
|
static void test_BCryptEnumAlgorithms(void)
|
||||||
|
|
Loading…
Reference in New Issue