diff --git a/wolfcrypt/src/dh.c b/wolfcrypt/src/dh.c index 34c7a16a0..6e76a51f2 100644 --- a/wolfcrypt/src/dh.c +++ b/wolfcrypt/src/dh.c @@ -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, diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 532d77ed0..d28edca28 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -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, diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index d88d7aec6..d4cd1bc3f 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -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);