Skip to content

Commit 14254e8

Browse files
authored
Merge pull request #7862 from bigbrett/wc-test-nocryptocb
cryptocb test disable option
2 parents 0c24aff + 10a3634 commit 14254e8

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,10 @@ add_option("WOLFSSL_CRYPTOCB"
18771877
"Enable crypto callbacks (default: disabled)"
18781878
"no" "yes;no")
18791879

1880+
add_option("WOLFSSL_CRYPTOCB_NO_SW_TEST"
1881+
"Disable crypto callback SW testing (default: disabled)"
1882+
"no" "yes;no")
1883+
18801884
add_option("WOLFSSL_PKCALLBACKS"
18811885
"Enable public key callbacks (default: disabled)"
18821886
"no" "yes;no")
@@ -2080,6 +2084,10 @@ if(WOLFSSL_CRYPTOCB)
20802084
list(APPEND WOLFSSL_DEFINITIONS "-DWOLF_CRYPTO_CB")
20812085
endif()
20822086

2087+
if(WOLFSSL_CRYPTOCB_NO_SW_TEST)
2088+
list(APPEND WOLFSSL_DEFINITIONS "-DWC_TEST_NO_CRYPTOCB_SW_TEST")
2089+
endif()
2090+
20832091
# Public Key Callbacks
20842092
if(WOLFSSL_PKCALLBACKS)
20852093
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_PK_CALLBACKS")

configure.ac

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8475,6 +8475,19 @@ AC_ARG_ENABLE([cryptocb],
84758475
[ ENABLED_CRYPTOCB=no ]
84768476
)
84778477
8478+
# Enable testing of cryptoCb using software crypto. On platforms where wolfCrypt tests
8479+
# are used to test a custom cryptoCb, it may be desired to disable this so wolfCrypt tests
8480+
# don't also test software implementations of every algorithm
8481+
AC_ARG_ENABLE([cryptocb-sw-test],
8482+
[AS_HELP_STRING([--disable-cryptocb-sw-test],[Disable wolfCrypt crypto callback tests using software crypto (default: enabled). Only valid with --enable-cryptocb])],
8483+
[ if test "x$ENABLED_CRYPTOCB" = "xno"; then
8484+
AC_MSG_ERROR([--disable-cryptocb-sw-test requires --enable-cryptocb])
8485+
else
8486+
ENABLED_CRYPTOCB_SW_TEST=$enableval
8487+
fi ],
8488+
[ ENABLED_CRYPTOCB_SW_TEST=yes ]
8489+
)
8490+
84788491
if test "x$ENABLED_PKCS11" = "xyes" || test "x$ENABLED_WOLFTPM" = "xyes" || test "$ENABLED_CAAM" != "no"
84798492
then
84808493
ENABLED_CRYPTOCB=yes
@@ -8484,6 +8497,11 @@ then
84848497
AM_CFLAGS="$AM_CFLAGS -DWOLF_CRYPTO_CB"
84858498
fi
84868499
8500+
if test "$ENABLED_CRYPTOCB_SW_TEST" = "no"
8501+
then
8502+
AM_CFLAGS="$AM_CFLAGS -DWC_TEST_NO_CRYPTOCB_SW_TEST"
8503+
fi
8504+
84878505
84888506
84898507
# Asynchronous Crypto

wolfcrypt/test/test.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ void printOutput(const char *strName, unsigned char *data, unsigned int dataSz);
735735
WOLFSSL_TEST_SUBROUTINE int ariagcm_test(MC_ALGID);
736736
#endif
737737

738-
#ifdef WOLF_CRYPTO_CB
738+
#if defined(WOLF_CRYPTO_CB) && !defined(WC_TEST_NO_CRYPTOCB_SW_TEST)
739739
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t cryptocb_test(void);
740740
#endif
741741
#ifdef WOLFSSL_CERT_PIV
@@ -2321,7 +2321,7 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
23212321
TEST_PASS("blob test passed!\n");
23222322
#endif
23232323

2324-
#if defined(WOLF_CRYPTO_CB) && \
2324+
#if defined(WOLF_CRYPTO_CB) && !defined(WC_TEST_NO_CRYPTOCB_SW_TEST) && \
23252325
!(defined(HAVE_INTEL_QAT_SYNC) || defined(HAVE_CAVIUM_OCTEON_SYNC) || \
23262326
defined(WOLFSSL_QNX_CAAM) || defined(HAVE_RENESAS_SYNC))
23272327
if ( (ret = cryptocb_test()) != 0)
@@ -55572,6 +55572,7 @@ static int myCryptoCbFind(int currentId, int algoType)
5557255572
#endif /* WOLF_CRYPTO_CB_FIND */
5557355573

5557455574

55575+
#if !defined(WC_TEST_NO_CRYPTOCB_SW_TEST)
5557555576
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t cryptocb_test(void)
5557655577
{
5557755578
wc_test_ret_t ret = 0;
@@ -55700,6 +55701,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t cryptocb_test(void)
5570055701

5570155702
return ret;
5570255703
}
55704+
#endif /* ! WC_TEST_NO_CRYPTOCB_SW_TEST */
5570355705
#endif /* WOLF_CRYPTO_CB */
5570455706

5570555707
#ifdef WOLFSSL_CERT_PIV

0 commit comments

Comments
 (0)