mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
tests/api.c: in test_wc_ecc_verify_hash_ex(), check that passing zero r and/or s to wc_ecc_verify_hash_ex() returns MP_ZERO_E.
This commit is contained in:
committed by
Daniele Lacamera
parent
cfab451328
commit
4a4b019e30
15
tests/api.c
15
tests/api.c
@@ -25915,6 +25915,7 @@ static int test_wc_ecc_verify_hash_ex (void)
|
|||||||
WC_RNG rng;
|
WC_RNG rng;
|
||||||
mp_int r;
|
mp_int r;
|
||||||
mp_int s;
|
mp_int s;
|
||||||
|
mp_int z;
|
||||||
unsigned char hash[] = "Everyone gets Friday off.EccSig";
|
unsigned char hash[] = "Everyone gets Friday off.EccSig";
|
||||||
unsigned char iHash[] = "Everyone gets Friday off.......";
|
unsigned char iHash[] = "Everyone gets Friday off.......";
|
||||||
unsigned char shortHash[] = TEST_STRING;
|
unsigned char shortHash[] = TEST_STRING;
|
||||||
@@ -25927,7 +25928,7 @@ static int test_wc_ecc_verify_hash_ex (void)
|
|||||||
int verify_ok = 0;
|
int verify_ok = 0;
|
||||||
|
|
||||||
/* Initialize r and s. */
|
/* Initialize r and s. */
|
||||||
ret = mp_init_multi(&r, &s, NULL, NULL, NULL, NULL);
|
ret = mp_init_multi(&r, &s, &z, NULL, NULL, NULL);
|
||||||
if (ret != MP_OKAY) {
|
if (ret != MP_OKAY) {
|
||||||
return MP_INIT_E;
|
return MP_INIT_E;
|
||||||
}
|
}
|
||||||
@@ -26005,6 +26006,18 @@ static int test_wc_ecc_verify_hash_ex (void)
|
|||||||
&verify_ok, &key) != ECC_BAD_ARG_E) {
|
&verify_ok, &key) != ECC_BAD_ARG_E) {
|
||||||
ver = WOLFSSL_FATAL_ERROR;
|
ver = WOLFSSL_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
|
if (wc_ecc_verify_hash_ex(&z, &s, shortHash, shortHashLen, &verify_ok, &key)
|
||||||
|
!= MP_ZERO_E) {
|
||||||
|
ver = WOLFSSL_FATAL_ERROR;
|
||||||
|
}
|
||||||
|
if (wc_ecc_verify_hash_ex(&r, &z, shortHash, shortHashLen, &verify_ok, &key)
|
||||||
|
!= MP_ZERO_E) {
|
||||||
|
ver = WOLFSSL_FATAL_ERROR;
|
||||||
|
}
|
||||||
|
if (wc_ecc_verify_hash_ex(&z, &z, shortHash, shortHashLen, &verify_ok, &key)
|
||||||
|
!= MP_ZERO_E) {
|
||||||
|
ver = WOLFSSL_FATAL_ERROR;
|
||||||
|
}
|
||||||
if (ver == 0 && wc_ecc_verify_hash_ex(&r, &s, NULL, shortHashLen, &verify_ok,
|
if (ver == 0 && wc_ecc_verify_hash_ex(&r, &s, NULL, shortHashLen, &verify_ok,
|
||||||
&key) != ECC_BAD_ARG_E) {
|
&key) != ECC_BAD_ARG_E) {
|
||||||
ver = WOLFSSL_FATAL_ERROR;
|
ver = WOLFSSL_FATAL_ERROR;
|
||||||
|
Reference in New Issue
Block a user