Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
69a9d6c
Generate PSA_WANT_* for the Makefile build
padelsbach Oct 31, 2026
b013722
Add EdDSA and ML-KEM sizes in the PSA_WANT_* macros
padelsbach Oct 31, 2026
a3d4563
Ensure MBEDTLS_FS_IO and NO_FILESYSTEM agree, add no-filesystem to CI
padelsbach Nov 2, 2026
3ced08e
Generate PSA_WANT_* into the build dir, fix max sizes
padelsbach Nov 2, 2026
90dae8a
Add PSA_WANT_ALG_ECDSA_ANY, PSA_WANT_ALG_RSA_PKCS1V15_SIGN_RAW and PS…
padelsbach Nov 3, 2026
350ef4c
Add TF-PSA-Crypto pk and threading API
padelsbach Nov 4, 2026
8da021c
Fix Ed448 key/sig size, build without HAVE_ECC
padelsbach Oct 31, 2026
a9e0372
PR feedback: updpate PSA_SIGNATURE_MAX_SIZE, SECP size check, length …
padelsbach Nov 2, 2026
22d2dc9
Add RSA size, padding and status checks
padelsbach Nov 3, 2026
82c217e
Clear outputs upon entry to public functions
padelsbach Nov 3, 2026
71b143d
Clear outputs at entry of remaining public functions
padelsbach Nov 3, 2026
04b1854
Allow 4 and 8 byte GCM tags for PSA compat
padelsbach Nov 3, 2026
edcfce3
Allow psa_aead_set_lengths before or after the nonce
padelsbach Nov 4, 2026
4288199
Check CCM length limits against the nonce and reject early AAD
padelsbach Nov 4, 2026
d17cf24
Check RSA and ECC key data in psa_import_key
padelsbach Nov 4, 2026
1c996ea
Align PSA return codes and key derivation inputs with the PSA spec
padelsbach Nov 4, 2026
f8d1b18
Add support for the enrollment algorithm on volatile keys
padelsbach Nov 4, 2026
da80cf3
Check enrollment algorithm in key wrap, KEM and one-shot AEAD
padelsbach Nov 4, 2026
b386503
MbedTLS compatibility layer prototype
padelsbach Nov 2, 2026
c081205
Fix Mbed TLS compat verify, hostname and return codes
padelsbach Nov 2, 2026
8276371
Add the generated PSA_WANT_* header to the Mbed TLS compat include path
padelsbach Nov 2, 2026
c154859
Extend Mbed compat: TLS version, suites, sessions, IP SANs
padelsbach Nov 3, 2026
d912941
Param handling and wolfSSL_free() in mbedtls_ssl_list_ciphersuites()
padelsbach Nov 4, 2026
a0e8441
Turn on the enrollment algorithm with MBEDTLS_COMPAT=1
padelsbach Nov 4, 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
19 changes: 15 additions & 4 deletions .github/workflows/build-config-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,27 @@ jobs:
modifiers: "-HAVE_HKDF -HAVE_ECC_ENCRYPT"
- name: tls-prf
modifiers: "-WOLFSSL_HAVE_PRF"
# This config stays as a static library (not shared) because of a
# missing symbol in this build of wolfSSL. 'target' field and the
# LDFLAGS environment variable below can be removed after
# wolfSSL#11958 merges.
- name: pbkdf2
modifiers: "-HAVE_PBKDF2 +NO_PBKDF2"
target: libwolfpsa.a
- name: ecc384
modifiers: "-WOLFSSL_SP_384 -HAVE_ECC384"
- name: no-ecc
modifiers: "-HAVE_ECC -HAVE_ECC_ENCRYPT"
- name: rsa-1024
modifiers: "-WOLFSSL_SP_1024 -RSA_MIN_SIZE +RSA_MIN_SIZE=2048"
# wolfPSA's own sources only: the bundled wolfCrypt sources do not
# build under WC_NO_RNG (asn.c trips -Wnonnull), which is a wolfSSL
# issue outside this lane's scope.
- name: no-rsa
modifiers: "+NO_RSA +ECC_USER_CURVES -WOLFSSL_HAVE_MLDSA"
- name: no-rng
modifiers: "+WC_NO_RNG +WC_BLINDING_NO_RNG_ACKNOWLEDGE_WEAKNESS"
target: psa-objects
- name: no-filesystem
modifiers: "+NO_FILESYSTEM +WOLFPSA_CUSTOM_STORE"
target: libwolfpsa.a

