Commit Graph

30955 Commits

Author SHA1 Message Date
night1rider 64c7699f68 versal_gen2_asu: fix check-source-text native heap false positive and add port macros to .wolfssl_known_macro_extras. 2026-07-22 13:17:32 -06:00
night1rider 66f6f7c451 Xilinx Versal Gen2 ASU port: TRNG, hashes, HMAC offload 2026-07-20 17:02:38 -06:00
Daniel Pouzzner bd6388c0b6 Merge pull request #10951 from Frauschi/fix-dist-argmax
build: distribute IDE project trees per-directory to fix "make dist"
2026-07-20 17:06:10 -05:00
Daniel Pouzzner 69a994e62b Merge pull request #10945 from ejohnstown/ocsp-fail
OCSP: opt-in fail-closed on missing responder
2026-07-20 16:42:04 -05:00
JacobBarthelmeh 39a607384c Merge pull request #10920 from douzzer/20260713-WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED-etc
20260713-WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED-etc
2026-07-20 13:27:24 -06:00
JacobBarthelmeh e19a1a4dc4 Merge pull request #10912 from danielinux/mcdc-test-coverage
MC/DC coverage for wolfCrypt modules - Part 3
2026-07-20 10:10:39 -06:00
Daniel Pouzzner 3f9bc8c775 linuxkm/Makefile: fix module-update-fips-hash recipe to allow SHA512 verifyCore. 2026-07-20 11:09:53 -05:00
Daniel Pouzzner 6fcfadfee2 configure.ac: more FIPS v7/ready/dev DH purging: omit HAVE_FFDHE_* too. 2026-07-20 11:09:53 -05:00
Daniel Pouzzner f79b203745 wolfcrypt/src/sha3.c, wolfssl/wolfcrypt/sha3.h, wolfssl/wolfcrypt/error-crypt.h, wolfcrypt/src/error.c:
* Fix vector register restore on error paths in Sha3Update().

* Add SP 800-185 check against KMAC_FIPS_MIN_KEY in KmacInit() and
  KMAC_FIPS_MIN_OUTPUT in KmacFinal(), returning KMAC_MIN_KEYLEN_E and
  BAD_LENGTH_E respectively on failure.

* Use word32 rather than byte for wc_Sha3.i, wc_Cshake.count, wc_Kmac.count, and
  related, and add explicit range checking where needed, to fix a -Wconversion,
  fix possible overruns, obviate 14 casts, and eliminate (negligible) runtime
  overhead from masking and promotions.
