Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
95 changes: 95 additions & 0 deletions .github/workflows/cryptocb-only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
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 piggybacks on the SHA-256
# software core so it is incompatible with this strip and must be
# explicitly disabled (it is default-on on x86_64/aarch64).
- 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
# 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. SHA-224 is left at the platform
# default (on for x86_64/aarch64); entries that need it off pass
# --disable-sha224 in extra_config.
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
20 changes: 20 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -10666,6 +10666,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, forces WOLF_CRYPTO_CB_FIND, and currently supports in-tree builds only.])],
[ ENABLED_SWDEV=$enableval ],
[ ENABLED_SWDEV=no ]
)

if test "$ENABLED_SWDEV" = "yes"
then
if test "$ENABLED_CRYPTOCB" != "yes"; then
AC_MSG_ERROR([--enable-swdev requires --enable-cryptocb])
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 @@ -12288,6 +12307,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 @@ -5054,6 +5058,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 on lines +5061 to +5066
ChangeToWolfRoot();

#if !defined(NO_WOLFSSL_CLIENT) && !defined(NO_TLS)
Expand All @@ -5064,6 +5074,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 @@ -4258,6 +4262,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 on lines +4266 to +4270
#endif
ChangeToWolfRoot();

Expand All @@ -4271,6 +4281,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
66 changes: 41 additions & 25 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 @@ -28467,7 +28471,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 @@ -29469,7 +29475,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 @@ -36801,7 +36809,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 @@ -36830,7 +36838,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 @@ -37707,7 +37715,9 @@ TEST_CASE testCases[] = {

static void TestSetup(void)
{
/* Stub, for now. Add common test setup code here. */
#ifdef WOLFSSL_SWDEV
(void)wc_SwDev_Init();
#endif
Comment on lines 37716 to +37720
}

static void TestCleanup(void)
Expand Down Expand Up @@ -37929,20 +37939,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 @@ -38034,13 +38048,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
5 changes: 4 additions & 1 deletion tests/api/test_ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,9 +785,12 @@ int test_wc_ecc_import_x963(void)
int test_wc_ecc_import_x963_off_curve(void)
{
EXPECT_DECLS;
/* point-on-curve validation inside wc_ecc_import_x963 is raw math stripped
* by WOLF_CRYPTO_CB_ONLY_ECC; swdev cannot reach below the dispatch layer. */
#if defined(HAVE_ECC) && defined(HAVE_ECC_KEY_IMPORT) && \
!defined(NO_ECC256) && !defined(NO_ECC_SECP) && \
(!defined(HAVE_FIPS) || FIPS_VERSION_GE(7,0)) && !defined(HAVE_SELFTEST)
(!defined(HAVE_FIPS) || FIPS_VERSION_GE(7,0)) && !defined(HAVE_SELFTEST) && \
!defined(WOLF_CRYPTO_CB_ONLY_ECC)
ecc_key pubKey;
/* Uncompressed X9.63 P-256 point: 0x04 || Gx || Gy with the last byte
* of Gy flipped by 1. Gx/Gy are the NIST P-256 generator coordinates;
Expand Down
Loading
Loading