steps:
- name: Check out wolfPSA
Expand All @@ -107,5 +116,7 @@ jobs:

- name: Build ${{ matrix.config.name }}
env:
BUILD_TARGET: ${{ matrix.config.target || 'libwolfpsa.a' }}
BUILD_TARGET: ${{ matrix.config.target || 'libwolfpsa.so' }}
# Fail on undefined symbols
LDFLAGS: -Wl,-z,defs
run: ./build-test/build-variant.sh "${{ matrix.config.name }}" ${{ matrix.config.modifiers }}
35 changes: 35 additions & 0 deletions .github/workflows/mbedtls-compat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Mbed TLS compatibility

on:
push:
pull_request:

jobs:
# make MBEDTLS_COMPAT=1 mbedtls-compat-test: the Mbed TLS 4.x API on
# wolfSSL, tested with Mbed TLS's sample programs and test data. See the
# README.
mbedtls-compat:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
wolfssl-ref: [ master, v5.9.4-stable ]
options: [ "", "MBEDTLS_THREADING_C=1 ASAN=1" ]

steps:
- name: Check out wolfPSA
uses: actions/checkout@v4

- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential autoconf automake libtool libtool-bin pkg-config python3-jinja2 faketime

- name: Clone sibling wolfSSL
run: git clone --depth 1 --branch ${{ matrix.wolfssl-ref }} https://github.com/wolfSSL/wolfssl ../wolfssl

- name: Clone sibling Mbed TLS
run: git clone --depth 1 --branch mbedtls-4.2.0 --recurse-submodules --shallow-submodules https://github.com/Mbed-TLS/mbedtls ../mbedtls

- name: Build and run the compatibility tests
run: make MBEDTLS_COMPAT=1 ${{ matrix.options }} mbedtls-compat-test
5 changes: 5 additions & 0 deletions .github/workflows/test-psa-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ jobs:
./test/psa_ecc_verify_curve_test
./test/psa_ecc_ecdh_curve_test

- name: Run the PSA_WANT surface test
run: |
make want-surface-test \
USER_SETTINGS_PATH="${GITHUB_WORKSPACE}/build-ecc-var"

test-psa-api:
runs-on: ubuntu-latest
strategy:
Expand Down
19 changes: 17 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ test/psa_14_misc_test
test/psa_aead_multipart_test
test/psa_cipher_inplace_test
test/psa_cipher_oneshot_len_test
test/psa_reset_outputs_test
test/psa_cipher_overlap_test
test/psa_copy_key_narrowing_test
test/psa_des3_pkcs7_test
test/psa_aead_call_order_test
test/psa_ecc_curve_caps_test
test/psa_ecc_ecdh_curve_test
test/psa_ecc_sig_len_test
test/psa_rsa_status_test
test/psa_ecc_verify_curve_test
test/psa_eddsa_mont_export_test
test/psa_eddsa_mont_gen_test
Expand Down Expand Up @@ -70,6 +73,8 @@ test/psa_devid_cryptocb_test
test/build-probe
test/build-cryptocb
test/build-cryptocb-asan
test/build-enroll
test/build-enroll-asan
test/psa_store_commit_test
test/psa_store_dir_validation_test
test/psa_store_read_open_test
Expand All @@ -79,7 +84,17 @@ test/psa_kdf_repeat_step_test
test/psa_kdf_psk_to_ms_size_test
test/psa_kdf_zeroize_output_test
test/psa_import_zero_length_test
test/psa_import_key_data_test
test/psa_copy_key_cross_lifetime_test
build-test/out/
test/psa_zero_capacity_buffer_test
test/psa_tf_psa_extra_test
test/psa_want_surface_test
test/psa_tf_psa_pk_test
test/psa_tf_psa_threading_test
test/psa_aead_gcm_short_tag_test
test/build-threads
test/build-threads-asan
test/psa_zero_capacity_buffer_test
test/psa_enrollment_alg_test
build-test/out/
.cache/
compile_commands.json
112 changes: 105 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,38 @@ WOLFCRYPT_SRC := \
WOLFCRYPT_OBJ := $(patsubst $(WOLFSSL_PATH)/wolfcrypt/src/%.c,$(OBJDIR)/wolfcrypt_%.o,$(WOLFCRYPT_SRC))
WOLFCRYPT_OBJ_PIC := $(patsubst $(WOLFSSL_PATH)/wolfcrypt/src/%.c,$(OBJDIR_PIC)/wolfcrypt_%.o,$(WOLFCRYPT_SRC))

