Skip to content

Commit ece75b4

Browse files
committed
Remove 9-bit prime generation testing, disallowed with DH_MIN_SIZE
1 parent 9850c44 commit ece75b4

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
@@ -29955,18 +29955,6 @@ static wc_test_ret_t dh_generate_test(WC_RNG *rng)
2995529955
#endif
2995629956
byte p[2] = { 1, 7 }; /* 263 in decimal */
2995729957
byte g[2] = { 0, 2 };
29958-
#if !defined(WOLFSSL_SP_MATH) && !defined(HAVE_FFDHE)
29959-
#ifdef WOLFSSL_DH_CONST
29960-
/* the table for constant DH lookup will round to the lowest byte size 21 */
29961-
byte priv[21];
29962-
byte pub[21];
29963-
#else
29964-
byte priv[2];
29965-
byte pub[2];
29966-
#endif
29967-
word32 privSz = sizeof(priv);
29968-
word32 pubSz = sizeof(pub);
29969-
#endif
2997029958
int smallKey_inited = 0;
2997129959

2997229960
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
@@ -30009,30 +29997,12 @@ static wc_test_ret_t dh_generate_test(WC_RNG *rng)
3000929997
if (ret != 0)
3001029998
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit_gen_test);
3001129999

30012-
#if !defined(WOLFSSL_SP_MATH) && !defined(HAVE_FFDHE)
30013-
/* Use API. p is a 9-bit prime: key generation is rejected with
30014-
* WC_KEY_SIZE_E unless DH_MIN_SIZE permits a prime this small. */
30015-
ret = wc_DhGenerateKeyPair(smallKey, rng, priv, &privSz, pub, &pubSz);
30016-
#if defined(WOLFSSL_ASYNC_CRYPT)
30017-
ret = wc_AsyncWait(ret, &smallKey->asyncDev, WC_ASYNC_FLAG_NONE);
30018-
#endif
30019-
#if DH_MIN_SIZE > 9
30020-
if (ret == WC_NO_ERR_TRACE(WC_KEY_SIZE_E))
30021-
ret = 0;
30022-
else if (ret == 0)
30023-
ret = WC_TEST_RET_ENC_NC; /* should have been rejected */
30024-
else
30025-
ret = WC_TEST_RET_ENC_EC(ret);
30026-
#else
30027-
if (ret != 0) {
30028-
ret = WC_TEST_RET_ENC_EC(ret);
30029-
}
30030-
#endif
30031-
#else
30000+
/* Generation with this sub-DH_MIN_SIZE prime is intentionally not
30001+
* exercised here; wc_DhGenerateKeyPair is covered with a valid group in
30002+
* dh_fips_generate_test. */
3003230003
(void)rng;
30033-
#if defined(HAVE_FIPS) || !defined(WOLFSSL_NO_DH186)
30004+
#if defined(HAVE_FIPS) || !defined(WOLFSSL_NO_DH186)
3003430005
ret = 0;
30035-
#endif
3003630006
#endif
3003730007

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

0 commit comments

Comments
 (0)