2026-07-20 11:09:53 -05:00
Daniel Pouzzner ef070bf564 linuxkm/linuxkm-fips-hash-wrapper.sh: fix dependency on SHA-2 coreKey. 2026-07-20 11:09:53 -05:00
Daniel Pouzzner b4a9326842 configure.ac: fix DH dependencies for FIPS v7 (implicit --disable-dh). 2026-07-20 11:09:53 -05:00
Daniel Pouzzner 755220792e wolfcrypt/src/kdf.c, wolfssl/wolfcrypt/kdf.h: use "hash_type", not "hash", for the hash type in wc_PRF_fips(), for clarity and consistency. 2026-07-20 11:09:53 -05:00
Daniel Pouzzner d494864965 wolfssl/wolfcrypt/settings.h: add assert that WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED isn't defined in old FIPS builds. 2026-07-20 11:09:53 -05:00
Daniel Pouzzner 7897c335e0 configure.ac: don't include CShake or KMAC in enable-all-crypto when building FIPS < v7. 2026-07-20 11:09:53 -05:00
Daniel Pouzzner a7511940ff wolfssl/wolfcrypt/wc_compat.h: in non-streaming wc_AesGcmEncrypt_compat_shim(), restore aes->reg to the supplied IV after wc_AesGcmEncrypt_ex() increments it, supporting the EVP access pattern. 2026-07-20 11:09:53 -05:00
Daniel Pouzzner 09bcd2f391 wolfssl/wolfcrypt/wc_compat.h: FIPS v2 compatibility. 2026-07-20 11:09:53 -05:00
Daniel Pouzzner 00368d1cc4 wolfssl/wolfcrypt/error-crypt.h: #include <wolfssl/wolfcrypt/wc_port.h> where previously #include <wolfssl/wolfcrypt/types.h>, to retain standalone compilability without provoking circular dependencies via wc_compat.h. 2026-07-20 11:09:53 -05:00
Daniel Pouzzner b4095f0578 wolfcrypt/src/ed25519.c: whitespace fix (from AI review). 2026-07-20 11:09:53 -05:00
Daniel Pouzzner 08b5b65c26 configure.ac: add --enable-all-quantum-crypto "Enable all quantum-resistant asymmetric algorithms (default: disabled)". 2026-07-20 11:09:53 -05:00
Daniel Pouzzner 3db433a31a wolfcrypt/src/ed25519.c, tests/api/test_ed25519.c:
* add missing null key checks to wc_ed25519_verify_msg_init(), wc_ed25519_verify_msg_update(), and wc_ed25519_verify_msg_final().
* add WC_ARG_NOT_NULL() attributes to args of static functions as appropriate.
* add FIPS >v6 gates to new null key tests and a new invalid hash size test in test_wc_ed25519_sign_verify_ctx_ph() and test_wc_ed25519_verify_streaming().
2026-07-20 11:09:53 -05:00
Daniel Pouzzner 2628676b28 wolfssl/wolfcrypt/wc_compat.h, wolfssl/wolfcrypt/fips_test.h, .wolfssl_known_macro_extras:
* also inhibit recursive evaluation midway through random.h, fips.h, and fips_test.h (circular dependencies).
* add WC_FIPS_ENUM_CAST_ID_DEFINED to allow detection of fips_test.h incomplete evaluation.
2026-07-20 11:09:53 -05:00
Daniel Pouzzner 6f1e5a93d4 wolfcrypt/src/aes.c: revert atomic refactor of checkedAESNI, haveAESNI, and intel_flags (3f3ebcac58 / #10871) to avoid frivolous atomic access overhead. Also use regular int, not cpuid_flags_atomic_t, for cpuid_flags in the WOLFSSL_ARMASM path, and similarly use a regular int for aes_ppc64_use_crypto in the WOLFSSL_PPC64_ASM_CRYPTO path. 2026-07-20 11:09:53 -05:00
Daniel Pouzzner 9b30443288 linuxkm/lkcapi_aes_glue.c: in the inner streaming loops for AES-GCM and AES-XTS (AesGcmCrypt_1(), km_AesXtsEncrypt(), and km_AesXtsDecrypt()), bypass FIPS wrappers to avoid frivolous overhead, with decisive check after looping by the Final function. 2026-07-20 11:09:53 -05:00
Daniel Pouzzner 40623dada0 Implement FIPS shimming for wc_AesGcmEncrypt():
wolfssl/wolfcrypt/aes.h: if HAVE_FIPS && !WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED, make wc_AesGcmEncrypt() a WOLFSSL_LOCAL, and if !_WC_BUILDING_AES_C, add a WC_DEPRECATED() attribute to it.

wolfssl/wolfcrypt/wc_compat.h, wolfssl/wolfcrypt/include.am, .wolfssl_known_macro_extras: add wc_compat.h: when HAVE_FIPS and !WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED, shim wc_AesGcmEncrypt() to remap it to FIPS-allowed APIs.

wolfssl/wolfcrypt/types.h: at the end, #ifndef BUILDING_WOLFSSL, #include <wolfssl/wolfcrypt/wc_compat.h>, to assure transparent shimming of wc_AesGcmEncrypt() for all outside callers.

wolfcrypt/src/evp.c, wolfcrypt/src/hpke.c, wolfcrypt/src/pkcs7.c, wolfcrypt/benchmark/benchmark.c, wolfcrypt/test/test.c, wolfssl/ssl.h: #include <wolfssl/wolfcrypt/wc_compat.h> to shim in-library/in-module calls to wc_AesGcmEncrypt().

src/internal.c: in TicketEncDec(), add const attributes to constable input args, and fix swapped out/in in calls to wc_AesGcmEncrypt().

tests/api/test_aes.c: in test_wc_AesGcmEncryptDecrypt(), skip longIV test if WC_TEST_AES_GCM_ENCRYPT_NO_NONSTD_IV (defined by wc_compat.h when needed).

wolfssl/wolfcrypt/error-crypt.h, wolfssl/error-ssl.h, wolfcrypt/src/error.c, src/internal.c:
* add FIPS_WRONG_API_E;
* put several error codes back into sequence in wc_GetErrorString() switch().
* move wc_static_assert()s from headers to corresponding .c files, to eliminate dependency on wolfcrypt/types.h;
* remove unneeded #include <wolfssl/wolfcrypt/types.h> from error-crypt.h.
2026-07-20 11:09:53 -05:00
Tobias Frauenschläger 29506d2cac build: distribute IDE project trees per-directory to fix "make dist"
The non-recursive automake "distdir" recipe inlines the entire $(DISTFILES)
list into a single shell command. Enumerating every IDE integration file
individually made that list large enough (~123 KB) that the recipe exceeded
the Linux MAX_ARG_STRLEN (128 KB) single-argument exec limit, so "make dist"
failed with:

    /bin/bash: Argument list too long
    make[2]: *** [distdir-am] Error 127

Replace the per-file EXTRA_DIST enumeration of the IDE directories with one
wholesale "EXTRA_DIST += IDE/<dir>" entry per directory (automake copies the
tree recursively). This collapses ~745 file entries into ~52 directory
entries and shrinks the top-level DISTFILES from ~123 KB to ~97 KB, well
under the limit.

The set of distributed IDE files is unchanged: a before/after "make dist"
diff shows no project file added or removed (only the now-unused include.am
build fragments are gone). Three directories that intentionally omit some
tracked files (apple-universal, MPLABX16, Renesas - private IDE configs,
.gitkeep placeholders, helper scripts) stay enumerated file-by-file.
2026-07-20 17:22:10 +02:00
Tobias Frauenschläger 5012d1d6e7 check-source-text: whitelist WOLFSSL_OCSP_SCREEN_RESPONDER
WOLFSSL_OCSP_SCREEN_RESPONDER (from the OCSP AIA responder SSRF
screening work) is only ever enabled via
CPPFLAGS=-DWOLFSSL_OCSP_SCREEN_RESPONDER, a form the check-source-text
"unknown macros" -D pattern does not match, so the subtest reports it as
an unrecognized macro and fails. Add it to .wolfssl_known_macro_extras.

Also fix the C lexical ordering of HWCAP2_SME, which sorted after
HWCAP_ASIMDRDM ('2' precedes '_' in the C locale) and tripped the "not
in C lexical order" warning.
2026-07-20 15:28:41 +02:00
Sean Parkinson 7b5970b9b5 Merge pull request #10898 from danielinux/sp-from-mp-const-time
Regenerate SP sources: constant-time sp_*_from_mp
2026-07-20 23:06:41 +10:00
philljj 5dd7717d11 Merge pull request #10933 from holtrop-wolfssl/f-6445
Rust wrapper: Add ChaCha20Poly1305::finalize_verify()
2026-07-19 11:04:41 -05:00
JacobBarthelmeh c1ee61c8d1 Merge pull request #10888 from SparkiDev/kmac_cshake
KMAC and cSHAKE: Add new algorithms
2026-07-17 16:49:25 -06:00
JacobBarthelmeh 25b5636c30 Merge pull request #10808 from aidankeefe2022/fenrir-fixes-jun29-ak
Fix: WolfCrypt 7 fenrir fixes
2026-07-17 15:49:14 -06:00
JacobBarthelmeh d65b9ebf68 Merge pull request #10723 from ejohnstown/ocsp-fix
OCSP: opt-in SSRF screening of AIA responder
2026-07-17 14:45:18 -06:00
philljj 98f4d6f955 Merge pull request #10721 from JacobBarthelmeh/dev_2
Defensive code additions for sanity checks on input arguments with Base64, PEM write, mp_read_unsigned_bin
2026-07-17 15:34:35 -05:00
John Safranek ae0bac50c9 OCSP: opt-in fail-closed on missing responder
WOLFSSL_OCSP_CHECKALL is a scope flag ("always leaf, but all ?"), selecting
which certs are checked, not how hard to fail when one advertises no OCSP
responder in its AIA. Treating a missing responder as a hard failure breaks
any chain whose CA publishes no OCSP URI (e.g. Google GTS WR2), a
configuration that only grows as CAs drop responders. Strictness belongs in
its own opt-in flag.

- Keep CHECKALL scope-only; a cert with no responder soft-fails by default.
- Return distinct OCSP_NO_URL for "no responder", separate from a failed
  lookup; stapling response handling stays best-effort (mapped to CERT_GOOD).
- Add WOLFSSL_OCSP_FAIL_IF_NOT_SUPPORTED (via OcspNoUrlPolicy) to refuse such
  certs; independent of CHECKALL.
- Add test_ocsp_no_url_policy covering both halves.
2026-07-17 13:21:01 -07:00
John Safranek 6f087a502e OCSP: opt-in SSRF screening of AIA responder
- Add wolfIO_OcspDestAllowed(); block internal-range responder hosts
- Call it in EmbedOcspLookup before connect (CWE-918)
- Gate on WOLFSSL_OCSP_SCREEN_RESPONDER (off by default)
- Add unit tests and CI for both resolver paths
2026-07-17 13:11:16 -07:00
JacobBarthelmeh 6283bd6db8 Merge pull request #10891 from rlm2002/fipsEcc
add mp_clear(order) before freeing in _ecc_import_private_key_ex()
2026-07-17 13:35:41 -06:00
JacobBarthelmeh 2281459e2b Merge pull request #10923 from miyazakh/mldsa_verifyonly_op
Fix configure.ac so --enable-mldsa=verify-only
2026-07-17 13:26:43 -06:00
philljj dc1c77e079 Merge pull request #10830 from padelsbach/ed25519-cryptocb-only
Add crypto callback only mode for ed25519
2026-07-17 11:42:31 -05:00
JacobBarthelmeh 3984c8b1dd Merge pull request #10870 from SparkiDev/frodokem_1
FrodoKEM: Initial implementation
2026-07-17 10:14:47 -06:00
JacobBarthelmeh 575c107249 Merge pull request #10929 from Frauschi/xmss_cmake
CMake: fix XMSS wiring and complete LMS/XMSS sub-option parity
2026-07-17 09:27:12 -06:00
Paul Adelsbach d832415d32 Remove ed25519+fips cryptocb check in settings.h 2026-07-17 06:36:03 -07:00
Sean Parkinson 78df69d051 FrodoKEM: ASN.1 keys, X.509 certicates
Added support for encoding and decoding keys in ASN.1.
Added support for X.509 certificates and CSRs.
Generated certificates and CSRs. Not fo FrodoKEM-640 as is not in the specs.
2026-07-17 22:38:55 +10:00
Sean Parkinson 607d7cfdb3 FrodoKEM: Initial implementation
Supports Fast C code, small C code, small stack and assembly for x86_64, Aarch64, Aarch32, Thumb2.
2026-07-17 22:38:55 +10:00
Daniele Lacamera 4c36537053 Regenerate SP sources: constant-time sp_*_from_mp
Regenerated the single-precision C sources so that sp_<N>_from_mp() converts
secret inputs (ECDH/ECDSA private keys and nonces) in constant time: a
fixed-count loop bounded by the output size with masked reads at/after
a->used, instead of looping a->used times (which leaked the value's
magnitude through the executed-instruction count).

Fixes the ct-callgrind constant-time failures for P-521 (ec_p521_kex,
ec_p521_sign) and hardens the same pattern across all curves and key sizes
(108 sp_*_from_mp functions in sp_c32/sp_c64, sp_arm32/sp_arm64/sp_armthumb/
sp_cortexm and sp_x86_64).

Verified (--enable-sp, gcc 15.2): ec_p521_kex diff 156 -> 0, ec_p521_sign
diff 367 -> 55 (tol 300); testwolfcrypt RSA/ECC KATs pass.

Generated by https://github.com/wolfSSL/scripts/pull/626
2026-07-17 08:57:37 +02:00
Daniele Lacamera 3a47bfb78e tests: fix check-source-text and clang-tidy findings in Part-3 tests
check-source-text (rule I) flags error-code identifiers used as comparison
operands even inside comments. Reword three comments so the code name is no
longer written as "(ret == PUBLIC_KEY_E)" / "(ret != CRYPTOCB_UNAVAILABLE)"
(test_kdf.c, test_ed448.c); the bare token on its own is fine.

clang-tidy reported a possible 0-byte malloc in test_mlkem.c: the ML-KEM
key/ciphertext sizes come from wc_MlKemKey_*Size() queries, which the analyzer
cannot prove nonzero. Guard each XMALLOC with a >0 check so the allocation
size is provably positive; the ExpectNotNull() checks still catch a 0-size
query at runtime.
2026-07-17 08:56:03 +02:00
Daniele Lacamera 004cc22e9f tests: skip KDF MC/DC suites under FIPS/selftest (behavioral divergence)
The FIPS build diverges from the OPEN build on KDF behavior these exhaustive
MC/DC probes assert: wc_HmacSetKey enforces the 14-byte HMAC_FIPS_MIN_KEY, so
wc_Tls13_HKDF_Extract with the short salt/ikm here returns HMAC_MIN_KEYLEN_E
(-200) instead of 0 (test_kdf.c:766), and wc_PRF with resLen==0 returns 0
instead of BAD_FUNC_ARG (test_kdf.c:118). kdf.c coverage is measured only in
non-FIPS campaign variants, so guard both test_wc_KdfDecisionCoverage and
test_wc_KdfFeatureCoverage bodies with !HAVE_FIPS && !HAVE_SELFTEST; they run
in full in OPEN builds and skip cleanly under FIPS/selftest. Verified against
a --enable-fips=v5 build (both now skip, 0 failures).
2026-07-17 08:56:03 +02:00
Daniele Lacamera 28a9c5921f tests: fix shared-CI link and FIPS build for math/kdf MC/DC tests
kdf: wc_Tls13_HKDF_Extract_ex / wc_Tls13_HKDF_Expand_Label_ex postdate the
frozen FIPS/selftest kdf.h and are undeclared there. Gate every _ex call site
behind WOLFSSL_TEST_HKDF_EX (!HAVE_FIPS && !HAVE_SELFTEST); the thin non-_ex
wrappers, which exist everywhere, keep their coverage.

wolfmath: test_wc_TfmDecisionCoverage / test_wc_TfmExptModDecisionCoverage /
test_wc_IntegerDecisionCoverage called library-internal fp_* and s_mp_*
functions that carry no MP_API decoration, so under -fvisibility=hidden they
are not exported from the shared library and unit.test failed to link them
(undefined reference to fp_set / s_mp_mul_digs / ...) in the default shared CI
build. Relocate those decision drivers into the tests/unit-mcdc white-boxes,
which reach the internals legally by #including tfm.c / integer.c; tests/api
now uses only the public mp_* interface. mp_rand_prime calls are gated by
WOLFSSL_KEY_GEN (and, for integer, !NO_DH || !NO_DSA) to match where the
library declares and defines it.
2026-07-17 08:56:03 +02:00
Daniele Lacamera 2f5ae6c9ab tests: skip DEBUG-unreachable hash type-error checks in test_hash
Under DEBUG_WOLFSSL, wc_HashUpdate/Final/Free first check (hash->type != type)
and return BAD_FUNC_ARG before the switch, so the "unsupported type ->
HASH_TYPE_E" arm is unreachable on an uninitialized hash (wc_HashInit refuses
those types). Guard those Update/Final/Free assertions with #ifndef
DEBUG_WOLFSSL; the arm's coverage comes from non-DEBUG variants in the union.
Fixes the cmake (old-TLS/debug) build failure. wc_HashInit assertions keep
running (Init has no such type check).

