additional fixes for reports with test cases

This commit is contained in:
Jacob Barthelmeh
2021-03-26 20:23:40 +07:00
parent 71fea2bdd1
commit 9a86f133c8
4 changed files with 85 additions and 58 deletions

View File

@ -2748,6 +2748,9 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_nofail(void* args)
}
ctx = wolfSSL_CTX_new(method);
}
if (ctx == NULL) {
goto done;
}
#if defined(HAVE_SESSION_TICKET) && \
((defined(HAVE_CHACHA) && defined(HAVE_POLY1305)) || defined(HAVE_AESGCM))

View File

@ -6188,7 +6188,7 @@ void bench_eccsiPairGen(void)
byte id[] = { 0x01, 0x23, 0x34, 0x45 };
int ret;
mp_init(&ssk);
(void)mp_init(&ssk);
pvt = wc_ecc_new_point();
wc_InitEccsiKey(&genKey, NULL, INVALID_DEVID);
(void)wc_MakeEccsiKey(&genKey, &gRng);
@ -6227,7 +6227,7 @@ void bench_eccsiValidate(void)
int valid;
int ret;
mp_init(&ssk);
(void)mp_init(&ssk);
pvt = wc_ecc_new_point();
wc_InitEccsiKey(&genKey, NULL, INVALID_DEVID);
(void)wc_MakeEccsiKey(&genKey, &gRng);
@ -6272,7 +6272,7 @@ void bench_eccsi(void)
int ret;
int verified;
mp_init(&ssk);
(void)mp_init(&ssk);
pvt = wc_ecc_new_point();
(void)wc_InitEccsiKey(&genKey, NULL, INVALID_DEVID);
(void)wc_MakeEccsiKey(&genKey, &gRng);
@ -6518,10 +6518,10 @@ void bench_sakke(void)
bench_stats_asym_finish("SAKKE", 1024, desc[10], 0, count, start, 0);
len = 0;
wc_GenerateSakkeRskTable(&genKey, rsk, NULL, &len);
(void)wc_GenerateSakkeRskTable(&genKey, rsk, NULL, &len);
if (len > 0) {
table = (byte*)XMALLOC(len, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
wc_GenerateSakkeRskTable(&genKey, rsk, table, &len);
(void)wc_GenerateSakkeRskTable(&genKey, rsk, table, &len);
}
(void)wc_SetSakkeRsk(&genKey, rsk, table, len);

View File

@ -6134,6 +6134,10 @@ static int sakke_hash_to_range(SakkeKey* key, enum wc_HashType hashType,
XMEMSET(h, 0, hashSz);
err = 0; /* reset err value after getting digest size */
}
else if (err == 0) {
/* invalid hash digest size */
err = BAD_FUNC_ARG;
}
/* Step 3: l = Ceiling(lg(n)/hashlen) */
/* Step 4: For each i in 1 to l, do */

View File

@ -27281,7 +27281,7 @@ static int eccsi_enc_dec_pair_test(EccsiKey* priv, mp_int* ssk, ecc_point* pvt)
return -10117;
decPvt = wc_ecc_new_point();
if (ret != 0)
if (decPvt == NULL)
return -10118;
ret = wc_EncodeEccsiPair(priv, ssk, pvt, NULL, &sz);
@ -27645,80 +27645,100 @@ static int eccsi_sign_verify_test(EccsiKey* priv, EccsiKey* pub, WC_RNG* rng,
int eccsi_test(void)
{
int ret;
int ret = 0;
WC_RNG rng;
EccsiKey* priv;
EccsiKey* pub;
mp_int* ssk;
ecc_point* pvt;
EccsiKey* priv = NULL;
EccsiKey* pub = NULL;
mp_int* ssk = NULL;
ecc_point* pvt = NULL;
priv = (EccsiKey*)XMALLOC(sizeof(EccsiKey), HEAP_HINT,
DYNAMIC_TYPE_TMP_BUFFER);
if (priv == NULL) {
return -10205;
ret = -10205;
}
if (ret == 0) {
pub = (EccsiKey*)XMALLOC(sizeof(EccsiKey), HEAP_HINT,
DYNAMIC_TYPE_TMP_BUFFER);
if (pub == NULL) {
XFREE(priv, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
return -10206;
ret = -10206;
}
ssk = (mp_int*)XMALLOC(sizeof(mp_int), HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
if (ssk == NULL) {
XFREE(pub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(priv, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
return -10207;
}
if (ret == 0) {
ssk = (mp_int*)XMALLOC(sizeof(mp_int), HEAP_HINT,
DYNAMIC_TYPE_TMP_BUFFER);
if (ssk == NULL) {
ret = -10207;
}
}
if (ret == 0) {
#ifndef HAVE_FIPS
ret = wc_InitRng_ex(&rng, HEAP_HINT, devId);
#else
ret = wc_InitRng(&rng);
#endif
if (ret != 0)
return -10200;
ret = -10200;
}
if (ret == 0) {
pvt = wc_ecc_new_point();
if (pvt == NULL)
return -10201;
ret = -10201;
}
if (ret == 0) {
ret = mp_init(ssk);
if (ret != 0)
return -10202;
ret = -10202;
}
if (ret == 0) {
ret = eccsi_api_test(&rng, priv, ssk, pvt);
if (ret != 0)
return ret;
}
if (ret == 0) {
ret = wc_InitEccsiKey(pub, HEAP_HINT, INVALID_DEVID);
if (ret != 0)
return -10203;
ret = -10203;
}
if (ret == 0) {
ret = wc_InitEccsiKey(priv, HEAP_HINT, INVALID_DEVID);
if (ret != 0)
return -10204;
ret = -10204;
}
if (ret == 0) {
ret = eccsi_kat_verify_test(pub, pvt);
if (ret != 0)
return ret;
}
if (ret == 0) {
ret = eccsi_make_key_test(priv, pub, &rng, ssk, pvt);
if (ret != 0)
return ret;
}
if (ret == 0) {
ret = eccsi_sign_verify_test(priv, pub, &rng, ssk, pvt);
if (ret != 0)
return ret;
}
wc_FreeEccsiKey(priv);
wc_FreeEccsiKey(pub);
mp_free(ssk);
wc_ecc_del_point(pvt);
if (ret != -10200)
wc_FreeRng(&rng);
if (ssk != NULL)
XFREE(ssk, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
if (pub != NULL)
XFREE(pub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
if (priv != NULL)
XFREE(priv, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
return 0;
return ret;
}
#endif /* WOLFCRYPT_HAVE_ECCSI */