# MBEDTLS_COMPAT=1 adds the Mbed TLS 4.x TLS, X.509 and network API, on
# wolfSSL's TLS compiled from WOLFSSL_PATH like wolfCrypt.
# See src/mbedtls_compat.c and src/mbedtls_net.c.
WOLFSSL_TLS_SRC :=
ifeq ($(MBEDTLS_COMPAT),1)
CPPFLAGS += -DWOLFPSA_MBEDTLS_COMPAT
ENROLLMENT_ALG := 1
WOLFSSL_TLS_SRC := $(addprefix $(WOLFSSL_PATH)/src/,internal.c keys.c ssl.c \
tls.c tls13.c wolfio.c)
endif
WOLFSSL_TLS_OBJ := $(patsubst $(WOLFSSL_PATH)/src/%.c,$(OBJDIR)/wolfssl_%.o, \
$(WOLFSSL_TLS_SRC))
WOLFSSL_TLS_OBJ_PIC := $(patsubst $(WOLFSSL_PATH)/src/%.c, \
$(OBJDIR_PIC)/wolfssl_%.o,$(WOLFSSL_TLS_SRC))

# MBEDTLS_THREADING_C=1 builds a thread safe library, as in Mbed TLS. See
# user_settings.h. Applications define MBEDTLS_THREADING_C too.
ifeq ($(MBEDTLS_THREADING_C),1)
CPPFLAGS += -DMBEDTLS_THREADING_C
LDFLAGS += -pthread
endif

# Changing MBEDTLS_COMPAT or MBEDTLS_THREADING_C rebuilds every object
OPTIONS_STAMP := $(BUILD_DIR)/options_$(if \
$(filter 1,$(MBEDTLS_COMPAT)),compat,nocompat)_$(if \
$(filter 1,$(MBEDTLS_THREADING_C)),threads,nothreads)

WOLFSSL_CPPFLAGS ?= -DWOLFSSL_USER_SETTINGS

CPPFLAGS += -I$(WOLFSSL_PATH) -I$(USER_SETTINGS_PATH) \
-I$(CURDIR) -I$(CURDIR)/wolfpsa -I$(CURDIR)/src $(WOLFSSL_CPPFLAGS)
-I$(CURDIR) -I$(CURDIR)/wolfpsa -I$(CURDIR)/src -I$(BUILD_DIR)/include \
$(WOLFSSL_CPPFLAGS)
ifneq ($(strip $(PSA_INCLUDE)),)
CPPFLAGS += -I$(PSA_INCLUDE)
endif
Expand All @@ -104,6 +132,10 @@ endif
ifeq ($(AES_FAST),1)
CPPFLAGS += -DWOLFPSA_AES_FAST
endif
# ENROLLMENT_ALG=1 allows the Mbed TLS enrollment algorithm on volatile keys
ifeq ($(ENROLLMENT_ALG),1)
CPPFLAGS += -DWOLFPSA_ENROLLMENT_ALG
endif
CFLAGS += $(DEBUG_FLAGS) $(SANITIZE_FLAGS)
LDFLAGS += $(SANITIZE_FLAGS)