This bug is fixed in PR #10927
2026-07-17 08:56:03 +02:00
Daniele Lacamera afe37aabd1 tests: MC/DC gap-closing for the deferred Part-3 modules
Close API-reachable and file-static gaps in the smaller modules (+52 union
conditions): kdf 75->91, coding 48->64, wolfentropy 9->13, curve448 54->58
(100%), chacha20_poly1305 43->46 (100%), hash 6->7 (100%), wc_encrypt 16->19,
pwdbased 14->17, signature 30->32. Additive cases in the existing tests (one
new test_wc_HashTypeConvert), plus wolfentropy/random white-box drivers.
Remaining are justified residuals (WOLFSSL_LOCAL wc_CryptKey, dead defensive
branches, alloc/crypto-failure err-chains, platform seed sources).
2026-07-17 08:56:03 +02:00
Daniele Lacamera 9509583f65 tests: drive read_write_ex shutdown to completion instead of fixed sequence
test_wolfSSL_read_write_ex hard-coded the close-notify exchange as
NOT_DONE/NOT_DONE/SUCCESS/SUCCESS, which is protocol-version/config dependent
and fails under the cmake old-TLS build. Loop wolfSSL_shutdown on each side
until WOLFSSL_SUCCESS (pre-existing flake, not from this PR's new tests).
2026-07-17 08:56:03 +02:00
Daniele Lacamera 92975dd9c8 tests: unify per-source white-box supplements into one file each
Merge the _gap white-box drivers into their base file (tfm, integer, ed448,
mldsa, mlkem_poly, slhdsa, xmss_impl) and delete the _gap copies; a single
binary per source also satisfies more MC/DC independence pairs (tfm 89->91,
integer 92->100, mlkem_poly 25->27, mldsa 252->256). LMS is kept as two files:
its sign-side drivers reference internals absent under verify-only/small
builds and use per-driver state that does not share one main() safely.
2026-07-17 08:56:03 +02:00