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); ctx = wolfSSL_CTX_new(method);
} }
if (ctx == NULL) {
goto done;
}
#if defined(HAVE_SESSION_TICKET) && \ #if defined(HAVE_SESSION_TICKET) && \
((defined(HAVE_CHACHA) && defined(HAVE_POLY1305)) || defined(HAVE_AESGCM)) ((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 }; byte id[] = { 0x01, 0x23, 0x34, 0x45 };
int ret; int ret;
mp_init(&ssk); (void)mp_init(&ssk);
pvt = wc_ecc_new_point(); pvt = wc_ecc_new_point();
wc_InitEccsiKey(&genKey, NULL, INVALID_DEVID); wc_InitEccsiKey(&genKey, NULL, INVALID_DEVID);
(void)wc_MakeEccsiKey(&genKey, &gRng); (void)wc_MakeEccsiKey(&genKey, &gRng);
@ -6227,7 +6227,7 @@ void bench_eccsiValidate(void)
int valid; int valid;
int ret; int ret;
mp_init(&ssk); (void)mp_init(&ssk);
pvt = wc_ecc_new_point(); pvt = wc_ecc_new_point();
wc_InitEccsiKey(&genKey, NULL, INVALID_DEVID); wc_InitEccsiKey(&genKey, NULL, INVALID_DEVID);
(void)wc_MakeEccsiKey(&genKey, &gRng); (void)wc_MakeEccsiKey(&genKey, &gRng);
@ -6272,7 +6272,7 @@ void bench_eccsi(void)
int ret; int ret;
int verified; int verified;
mp_init(&ssk); (void)mp_init(&ssk);
pvt = wc_ecc_new_point(); pvt = wc_ecc_new_point();
(void)wc_InitEccsiKey(&genKey, NULL, INVALID_DEVID); (void)wc_InitEccsiKey(&genKey, NULL, INVALID_DEVID);
(void)wc_MakeEccsiKey(&genKey, &gRng); (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); bench_stats_asym_finish("SAKKE", 1024, desc[10], 0, count, start, 0);
len = 0; len = 0;
wc_GenerateSakkeRskTable(&genKey, rsk, NULL, &len); (void)wc_GenerateSakkeRskTable(&genKey, rsk, NULL, &len);
if (len > 0) { if (len > 0) {
table = (byte*)XMALLOC(len, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); 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); (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); XMEMSET(h, 0, hashSz);
err = 0; /* reset err value after getting digest size */ 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 3: l = Ceiling(lg(n)/hashlen) */
/* Step 4: For each i in 1 to l, do */ /* 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; return -10117;
decPvt = wc_ecc_new_point(); decPvt = wc_ecc_new_point();
if (ret != 0) if (decPvt == NULL)
return -10118; return -10118;
ret = wc_EncodeEccsiPair(priv, ssk, pvt, NULL, &sz); 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 eccsi_test(void)
{ {
int ret; int ret = 0;
WC_RNG rng; WC_RNG rng;
EccsiKey* priv; EccsiKey* priv = NULL;
EccsiKey* pub; EccsiKey* pub = NULL;
mp_int* ssk; mp_int* ssk = NULL;
ecc_point* pvt; ecc_point* pvt = NULL;
priv = (EccsiKey*)XMALLOC(sizeof(EccsiKey), HEAP_HINT, priv = (EccsiKey*)XMALLOC(sizeof(EccsiKey), HEAP_HINT,
DYNAMIC_TYPE_TMP_BUFFER); DYNAMIC_TYPE_TMP_BUFFER);
if (priv == NULL) { if (priv == NULL) {
return -10205; ret = -10205;
} }
pub = (EccsiKey*)XMALLOC(sizeof(EccsiKey), HEAP_HINT,
if (ret == 0) {
pub = (EccsiKey*)XMALLOC(sizeof(EccsiKey), HEAP_HINT,
DYNAMIC_TYPE_TMP_BUFFER); DYNAMIC_TYPE_TMP_BUFFER);
if (pub == NULL) { if (pub == NULL) {
XFREE(priv, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); ret = -10206;
return -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;
} }
#ifndef HAVE_FIPS if (ret == 0) {
ret = wc_InitRng_ex(&rng, HEAP_HINT, devId); ssk = (mp_int*)XMALLOC(sizeof(mp_int), HEAP_HINT,
#else DYNAMIC_TYPE_TMP_BUFFER);
ret = wc_InitRng(&rng); if (ssk == NULL) {
#endif ret = -10207;
if (ret != 0) }
return -10200; }
pvt = wc_ecc_new_point(); if (ret == 0) {
if (pvt == NULL) #ifndef HAVE_FIPS
return -10201; ret = wc_InitRng_ex(&rng, HEAP_HINT, devId);
ret = mp_init(ssk); #else
if (ret != 0) ret = wc_InitRng(&rng);
return -10202; #endif
if (ret != 0)
ret = -10200;
}
ret = eccsi_api_test(&rng, priv, ssk, pvt); if (ret == 0) {
if (ret != 0) pvt = wc_ecc_new_point();
return ret; if (pvt == NULL)
ret = -10201;
}
ret = wc_InitEccsiKey(pub, HEAP_HINT, INVALID_DEVID); if (ret == 0) {
if (ret != 0) ret = mp_init(ssk);
return -10203; if (ret != 0)
ret = -10202;
}
ret = wc_InitEccsiKey(priv, HEAP_HINT, INVALID_DEVID); if (ret == 0) {
if (ret != 0) ret = eccsi_api_test(&rng, priv, ssk, pvt);
return -10204; }
ret = eccsi_kat_verify_test(pub, pvt); if (ret == 0) {
if (ret != 0) ret = wc_InitEccsiKey(pub, HEAP_HINT, INVALID_DEVID);
return ret; if (ret != 0)
ret = -10203;
}
ret = eccsi_make_key_test(priv, pub, &rng, ssk, pvt); if (ret == 0) {
if (ret != 0) ret = wc_InitEccsiKey(priv, HEAP_HINT, INVALID_DEVID);
return ret; if (ret != 0)
ret = -10204;
}
ret = eccsi_sign_verify_test(priv, pub, &rng, ssk, pvt); if (ret == 0) {
if (ret != 0) ret = eccsi_kat_verify_test(pub, pvt);
return ret; }
if (ret == 0) {
ret = eccsi_make_key_test(priv, pub, &rng, ssk, pvt);
}
if (ret == 0) {
ret = eccsi_sign_verify_test(priv, pub, &rng, ssk, pvt);
}
wc_FreeEccsiKey(priv); wc_FreeEccsiKey(priv);
wc_FreeEccsiKey(pub); wc_FreeEccsiKey(pub);
mp_free(ssk); mp_free(ssk);
wc_ecc_del_point(pvt); wc_ecc_del_point(pvt);
wc_FreeRng(&rng);
XFREE(ssk, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(pub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(priv, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
return 0; 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 ret;
} }
#endif /* WOLFCRYPT_HAVE_ECCSI */ #endif /* WOLFCRYPT_HAVE_ECCSI */