Skip to content

Commit f15681a

Browse files
committed
Remove 9-bit prime generation testing, disallowed with DH_MIN_SIZE
1 parent 53fe0b3 commit f15681a

1 file changed

Lines changed: 4 additions & 34 deletions

File tree

wolfcrypt/test/test.c

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30003,18 +30003,6 @@ static wc_test_ret_t dh_generate_test(WC_RNG *rng)
3000330003
#endif
3000430004
byte p[2] = { 1, 7 }; /* 263 in decimal */
3000530005
byte g[2] = { 0, 2 };
30006-
#if !defined(WOLFSSL_SP_MATH) && !defined(HAVE_FFDHE)
30007-
#ifdef WOLFSSL_DH_CONST
30008-
/* the table for constant DH lookup will round to the lowest byte size 21 */
30009-
byte priv[21];
30010-
byte pub[21];
30011-
#else
30012-
byte priv[2];
30013-
byte pub[2];
30014-
#endif
30015-
word32 privSz = sizeof(priv);
30016-
word32 pubSz = sizeof(pub);
30017-
#endif
3001830006
int smallKey_inited = 0;
3001930007

3002030008
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
@@ -30057,30 +30045,12 @@ static wc_test_ret_t dh_generate_test(WC_RNG *rng)
3005730045
if (ret != 0)
3005830046
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit_gen_test);
3005930047

30060-
#if !defined(WOLFSSL_SP_MATH) && !defined(HAVE_FFDHE)
30061-
/* Use API. p is a 9-bit prime: key generation is rejected with
30062-
* WC_KEY_SIZE_E unless DH_MIN_SIZE permits a prime this small. */
30063-
ret = wc_DhGenerateKeyPair(smallKey, rng, priv, &privSz, pub, &pubSz);
30064-
#if defined(WOLFSSL_ASYNC_CRYPT)
30065-
ret = wc_AsyncWait(ret, &smallKey->asyncDev, WC_ASYNC_FLAG_NONE);
30066-
#endif
30067-
#if DH_MIN_SIZE > 9
30068-
if (ret == WC_NO_ERR_TRACE(WC_KEY_SIZE_E))
30069-
ret = 0;
30070-
else if (ret == 0)
30071-
ret = WC_TEST_RET_ENC_NC; /* should have been rejected */
30072-
else
30073-
ret = WC_TEST_RET_ENC_EC(ret);
30074-
#else
30075-
if (ret != 0) {
30076-
ret = WC_TEST_RET_ENC_EC(ret);
30077-
}
30078-
#endif
30079-
#else
30048+
/* Generation with this sub-DH_MIN_SIZE prime is intentionally not
30049+
* exercised here; wc_DhGenerateKeyPair is covered with a valid group in
30050+
* dh_fips_generate_test. */
3008030051
(void)rng;
30081-
#if defined(HAVE_FIPS) || !defined(WOLFSSL_NO_DH186)
30052+
#if defined(HAVE_FIPS) || !defined(WOLFSSL_NO_DH186)
3008230053
ret = 0;
30083-
#endif
3008430054
#endif
3008530055

3008630056
#if !defined(HAVE_FIPS) && defined(WOLFSSL_NO_DH186)

0 commit comments

Comments
 (0)