Expand All @@ -118,7 +150,8 @@ CFLAGS += --coverage
LDFLAGS += --coverage
endif

.PHONY: all clean psa-objects unit-run run-tests cov covclean
.PHONY: all clean psa-objects unit-run run-tests cov covclean \
want-surface-test mbedtls-compat-test

all: $(LIBNAME) $(SHLIBNAME)

Expand All @@ -128,13 +161,44 @@ all: $(LIBNAME) $(SHLIBNAME)
# bundled wolfCrypt sources are out of scope.
psa-objects: $(OBJ)

$(LIBNAME): $(OBJ) $(WOLFCRYPT_OBJ)
$(LIBNAME): $(OBJ) $(WOLFCRYPT_OBJ) $(WOLFSSL_TLS_OBJ)
rm -f $@
$(AR) rcs $@ $^
$(RANLIB) $@

$(SHLIBNAME): $(OBJ_PIC) $(WOLFCRYPT_OBJ_PIC) $(EXPORT_MAP)
$(SHLIBNAME): $(OBJ_PIC) $(WOLFCRYPT_OBJ_PIC) $(WOLFSSL_TLS_OBJ_PIC) \
$(EXPORT_MAP)
$(CC) -shared -Wl,--version-script,$(EXPORT_MAP) -Wl,-Bsymbolic-functions -o $@ $(filter-out $(EXPORT_MAP),$^) $(LDFLAGS)

# Build the PSA_WANT_* macros based on what the wolfCrypt build supports.
# Consumers of <psa/crypto.h> add $(BUILD_DIR)/include to the include path.
PSA_CONFIG := $(BUILD_DIR)/include/crypto_config_generated.h
PYTHON ?= python3

$(PSA_CONFIG): FORCE
@mkdir -p $(dir $@)
$(PYTHON) tools/gen-crypto-config.py $@ "$(CC)" \
tools/psa_want_probe.c $(CPPFLAGS) $(CFLAGS)

$(OBJ) $(OBJ_PIC): $(PSA_CONFIG)

FORCE:

# Check the PSA_WANT_* surface of this build against its static library
want-surface-test: $(LIBNAME)
$(CC) $(CPPFLAGS) $(CFLAGS) -o $(BUILD_DIR)/psa_want_surface_test \
test/psa_server/psa_want_surface_test.c $(LIBNAME) $(LDFLAGS) \
-lpthread -lm
$(BUILD_DIR)/psa_want_surface_test

$(OBJ) $(WOLFCRYPT_OBJ) $(WOLFSSL_TLS_OBJ) $(OBJ_PIC) $(WOLFCRYPT_OBJ_PIC) \
$(WOLFSSL_TLS_OBJ_PIC): $(OPTIONS_STAMP)

$(OPTIONS_STAMP):
@mkdir -p $(@D)
rm -f $(BUILD_DIR)/options_*
touch $@

$(OBJDIR)/%.o: src/%.c
@mkdir -p $(OBJDIR)
$(CC) $(CPPFLAGS) $(DEPFLAGS) $(CFLAGS) -c $< -o $@
Expand All @@ -151,6 +215,14 @@ $(OBJDIR_PIC)/wolfcrypt_%.o: $(WOLFSSL_PATH)/wolfcrypt/src/%.c
@mkdir -p $(OBJDIR_PIC)
$(CC) $(CPPFLAGS) $(DEPFLAGS) $(CFLAGS) -fPIC -c $< -o $@

$(OBJDIR)/wolfssl_%.o: $(WOLFSSL_PATH)/src/%.c
@mkdir -p $(OBJDIR)
$(CC) $(CPPFLAGS) $(DEPFLAGS) $(CFLAGS) -c $< -o $@

