Commit Graph
12240 Commits
Author SHA1 Message Date
JacobBarthelmehandGitHub 66d182b362 Merge pull request #11123 from dgarske/toradex_nxp_imx95
arm64: runtime-dispatch ML-KEM SHA-3 crypto extension to fix SIGILL
2026-08-11 08:54:59 -06:00
Daniel PouzznerandGitHub 067c10d71e Merge pull request #10819 from lealem47/input_validation
Crypto layer: Add missing input validation
2026-08-10 18:29:11 -05:00
David Garske a8cb129088 arm64: runtime-dispatch ML-KEM SHA-3 crypto extension to fix SIGILL 2026-08-10 16:11:22 -07:00
David GarskeandGitHub 1e0fa211d0 Merge pull request #10886 from night1rider/cryptocb-hooks-rsapss-ed448-cmac
Cryptocb hooks rsapss ed448 cmac
2026-08-10 15:49:05 -07:00
night1rider 73298a7f63 Share one helper between the RSA-PSS verify crypto callback paths 2026-08-10 14:02:21 -06:00
Lealem Amedie ca06c85ec0 Testing touch-ups to account for error code fix and MIN_AUTH_TAG_SZ update 2026-08-10 13:35:01 -06:00
Lealem Amedie 18ce83cf9b Fix spacing nit 2026-08-10 13:35:01 -06:00
JacobBarthelmehandGitHub 0ee11c71ac Merge pull request #10994 from night1rider/Xilinx-ASU-Ciphers-CMAC-GMAC
Xilinx Versal Gen2 ASU port: AES ciphers, CMAC, GMAC offload
2026-08-10 13:32:55 -06:00
Lealem Amedie 9c113d34f1 Crypto layer: Add missing input validation 2026-08-10 13:25:40 -06:00
JacobBarthelmehandGitHub 77da93945b Merge pull request #11117 from night1rider/fix/san-othername-null-memcpy
asn.c: guard empty otherName copy to avoid NULL memcpy (UBSan)
2026-08-10 10:25:23 -06:00
David GarskeandDaniele Lacamera 14a72c96e4 wolfCrypt SRAM PUF: configurable error correction and footprint 2026-08-09 09:04:51 +02:00
night1rider 866e9e15ea asn.c: guard empty otherName copy to avoid NULL memcpy (UBSan)
When a subjectAltName otherName has an empty value, SetDNSEntry() called
XMEMCPY(dst, NULL, 0). Passing NULL to memcpy is undefined behavior and
aborts under UBSan. Skip the copy unless there is real data to copy.
2026-08-08 17:13:02 -06:00
night1rider 375febc944 Extend the RSA-PSS verify callback and harden the Ed448/CMAC hooks
The PSS hook can hand back the recovered block through out/outSz/outLen.
A device that reports only a verdict leaves outLen at 0; wolfSSL then
zeroes the buffer and returns saltLen + hLen, and rejects a buffer
smaller than that with RSA_BUFFER_E. A reported length is clamped to the
buffer size, and any positive handler return maps to SIG_VERIFY_E.

Move the Ed448 sign WOLFSSL_CHECK_MEM_ZERO registration below the crypto
callback hook so the device path no longer returns past it, and guard the
RSA-PSS test callback against WOLF_CRYPTO_CB_ONLY_RSA.

Adds tests for the recovered-data, over-claimed-length and undersized
buffer paths, and an os-check config that builds the hooks under
WOLFSSL_CHECK_MEM_ZERO.
2026-08-08 15:14:28 -06:00
night1rider 33e03a5ce4 Release Ed448 sign MemZero registrations on the crypto callback exit 2026-08-08 15:14:27 -06:00
night1rider 4d19228ca0 Cast type to CmacType so cmac.c builds as C++ 2026-08-08 15:14:27 -06:00
night1rider 3ade5f62b9 Clear *res before invoking the Ed448 verify crypto callback 2026-08-08 15:14:27 -06:00
night1rider 7952b070e6 Validate Ed448ph prehash length before the sign crypto callback 2026-08-08 15:14:27 -06:00
night1rider b35f60eef3 Set cmac->type before cryptocb init so wc_CmacFree can clean up 2026-08-08 15:14:27 -06:00
night1rider 772a62628e Add crypto callback hooks for Ed448, CMAC free, and RSA-PSS verify
Add WOLF_CRYPTO_CB dispatch hooks so a device can service:
* Ed448 sign and verify, mirroring the existing Ed25519 hooks.
* CMAC context free on wc_CmacFree (WOLF_CRYPTO_CB_FREE), letting a device
  release offload state.
