Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0f82b9e
tests/swdev: add scaffolding for WOLF_CRYPTO_CB_ONLY_* testing
rizlik Apr 22, 2026
6fb617a
tests/swdev: add ECC support to wc_swdev
rizlik Apr 22, 2026
8f0d4db
tests/swdev: add RSA support to wc_swdev
rizlik Apr 22, 2026
65b49b2
_CRYPTO_CB_ONLY_{RSA,ECC,SHA256,AES}: move WOLF_CRYPTO_CB guards to s…
rizlik Apr 22, 2026
61bfff1
WOLF_CRYPTO_CB_ONLY_SHA256: strip software SHA-256 and dispatch via s…
rizlik Apr 29, 2026
c5ef060
WOLF_CRYPTO_CB_ONLY_AES: add support + swdev for testing
rizlik Apr 29, 2026
ade53b0
CRYPTO_CB_ONLY_SHA256: fix: guard Sha256FinalRaw under CB_ONLY_SHA256
rizlik Apr 30, 2026
df2fd4e
swdev: refcount swdev Init/Cleanup
rizlik Apr 30, 2026
438e512
test: use XFREE to pair XMALLOC
rizlik Apr 30, 2026
c926aaf
swdev: add copyright headers
rizlik May 5, 2026
799f7d4
swdev: support user_settings.h based main library builds
rizlik May 5, 2026
6d4fa59
tests:api: skip TLS_CALLBACK_TEST under CRYPTO_CB_ONLY_*
rizlik May 6, 2026
71819bc
swdev: pair internal wolfCrypt_Init() with wolfCrypt_Cleanup()
rizlik May 6, 2026
31891ea
swdev: always add swdev files to EXTRA_DISK
rizlik May 8, 2026
b1a3d72
github ci: minor rewording
rizlik May 12, 2026
c84ea8d
tests: api: remove extra wolfSSL_cleanup()
rizlik May 12, 2026
a98d479
tests: swdev: api: init/deinit swdev in TestSetup/TestCleanup
rizlik May 12, 2026
cf6c645
aes: CRYPTO_ONLY_AES: do keyscheduling to support GCM on ECB-only device
rizlik May 12, 2026
e03bc94
swdev: add AES-ECB only testing option
rizlik May 12, 2026
6c2040a
swdev: add README.md
rizlik May 12, 2026
cbaf9c1
cryptocb: don't declare wc_Sha256Trasnform under ONLY_SHA256
rizlik May 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/workflows/cryptocb-only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: cryptocb-only Tests

