@@ -300,7 +300,7 @@ int test_wolfSSL_i2d_ECPKParameters(void)
300300int test_wolfSSL_EC_POINT (void )
301301{
302302 EXPECT_DECLS ;
303- #if !defined(WOLFSSL_SP_MATH ) && \
303+ #if !defined(WOLFSSL_SP_MATH ) && !defined( WOLF_CRYPTO_CB_ONLY_ECC ) && \
304304 (!defined(HAVE_FIPS ) || (defined(HAVE_FIPS_VERSION ) && (HAVE_FIPS_VERSION > 2 )))
305305
306306#ifdef OPENSSL_EXTRA
@@ -1659,6 +1659,44 @@ int test_ECDSA_size_sign(void)
16591659 return EXPECT_RESULT ();
16601660}
16611661
1662+ int test_ECDSA_do_verify_oversized_sig (void )
1663+ {
1664+ EXPECT_DECLS ;
1665+ /* NO_RSA builds may size big integers too small to hold an r of
1666+ * ECC_MAX_SIG_SIZE bytes. */
1667+ #if defined(OPENSSL_EXTRA ) && !defined(NO_ECC256 ) && !defined(NO_ECC_SECP ) && \
1668+ !defined(NO_RSA )
1669+ EC_KEY * key = NULL ;
1670+ ECDSA_SIG * sig = NULL ;
1671+ BIGNUM * r = NULL ;
1672+ BIGNUM * s = NULL ;
1673+ byte hash [WC_MAX_DIGEST_SIZE ];
1674+ byte big [ECC_MAX_SIG_SIZE ];
1675+
1676+ XMEMSET (hash , 123 , sizeof (hash ));
1677+ XMEMSET (big , 0xff , sizeof (big ));
1678+
1679+ ExpectNotNull (key = EC_KEY_new_by_curve_name (NID_X9_62_prime256v1 ));
1680+ ExpectNotNull (sig = ECDSA_SIG_new ());
1681+ /* r alone DER encodes to more than ECC_MAX_SIG_SIZE bytes. */
1682+ ExpectNotNull (r = BN_bin2bn (big , (int )sizeof (big ), NULL ));
1683+ ExpectNotNull (s = BN_new ());
1684+ ExpectIntEQ (BN_set_word (s , 1 ), 1 );
1685+ ExpectIntEQ (ECDSA_SIG_set0 (sig , r , s ), 1 );
1686+ if (EXPECT_FAIL ()) {
1687+ BN_free (r );
1688+ BN_free (s );
1689+ }
1690+
1691+ ExpectIntEQ (ECDSA_do_verify (hash , sizeof (hash ), sig , key ),
1692+ WOLFSSL_FATAL_ERROR );
1693+
1694+ ECDSA_SIG_free (sig );
1695+ EC_KEY_free (key );
1696+ #endif
1697+ return EXPECT_RESULT ();
1698+ }
1699+
16621700int test_ECDH_compute_key (void )
16631701{
16641702 EXPECT_DECLS ;
0 commit comments