$(OBJDIR_PIC)/wolfssl_%.o: $(WOLFSSL_PATH)/src/%.c
@mkdir -p $(OBJDIR_PIC)
$(CC) $(CPPFLAGS) $(DEPFLAGS) $(CFLAGS) -fPIC -c $< -o $@

# The unit tests. The servers (psa_tls_client, psa_tls_server) and the
# benchmark are not unit tests and are not listed.
UNIT_TESTS := psa_api_test \
Expand Down Expand Up @@ -187,28 +259,37 @@ UNIT_TESTS := psa_api_test \
psa_ecc_curve_caps_test \
psa_xof_no_backend_test \
psa_ecc_sig_len_test \
psa_rsa_status_test \
psa_xof_set_context_test \
psa_cipher_inplace_test \
psa_cipher_overlap_test \
psa_des3_pkcs7_test \
psa_aead_call_order_test \
psa_eddsa_mont_export_test \
psa_eddsa_mont_gen_test \
psa_pure_eddsa_context_test \
psa_sign_hash_eddsa_test \
psa_key_infer_bits_test \
psa_cipher_oneshot_len_test \
psa_reset_outputs_test \
psa_pqc_export_seed_test \
psa_key_declared_bits_test \
psa_import_key_probe_test \
psa_store_commit_test \
psa_store_read_open_test \
psa_store_dir_validation_test \
psa_devid_cryptocb_test \
psa_enrollment_alg_test \
psa_kdf_zeroize_output_test \
psa_import_zero_length_test \
psa_import_key_data_test \
psa_copy_key_cross_lifetime_test \
psa_zero_capacity_buffer_test \
psa_tf_psa_extra_test
psa_want_surface_test \
psa_tf_psa_extra_test \
psa_tf_psa_pk_test \
psa_tf_psa_threading_test \
psa_aead_gcm_short_tag_test

# Run the unit test loop from the repo root (psa_rsa_pss_interop_test reads
# its certificate relative to the root). Assumes the tests are already built.
Expand All @@ -224,6 +305,22 @@ unit-run: all
@$(MAKE) -C test $(UNIT_TESTS)
@$(MAKE) run-tests

# Mbed TLS repo for running their example programs.
MBEDTLS_PATH ?= ../mbedtls

ifeq ($(MBEDTLS_COMPAT),1)
mbedtls-compat-test: $(LIBNAME)
$(MAKE) -C test/mbedtls_compat WOLFPSA_PATH=$(CURDIR) \
WOLFSSL_PATH=$(abspath $(WOLFSSL_PATH)) \
MBEDTLS_PATH=$(abspath $(MBEDTLS_PATH)) \
BUILD_DIR=$(abspath $(BUILD_DIR))/mbedtls_compat \
PSA_CONFIG_DIR=$(abspath $(dir $(PSA_CONFIG))) \
WOLFPSA_LDFLAGS="$(LDFLAGS)" check
else
mbedtls-compat-test:
@echo "Run make MBEDTLS_COMPAT=1 mbedtls-compat-test"; exit 1
endif

# Build everything with gcov instrumentation, run the unit tests, and emit an
# HTML coverage report for src/*.c (the bundled wolfCrypt sources are
# excluded by the -f filter). The instrumented objects are dropped once the
Expand Down Expand Up @@ -273,5 +370,6 @@ covclean:
clean:
rm -rf $(BUILD_DIR) $(LIBNAME) $(SHLIBNAME)

-include $(OBJ:.o=.d) $(WOLFCRYPT_OBJ:.o=.d)
-include $(OBJ_PIC:.o=.d) $(WOLFCRYPT_OBJ_PIC:.o=.d)
-include $(OBJ:.o=.d) $(WOLFCRYPT_OBJ:.o=.d) $(WOLFSSL_TLS_OBJ:.o=.d)
-include $(OBJ_PIC:.o=.d) $(WOLFCRYPT_OBJ_PIC:.o=.d) \
$(WOLFSSL_TLS_OBJ_PIC:.o=.d)
Loading
Loading