# START OF COMMON SECTION
on:
push:
branches: [ 'master', 'main', 'release/**' ]
pull_request:
branches: [ '*' ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# END OF COMMON SECTION

jobs:
make_check:
strategy:
fail-fast: false
matrix:
include:
# WOLF_CRYPTO_CB_ONLY_ECC: strips software ECC; swdev provides the
# software path via cryptocb. FP_ECC / ECCSI / SAKKE / deterministic-k
# test / OPENSSL_EXTRA compat layer all reference stripped primitives
# directly, so they stay off.
- name: ECC
cppflags: -DWOLF_CRYPTO_CB_ONLY_ECC
# WOLF_CRYPTO_CB_ONLY_RSA: strips software RSA; swdev provides the
# software path via cryptocb.
- name: RSA
cppflags: -DWOLF_CRYPTO_CB_ONLY_RSA
# WOLF_CRYPTO_CB_ONLY_SHA256: strips software SHA-256; swdev provides
# the software path via cryptocb. SHA-224 not yet supported.
- name: SHA256
extra_config: --disable-sha224
cppflags: -DWOLF_CRYPTO_CB_ONLY_SHA256
# WOLF_CRYPTO_CB_ONLY_AES: strips software AES; swdev provides the
# software path via cryptocb.
- name: AES
cppflags: -DWOLF_CRYPTO_CB_ONLY_AES
# Same as AES but tells swdev to refuse AES-GCM (SWDEV_AES_ONLYECB).
# That forces the parent's CB_ONLY_AES host-side GCM software path:
# GHASH runs on the host while AES-CTR blocks dispatch back through
# cryptocb ECB. The AES entry above instead has swdev handle GCM
# end-to-end, so the host-side GCM path is otherwise uncovered.
- name: AES_GCM_via_ECB
cppflags: -DWOLF_CRYPTO_CB_ONLY_AES -DSWDEV_AES_ONLYECB
# All four ONLY_* macros at once: every supported software primitive
# is stripped and dispatched through cryptocb. Catches any cross-
# algorithm call that a single-strip entry would still resolve via
# the remaining software paths.
- name: ALL
extra_config: --disable-sha224
cppflags: >-
-DWOLF_CRYPTO_CB_ONLY_ECC -DWOLF_CRYPTO_CB_ONLY_RSA
-DWOLF_CRYPTO_CB_ONLY_SHA256 -DWOLF_CRYPTO_CB_ONLY_AES
name: make check (${{ matrix.name }})
if: github.repository_owner == 'wolfssl'
runs-on: ubuntu-24.04
timeout-minutes: 10
env:
# Common feature set for every entry.
BASE_CONFIG: >-
--enable-swdev --enable-cryptocb --enable-ecc --enable-rsa --enable-dh
--enable-aesgcm --enable-aesccm --enable-aesctr --enable-aescfb
--enable-aeskeywrap --enable-aessiv --enable-aesofb --enable-aesxts
--enable-camellia --enable-chacha --enable-poly1305
--enable-sha --enable-sha3 --enable-shake128 --enable-shake256
--enable-blake2 --enable-blake2s
--enable-hkdf --enable-hashdrbg --enable-hashflags
--enable-curve25519 --enable-ed25519 --enable-curve448 --enable-ed448
--enable-mlkem --enable-dilithium
--enable-scrypt --enable-pwdbased --enable-pkcs7 --enable-pkcs12
--enable-certgen --enable-certreq --enable-certext
--enable-keygen --enable-asn=all
--enable-cmac --enable-xchacha
--enable-crl --enable-ocsp --enable-ocspstapling --enable-ocspstapling2
--enable-dtls --enable-dtls13 --enable-tls13
steps:
- uses: actions/checkout@v4
name: Checkout wolfSSL

- name: Test wolfSSL
run: |
./autogen.sh
./configure $BASE_CONFIG ${{ matrix.extra_config }} CPPFLAGS="${{ matrix.cppflags }}"
make -j 4
make check

- name: Print errors
if: ${{ failure() }}
run: |
for file in scripts/*.log
do
if [ -f "$file" ]; then
echo "${file}:"
cat "$file"
fi
done
27 changes: 26 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -10648,6 +10648,25 @@ if test "$ENABLED_CRYPTOCB_UTILS" != "no"; then
fi


# wc_swdev: software crypto-callback device for testing
AC_ARG_ENABLE([swdev],
[AS_HELP_STRING([--enable-swdev],[Build wc_swdev software crypto-callback for tests (default: disabled). Requires --enable-cryptocb])],
[ ENABLED_SWDEV=$enableval ],
[ ENABLED_SWDEV=no ]
)

if test "$ENABLED_SWDEV" = "yes"
then
if test "$ENABLED_CRYPTOCB" != "yes" && test "$enable_usersettings" != "yes"; then
AC_MSG_ERROR([--enable-swdev requires --enable-cryptocb (or --enable-usersettings with WOLF_CRYPTO_CB defined in user_settings.h)])
fi
if test "x$srcdir" != "x."; then
AC_MSG_ERROR([--enable-swdev currently supports in-tree builds only])
fi
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SWDEV -DWOLF_CRYPTO_CB_FIND"
fi


# Asynchronous Crypto
AC_ARG_ENABLE([asynccrypt],
[AS_HELP_STRING([--enable-asynccrypt],[Enable Asynchronous Crypto (default: disabled)])],
Expand Down Expand Up @@ -11905,9 +11924,14 @@ fi
if test "x$ENABLED_USERSETTINGS" = "xyes"
then
# Replace all options and just use WOLFSSL_USER_SETTINGS and
# WOLFSSL_USER_SETTINGS_ASM.
# WOLFSSL_USER_SETTINGS_ASM. Re-append build-system flags that affect
# preprocessor guards in test files and must survive the reset.
AM_CFLAGS="-DWOLFSSL_USER_SETTINGS -DWOLFSSL_USER_SETTINGS_ASM"
AM_CCASFLAGS="-DWOLFSSL_USER_SETTINGS -DWOLFSSL_USER_SETTINGS_ASM"
AS_IF([test "x$ENABLED_SWDEV" = "xyes"],[
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SWDEV -DWOLF_CRYPTO_CB_FIND"
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_SWDEV -DWOLF_CRYPTO_CB_FIND"
])

# Generate assembly-safe user_settings_asm.h (just preprocessor directives
# from user_settings.h).
Expand Down Expand Up @@ -12268,6 +12292,7 @@ AM_CONDITIONAL([BUILD_MCAPI],[test "x$ENABLED_MCAPI" = "xyes"])
AM_CONDITIONAL([BUILD_ASYNCCRYPT],[test "x$ENABLED_ASYNCCRYPT" = "xyes"])
AM_CONDITIONAL([BUILD_WOLFEVENT],[test "x$ENABLED_ASYNCCRYPT" = "xyes"])
AM_CONDITIONAL([BUILD_CRYPTOCB],[test "x$ENABLED_CRYPTOCB" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_SWDEV],[test "x$ENABLED_SWDEV" = "xyes"])
AM_CONDITIONAL([BUILD_PSK],[test "x$ENABLED_PSK" = "xyes"])
AM_CONDITIONAL([BUILD_TRUST_PEER_CERT],[test "x$ENABLED_TRUSTED_PEER_CERT" = "xyes"])
AM_CONDITIONAL([BUILD_PKI],[test "x$ENABLED_PKI" = "xyes"])
Expand Down
13 changes: 13 additions & 0 deletions examples/client/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ static const char *wolfsentry_config_path = NULL;
#include <wolfssl/test.h>
#include <wolfssl/error-ssl.h>

#ifdef WOLFSSL_SWDEV
#include "tests/swdev/swdev_loader.h"
#endif

#ifdef USE_FLAT_TEST_H
#include "client.h"
#else
Expand Down Expand Up @@ -5056,6 +5060,12 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
wolfSSL_Debugging_ON();
#endif
wolfSSL_Init();
#ifdef WOLFSSL_SWDEV
if (wc_SwDev_Init() != 0) {
fprintf(stderr, "wc_SwDev_Init failed\n");
return EXIT_FAILURE;
}
#endif
Comment thread
rizlik marked this conversation as resolved.
ChangeToWolfRoot();

#if !defined(NO_WOLFSSL_CLIENT) && !defined(NO_TLS)
Expand All @@ -5066,6 +5076,9 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
#endif
#else
fprintf(stderr, "Client not compiled in!\n");
#endif
#ifdef WOLFSSL_SWDEV
wc_SwDev_Cleanup();
#endif
wolfSSL_Cleanup();

Expand Down
5 changes: 5 additions & 0 deletions examples/client/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ noinst_HEADERS += examples/client/client.h
examples_client_client_SOURCES = examples/client/client.c
examples_client_client_LDADD = src/libwolfssl@LIBSUFFIX@.la $(LIB_STATIC_ADD) $(WOLFSENTRY_LIB)
examples_client_client_DEPENDENCIES = src/libwolfssl@LIBSUFFIX@.la
if BUILD_SWDEV
examples_client_client_SOURCES += tests/swdev/swdev_loader.c
examples_client_client_LDADD += $(top_builddir)/tests/swdev/build/swdev.o $(LIBM)
examples_client_client_DEPENDENCIES += $(top_builddir)/tests/swdev/build/swdev.o
endif
examples_client_client_CFLAGS = $(WOLFSENTRY_INCLUDE) $(AM_CFLAGS)
endif
EXTRA_DIST += examples/client/client.sln
Expand Down
5 changes: 5 additions & 0 deletions examples/server/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ noinst_HEADERS += examples/server/server.h
examples_server_server_SOURCES = examples/server/server.c
examples_server_server_LDADD = src/libwolfssl@LIBSUFFIX@.la $(LIB_STATIC_ADD) $(WOLFSENTRY_LIB)
examples_server_server_DEPENDENCIES = src/libwolfssl@LIBSUFFIX@.la
if BUILD_SWDEV
examples_server_server_SOURCES += tests/swdev/swdev_loader.c
examples_server_server_LDADD += $(top_builddir)/tests/swdev/build/swdev.o $(LIBM)
examples_server_server_DEPENDENCIES += $(top_builddir)/tests/swdev/build/swdev.o
endif
examples_server_server_CFLAGS = $(WOLFSENTRY_INCLUDE) $(AM_CFLAGS)
endif
EXTRA_DIST += examples/server/server.sln
Expand Down
13 changes: 13 additions & 0 deletions examples/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ static const char *wolfsentry_config_path = NULL;
#include <wolfssl/test.h>
#include <wolfssl/error-ssl.h>

#ifdef WOLFSSL_SWDEV
#include "tests/swdev/swdev_loader.h"
#endif

#ifdef USE_FLAT_TEST_H
#include "server.h"
#else
Expand Down Expand Up @@ -4255,6 +4259,12 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
wolfSSL_Init();
#ifdef WC_RNG_SEED_CB
wc_SetSeed_Cb(WC_GENERATE_SEED_DEFAULT);
#endif
#ifdef WOLFSSL_SWDEV
if (wc_SwDev_Init() != 0) {
fprintf(stderr, "wc_SwDev_Init failed\n");
return EXIT_FAILURE;
}
Comment thread
rizlik marked this conversation as resolved.
#endif
ChangeToWolfRoot();

Expand All @@ -4268,6 +4278,9 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
fprintf(stderr, "Server not compiled in!\n");
#endif

#ifdef WOLFSSL_SWDEV
wc_SwDev_Cleanup();
#endif
wolfSSL_Cleanup();
FreeTcpReady(&ready);

Expand Down
76 changes: 50 additions & 26 deletions tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
#include <tests/utils.h>
#include <testsuite/utils.h>

#ifdef WOLFSSL_SWDEV
#include "swdev/swdev_loader.h"
#endif

/* for testing compatibility layer callbacks */
#include "examples/server/server.h"

Expand Down Expand Up @@ -6367,7 +6371,10 @@ static void test_client_reuse_WOLFSSLobj(void* args, cbType cb,
/* Generic TLS client / server with callbacks for API unit tests
* Used by SNI / ALPN / crypto callback helper functions */
#if defined(HAVE_IO_TESTS_DEPENDENCIES) && \
(defined(HAVE_SNI) || defined(HAVE_ALPN) || defined(WOLF_CRYPTO_CB) || \
(defined(HAVE_SNI) || defined(HAVE_ALPN) || \
(defined(WOLF_CRYPTO_CB) && \
!defined(WOLF_CRYPTO_CB_ONLY_RSA) && !defined(WOLF_CRYPTO_CB_ONLY_ECC) && \
!defined(WOLF_CRYPTO_CB_ONLY_SHA256) && !defined(WOLF_CRYPTO_CB_ONLY_AES)) || \
defined(HAVE_ALPN_PROTOS_SUPPORT)) || defined(WOLFSSL_STATIC_MEMORY)
#define ENABLE_TLS_CALLBACK_TEST
#endif
Expand Down Expand Up @@ -30604,7 +30611,9 @@ static int test_SSL_CIPHER_get_xxx(void)
return EXPECT_RESULT();
}

#if defined(WOLF_CRYPTO_CB) && defined(HAVE_IO_TESTS_DEPENDENCIES)
#if defined(WOLF_CRYPTO_CB) && defined(HAVE_IO_TESTS_DEPENDENCIES) && \
(!defined(WOLF_CRYPTO_CB_ONLY_SHA256) && !defined(WOLF_CRYPTO_CB_ONLY_AES) && \
!defined(WOLF_CRYPTO_CB_ONLY_ECC) && !defined(WOLF_CRYPTO_CB_ONLY_RSA))

static int load_pem_key_file_as_der(const char* privKeyFile, DerBuffer** pDer,
int* keyFormat)
Expand Down Expand Up @@ -31606,7 +31615,9 @@ static int test_wc_CryptoCb_TLS(int tlsVer,
static int test_wc_CryptoCb(void)
{
EXPECT_DECLS;
#ifdef WOLF_CRYPTO_CB
#if defined(WOLF_CRYPTO_CB) && \
(!defined(WOLF_CRYPTO_CB_ONLY_SHA256) && !defined(WOLF_CRYPTO_CB_ONLY_AES) && \
!defined(WOLF_CRYPTO_CB_ONLY_ECC) && !defined(WOLF_CRYPTO_CB_ONLY_RSA))
/* TODO: Add crypto callback API tests */

#ifdef HAVE_IO_TESTS_DEPENDENCIES
Expand Down Expand Up @@ -39849,7 +39860,7 @@ static int test_pkcs7_padding(void)

/* Encode EncryptedData */
XMEMSET(&pkcs7, 0, sizeof(pkcs7));
ExpectIntEQ(wc_PKCS7_Init(&pkcs7, NULL, 0), 0);
ExpectIntEQ(wc_PKCS7_Init(&pkcs7, NULL, INVALID_DEVID), 0);
pkcs7.content = plaintext;
pkcs7.contentSz = sizeof(plaintext);
pkcs7.contentOID = DATA;
Expand Down Expand Up @@ -39878,7 +39889,7 @@ static int test_pkcs7_padding(void)

/* Decrypt modified ciphertext - must fail, not succeed */
XMEMSET(&pkcs7, 0, sizeof(pkcs7));
ExpectIntEQ(wc_PKCS7_Init(&pkcs7, NULL, 0), 0);
ExpectIntEQ(wc_PKCS7_Init(&pkcs7, NULL, INVALID_DEVID), 0);
pkcs7.encryptionKey = key;
pkcs7.encryptionKeySz = sizeof(key);

Expand Down Expand Up @@ -40788,7 +40799,11 @@ TEST_CASE testCases[] = {

static void TestSetup(void)
{
/* Stub, for now. Add common test setup code here. */
#ifdef WOLFSSL_SWDEV
/* Re-arm the swdev cryptocb registration in case the previous test
* tore down wolfCrypt and wiped gCryptoDev. */
(void)wc_SwDev_Init();
#endif
}

static void TestCleanup(void)
Expand All @@ -40797,6 +40812,9 @@ static void TestCleanup(void)
/* Clear any errors added to the error queue during the test run. */
wolfSSL_ERR_clear_error();
#endif /* OPENSSL_EXTRA || DEBUG_WOLFSSL_VERBOSE */
#ifdef WOLFSSL_SWDEV
wc_SwDev_Cleanup();
#endif
}

void ApiTest_StopOnFail(void)
Expand Down Expand Up @@ -41010,20 +41028,24 @@ int ApiTest(void)
printf(" Begin API Tests\n");
fflush(stdout);

/* we must perform init and cleanup if not all tests are running */
if (!testAll) {
#ifdef WOLFCRYPT_ONLY
if (wolfCrypt_Init() != 0) {
printf("wolfCrypt Initialization failed\n");
res = 1;
}
#else
if (wolfSSL_Init() != WOLFSSL_SUCCESS) {
printf("wolfSSL Initialization failed\n");
res = 1;
}
#endif
#ifdef WOLFCRYPT_ONLY
if (wolfCrypt_Init() != 0) {
printf("wolfCrypt Initialization failed\n");
res = 1;
}
#else
if (wolfSSL_Init() != WOLFSSL_SUCCESS) {
printf("wolfSSL Initialization failed\n");
res = 1;
}
#endif

#ifdef WOLFSSL_SWDEV
if (res == 0 && wc_SwDev_Init() != 0) {
printf("wc_SwDev_Init failed\n");
res = 1;
}
#endif

#ifdef WOLFSSL_DUMP_MEMIO_STREAM
if (res == 0) {
Expand Down Expand Up @@ -41115,13 +41137,15 @@ int ApiTest(void)
wc_ecc_fp_free(); /* free per thread cache */
#endif

if (!testAll) {
#ifdef WOLFCRYPT_ONLY
wolfCrypt_Cleanup();
#else
wolfSSL_Cleanup();
#endif
}
#ifdef WOLFSSL_SWDEV
wc_SwDev_Cleanup();
#endif

#ifdef WOLFCRYPT_ONLY
wolfCrypt_Cleanup();
#else
wolfSSL_Cleanup();
#endif

(void)testDevId;

Expand Down
Loading
Loading