* RSA-PSS verify with the digest (WOLF_CRYPTO_CB_RSA_PAD) so the device does
  the full signature and padding check. On that path *out is set to NULL with a
  positive return, documented in rsa.h.

Includes testwolfcrypt and API unit test coverage for each hook.
2026-08-08 15:14:27 -06:00
night1rider a08952b557 Xilinx Versal Gen2 ASU port: decline unsupported AES-GCM IV lengths to software 2026-08-08 14:35:12 -06:00
night1rider 52d569855a Xilinx Versal Gen2 ASU port: fold the one-shot CMAC input into the buffer at final 2026-08-08 14:35:12 -06:00
night1rider 0066461776 Xilinx Versal Gen2 ASU port: split AES-CTR at the 32-bit counter wrap and carry in software to keep it on hardware 2026-08-08 14:35:12 -06:00
night1rider 8f5137c08a Xilinx Versal Gen2 ASU port: AES ciphers, CMAC, GMAC offload 2026-08-08 14:35:11 -06:00
philljjandGitHub e71b086fc8 Merge pull request #10724 from dgarske/ti_c25
wolfCrypt on TI C2000 C28x (LAUNCHXL-F28P55X)
2026-08-08 14:26:28 -05:00
David GarskeandGitHub af9f62b690 Merge pull request #11092 from sameehj/fix/mem-fail-null-checks
Fix mem-fail nightly crashes (jenkins-supervisor #501)
2026-08-07 14:52:36 -07:00
David GarskeandGitHub 1bd2ee0dd4 Merge pull request #11041 from kareem-wolfssl/zd22232_42_63
Fully clear ECC k when calling wc_ecc_sign_hash_ex with SP math.  Avoid aliasing the ticket in wolfSSL_GetSessionAtIndex.  Fix IAR warnings.
2026-08-07 13:47:07 -07:00
David GarskeandGitHub 586f1ed490 Merge pull request #11096 from Frauschi/pqc_only
Support post-quantum-only (ML-KEM + ML-DSA/SLH-DSA) TLS 1.3 builds
2026-08-07 10:08:34 -07:00
David GarskeandGitHub 032c78726f Merge pull request #10999 from embhorn/zd22154
Parse x500UniqueIdentifier (OID 2.5.4.45) in certificate DN
2026-08-07 10:01:55 -07:00
David GarskeandGitHub a82f5b79c0 Merge pull request #11067 from SparkiDev/docs_user_settings_embedded_h
Documentation and embedded user_settings.h.
2026-08-07 09:14:36 -07:00
David GarskeandGitHub 96586b8f81 Merge pull request #11093 from Frauschi/fenrir_crypto
wolfCrypt Fenrir fixes
2026-08-07 09:11:42 -07:00
David GarskeandGitHub bbdc07c1e7 Merge pull request #10786 from aidankeefe2022/fenrir-fixes-jun24/26-ak
Fix: WolfCrypt Fenrir - 11 fixes
2026-08-07 09:06:39 -07:00
Takashi KojoandGitHub 563f0f0c13 Merge pull request #10962 from kojo1/oss_mldsa
OpenSSL compat with ML-DSA
2026-08-07 16:38:17 +09:00
Tobias Frauenschläger f5f3dd4c6e Support post-quantum-only (ML-KEM + ML-DSA/SLH-DSA) TLS 1.3 builds
Allow a quantum-safe-only TLS 1.3 stack - ML-KEM key exchange with ML-DSA or
SLH-DSA authentication - with RSA, ECC and DH all disabled (the CNSA 2.0 /
EO 14412 posture).

- Treat a usable standalone ML-KEM group as a valid key exchange and
  Falcon/ML-DSA/SLH-DSA as valid authentication, so the "no cipher suites"
  #errors no longer fire (ssl.c, internal.h), and extend the CopyDecodedToX509
  pkCurveOID guard to match the struct member guards (internal.c).
- asn.c: guard the RSA/ECC-only certificate signing helpers so cert generation
  compiles with RSA and ECC disabled, while keeping MakeSignatureCb available
  for the WOLFSSL_CERT_SIGN_CB (TPM/HSM) offload path.
- tls.c: advertise the psk_dhe_ke exchange mode when a standalone ML-KEM group
  is usable on the client side, that is when the build has both key generation
  and decapsulation. Without it an ML-KEM-only build fell back to psk_ke, the
  resumption key schedules diverged, and the first AEAD record failed to
  authenticate (AES_GCM_AUTH_E), breaking session-ticket resumption.
- tls13.c: hoist the hashAlgo void cast in EncodeSigAlg out of the Ed25519 and
  Ed448 cases so a build with no classic signature algorithm still marks the
  parameter used.
- Examples and tests: add ML-DSA and SLH-DSA certificate selection (gated on
  NO_RSA so it only applies in true PQC-only builds) and default to TLS 1.3
  when no classic auth is built in and a post-quantum signature is available
  (test.h, client/server/echo*, test_tls13.c). SLH-DSA uses the SHAKE-128s leaf
  certificates and their shared 128s root.
- CI: add PQC-only entries to the pq-all.json config list (ML-DSA and SLH-DSA),
  each exercising the build, a full TLS 1.3 handshake, and ML-KEM-only
  session-ticket resumption.

Whether a build can authenticate with a post-quantum certificate is three
separate questions - is the algorithm compiled in, are test credentials wired
up for the enabled parameter set, and can this build sign - so test.h answers
them with three tiers of macro rather than testing WOLFSSL_HAVE_MLDSA and
WOLFSSL_HAVE_SLHDSA directly:

- TEST_HAVE_MLDSA_CERT_FILES / TEST_HAVE_SLHDSA_CERT_FILES: the credential
  paths name real files. ML-DSA needs an enabled parameter level; SLH-DSA needs
  a 128s parameter set, since both families share a 128s root and only those
  certificates are wired up, and PEM decoding, since the entity certificates
  ship as PEM only. Loading a certificate needs verification support alone, so
  test_tls13.c uses this tier - it only needs a certificate on the context.
- TEST_HAVE_MLDSA_CERTS / TEST_HAVE_SLHDSA_CERTS: the above, plus the ability
  to sign. A verify-only build derives WOLFSSL_MLDSA_NO_SIGN and drops private
  key support entirely, so it can neither load the key nor produce a
  CertificateVerify. The example credential ladders use this tier.
- TEST_HAVE_PQC_CERT_AUTH: either of those, plus WOLFSSL_TLS13. Both algorithms
  are TLS 1.3 only, so folding the version into the macro keeps the version
  defaults and the PSK fallbacks in the client, server and echo examples from
  disagreeing. Falcon is deliberately absent, having no credentials in the
  ladders, so a Falcon-only build keeps the historic TLS 1.2 PSK behavior.

A build that fails a gate now falls back to PSK instead of naming credentials
it cannot use, which removes two hard #errors that were reachable from
configure: --enable-slhdsa with only non-128s parameter sets broke every build
that includes test.h, even ones with RSA and ECC enabled that would never touch
an SLH-DSA credential.

Also in the credential material and the configurations this opens up:

- test.h: pair the DER ML-DSA certificate with mldsa<N>-key.der. The
  mldsa<N>_priv-only.der files are standalone PKCS#8 encoding vectors from an
  unrelated key pair, so a build without PEM decoding presented a certificate
  and signed with a key that did not match it, and the peer rejected the
  CertificateVerify.
- echoserver.c: load the SLH-DSA key with CERT_FILETYPE like every neighboring
  branch, rather than hardcoding WOLFSSL_FILETYPE_PEM against a certificate
  loaded in the build-dependent format.
- internal.c, tls13.c, ssl_load.c: mark ssl, sigOut, keyType and keySz used.
  Every reader of these sits in a per-algorithm block, so a build with no
  signing algorithm at all left them unused and -Werror rejected the library.
- tests/api.c: skip test_wolfSSL_PKCS8 unless RSA, ECC or PEM decoding is
  available. With none of them every key-loading body compiles out, leaving the
  file locals unused and nothing for the test to do.
2026-08-07 08:14:26 +02:00
Tobias Frauenschläger b1e01d6d64 Fix PKCS12 PBKDF mp variant buffer size to include password block
The mp API variant of wc_PKCS12_PBKDF_ex builds a working buffer holding
D || S || P, but totalLen was computed as dLen + sLen and so left out the
password block entirely. The fill loop writes pLen bytes starting at
S + sLen, which is past the end of the buffer, and DoPKCS12Hash was called
with the short length so the password was never absorbed into the digest.
A build with this variant enabled therefore derived the same key for every
password over a given salt, and overflowed the heap allocation or the
static buffer by pLen bytes depending on the salt length.

Sum dLen with iLen instead, matching the non-mp variant. That corrects the
allocation size, the hash input length, the I update bound and the
ForceZero coverage in one place.

Fixes F-7306.
2026-08-07 08:11:23 +02:00
Tobias Frauenschläger d4755b4b62 Fix EVP_DecodeUpdate overflow on NUL byte in base64 input
The quad decoding loop broke out on a NUL byte without clearing the
remaining input length, unlike the equivalent loops in Base64_Decode and
Base64_Decode_nonCT. Control then fell into the block that buffers the
leftover input in the context, which copied the full remaining byte count
into the 48 byte ctx->data with an unbounded index, and read one byte past
the end of the caller's buffer. An application decoding attacker supplied
base64 with an explicit, binary safe length could write attacker
controlled data past the end of a heap allocated encode context.

Clear the length before breaking, and bound the leftover copy loop at one
decode block, which is the most that loop can legitimately buffer. That
also keeps ctx->remaining below the block size, so a reused context cannot
underflow the copy size in the next update call or over-read ctx->data in
EVP_DecodeFinal.

Add a negative test feeding a NUL byte followed by more non-whitespace
data than the context buffer can hold.

Fixes F-7445.
2026-08-07 08:11:23 +02:00
Tobias Frauenschläger fa2faecdf9 Bound Renesas crypt callback context slot allocation
wc_CryptoCb_CryptInitRenesasCmn() derived the slot index from a
free-running device id counter and wrote gCbCtx[] without checking the
index against MAX_FSPSM_CBINDEX. Since the function is called once per
WOLFSSL session, the sixth registration in the lifetime of a process
wrote a pointer past the end of the array.

Look for a free slot inside the hardware lock instead and derive the
device id from that slot, so a full table is rejected with
INVALID_DEVID. wc_CryptoCb_CleanupRenesasCmn() now clears the slot,
which makes it available to a later registration and drops the stale
pointer to a context the application may free. Also correct the upper
bound checks in Renesas_cmn_GetCbCtxBydevId() and
wc_CryptoCb_CleanupRenesasCmn(), which both accepted an index one past
the last element.

Fixes F-7438.
2026-08-07 08:11:23 +02:00
Tobias Frauenschläger af0eb33fff Invalidate LMS key when private key write fails
wc_LmsKey_Sign computes the signature with the one-time key at the
current leaf and only afterwards advances the leaf index and writes it
to non-volatile storage. When that write failed the signature was erased
but the key state was left as OK, so the same in-memory key could sign
again while storage still recorded the already consumed leaf. A restart
followed by wc_LmsKey_Reload would then resume from that leaf and sign a
second message with the same LM-OTS private key.

Set the key state to bad before signing and only restore it to OK once
the advanced private key has been committed to storage, matching what
wc_xmsskey_signupdate already does for XMSS. Exhausted keys keep their
existing NOSIGS state.

Fixes F-7411.
2026-08-07 08:11:23 +02:00
Tobias Frauenschläger be59d5af49 Wait for NETOS thread to finish before freeing its stack
The NETOS implementation of wolfSSL_JoinThread released the buffer that
tx_thread_create had been given as the thread's execution stack without
first waiting for the thread to complete, and never unregistered the
thread from ThreadX. A join issued while the callback was still running
handed the running thread's stack back to the allocator.

Waiting was not possible with the previous THREAD_TYPE layout, because
it embedded the TX_THREAD control block by value and wolfSSL_JoinThread
takes THREAD_TYPE by value, so the join only ever saw a stale copy of
the control block. Store a pointer to a heap allocated TX_THREAD
instead, the way the Zephyr port already does, so the join operates on
the block ThreadX is scheduling.

wolfSSL_JoinThread now polls tx_thread_info_get until the thread reports
TX_COMPLETED or TX_TERMINATED, calls tx_thread_delete and checks its
result, and only then frees the stack and the control block.

Fixes F-7413.
2026-08-07 08:11:23 +02:00
Tobias Frauenschläger 9533a8182a Fix RSA_W_ENC verify guard in signature wrapper
The DigestInfo length extraction in wc_SignatureVerifyHash was compiled
only when WOLFSSL_RSA_PUBLIC_ONLY was not defined, but the block depends
on ASN.1 support, not on private key support. In a public only build the
RSA verify path stays reachable and wc_SignatureVerify still DER encodes
the digest, so the length check fell through to the plain digest size
comparison and rejected every valid signature with BAD_LENGTH_E. The
same guard also broke compilation with NO_ASN and RSA enabled, since
asn.h is not included in that case and GetSequence and GetOctetString
are undeclared.

Guard the block on NO_ASN instead, matching the DER encode call site in
wc_SignatureVerify.

Fixes F-7412.
2026-08-07 08:11:23 +02:00
Sean Parkinson f9038b7809 Documentation and embedded user_settings.h.
Added documentation of the defines for algorithms and assembly code and math.
user_settings_embedded.h has configuration defines at the top that are set to
0 for off and 1 for on. Setting these turns on the appropriate defines.
2026-08-07 15:07:27 +10:00
David Garske b7dd5bb06e Peer review fixes 2026-08-06 16:56:10 -07:00
David Garske 1d264ccc5f mlkem: mask WOLFSSL_MLKEM_SMALL compress_10 pack with WC_OCTET for CHAR_BIT != 8 2026-08-06 16:56:10 -07:00
David Garske e2a9f72b01 sp: use CHAR_BIT not 8 in sp_*_from_mp constant-time mask for CHAR_BIT != 8 (fixes C28x ECC/RSA/DH) 2026-08-06 16:56:10 -07:00
David Garske 8d34ef4bde test: guard ecc_test DER key export/import helpers behind !NO_ASN 2026-08-06 16:56:10 -07:00
David Garske 4f2fd9c23c test/benchmark/ci: CHAR_BIT != 8 test vectors, NO_MALLOC benchmark, TI C2000 compile CI and docs 2026-08-06 16:56:10 -07:00
David Garske f9e34083f5 ecc/25519/448/sp: octet-correct X25519/Ed25519/X448/Ed448 and SP byte<->mp conversion for CHAR_BIT != 8
Curve448/Ed448 build with the CURVE448_SMALL / ED448_SMALL byte-array
field backend (the default fe_448 backend needs __uint128_t for the
sc448 mod-order arithmetic, which the C28x toolchain lacks).  The SMALL
fe448 carry-stores wrote each limb through a (word8) cast that does not
truncate to an octet when a C byte is wider than 8 bits, so the next
carry re-read saw a corrupted limb; mask each carry-store with WC_OCTET
(a no-op on the usual 8-bit-byte targets).
2026-08-06 16:55:52 -07:00
David Garske e44b63fc52 mldsa/mlkem: correct ML-DSA and ML-KEM on CHAR_BIT != 8; add WOLFSSL_MLDSA_VERIFY_SMALLEST_MEM 2026-08-06 16:55:52 -07:00
David Garske a326618937 aes/chacha: octet-correct block, key, keystream and XTS-tweak I/O for CHAR_BIT != 8 2026-08-06 16:55:52 -07:00
David Garske 5371237eb8 sha: octet-correct SHA-1/SHA-2 byte I/O and 32-bit split Keccak permutation for CHAR_BIT != 8 2026-08-06 16:55:52 -07:00
David Garske b6be0c878d wolfcrypt: add WOLFSSL_WIDE_BYTE support for CHAR_BIT != 8 targets (TI C2000 C28x) - core types, misc octet helpers, base64, DRBG 2026-08-06 16:55:09 -07:00