Test Fixes

1. When building on VS, it didn't like using a variable for an array size. Fixed it so it was a constant.
2. In dh.c, there were a few #if that should have been #ifdef.
3. Tweaked a return value in the wolfCrypt test so it was read after being set.
cert-3389
John Safranek 2018-05-09 14:08:22 -07:00
parent 12edf80e2b
commit 6a31f103aa
3 changed files with 10 additions and 9 deletions

View File

@ -202,7 +202,7 @@ static const byte dh_ffdhe3072_p[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
static const byte dh_ffdhe3072_g[] = { 0x02 };
#if HAVE_FFDHE_Q
#ifdef HAVE_FFDHE_Q
static const byte dh_ffdhe3072_q[] = {
0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xD6, 0xFC, 0x2A, 0x2C, 0x51, 0x5D, 0xA5, 0x4D,
@ -336,7 +336,7 @@ static const byte dh_ffdhe4096_p[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
static const byte dh_ffdhe4096_g[] = { 0x02 };
#if HAVE_FFDHE_Q
#ifdef HAVE_FFDHE_Q
static const byte dh_ffdhe4096_q[] = {
0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xD6, 0xFC, 0x2A, 0x2C, 0x51, 0x5D, 0xA5, 0x4D,
@ -518,7 +518,7 @@ static const byte dh_ffdhe6144_p[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
static const byte dh_ffdhe6144_g[] = { 0x02 };
#if HAVE_FFDHE_Q
#ifdef HAVE_FFDHE_Q
static const byte dh_ffdhe6144_q[] = {
0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xD6, 0xFC, 0x2A, 0x2C, 0x51, 0x5D, 0xA5, 0x4D,
@ -764,7 +764,7 @@ static const byte dh_ffdhe8192_p[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
static const byte dh_ffdhe8192_g[] = { 0x02 };
#if HAVE_FFDHE_Q
#ifdef HAVE_FFDHE_Q
static const byte dh_ffdhe8192_g[] = {
0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xD6, 0xFC, 0x2A, 0x2C, 0x51, 0x5D, 0xA5, 0x4D,

View File

@ -177,6 +177,7 @@ int wc_RNG_GenerateByte(WC_RNG* rng, byte* b)
#define RESEED_INTERVAL WC_RESEED_INTERVAL
#define SECURITY_STRENGTH (2048)
#define ENTROPY_SZ (SECURITY_STRENGTH/8)
#define MAX_ENTROPY_SZ (ENTROPY_SZ + ENTROPY_SZ/2)
/* Internal return codes */
#define DRBG_SUCCESS 0
@ -586,10 +587,10 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
#else
#ifdef HAVE_HASHDRBG
if (nonceSz == 0)
entropySz += (entropySz / 2);
entropySz = MAX_ENTROPY_SZ;
if (wc_RNG_HealthTestLocal(0) == 0) {
DECLARE_VAR(entropy, byte, entropySz, rng->heap);
DECLARE_VAR(entropy, byte, MAX_ENTROPY_SZ, rng->heap);
rng->drbg =
(struct DRBG*)XMALLOC(sizeof(DRBG), rng->heap,

View File

@ -10778,7 +10778,7 @@ static int dh_fips_generate_test(WC_RNG *rng)
ret = wc_AsyncWait(ret, &key.asyncDev, WC_ASYNC_FLAG_NONE);
#endif
if (ret != 0) {
ret = -5727;
ERROR_OUT(-5727, exit_gen_test);
}
ret = wc_DhCheckKeyPair(&key, pub, pubSz, priv, privSz);
@ -10792,8 +10792,6 @@ static int dh_fips_generate_test(WC_RNG *rng)
if (ret != MP_CMP_E) {
ERROR_OUT(-8230, exit_gen_test);
}
else
ret = 0;
#ifdef WOLFSSL_KEY_GEN
@ -10812,6 +10810,8 @@ static int dh_fips_generate_test(WC_RNG *rng)
#endif /* WOLFSSL_KEY_GEN */
ret = 0;
exit_gen_test:
wc_FreeDhKey(&key);