Commit Graph
30893 Commits
Author SHA1 Message Date
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
Daniele Lacamera b34d8ba1d2 tests: fix codespell in gap white-box comments
Reword "statics" -> "static functions" in test_ed448_whitebox_gap.c and
test_wc_xmss_impl_whitebox_gap.c (codespell flags "statics").
2026-07-17 08:56:03 +02:00
Daniele Lacamera 0a560b0106 tests: MC/DC gap-closing for Part 3 wolfCrypt modules
Close API-reachable and file-static MC/DC gaps identified by the per-module
GAPS.md reports (+291 conditions across the union):
  tfm.c 71->89, integer.c 49->92, ed448.c 62->92 (91%), wc_slhdsa.c 99->155
  (88%), wc_mldsa.c 169->252, wc_mlkem.c 46->65 (96%), wc_lms_impl.c 60->82,
  wc_xmss_impl.c 38->57.

Enriched DecisionCoverage in test_wolfmath.c (tfm/integer), test_ed448.c,
test_slhdsa.c; new arg/state/length cases in test_mldsa.c/test_mlkem.c; and
per-source *_gap white-box supplements under tests/unit-mcdc/ driving the
static internals (WOTS/FORS/NTT/poly/Merkle/comba/Montgomery, etc.). Remaining
uncovered conditions are justified residuals (AVX2/cpuid dispatch on an
always-AVX2 host, deep alloc/crypto-failure err-chains, asm-only paths).
2026-07-17 08:56:03 +02:00
Daniele Lacamera 8bc6cf9c1a tests: address PR #10912 review - force DRBG reseed-interval path
Copilot review (test_random.c:1238): test_wc_DrbgFeatureCoverage claimed a
bounded burst of generate calls crosses WC_RESEED_INTERVAL, but the default
interval is 1,000,000 so 40 generates never reach it and the
DRBG_NEED_RESEED -> PollAndReSeed branch was not exercised in normal builds.

Force the path instead: probe one generate to confirm the Hash_DRBG path is
active (skipped under e.g. --enable-intelrand), then set the active DRBG's
reseedCtr to WC_RESEED_INTERVAL - 1 and generate across it, asserting the
reseed resets the counter (same idiom as test_wc_RNG_ReseedBoundary), for
both SHA-256 and SHA-512 DRBG widths. Comment corrected to match.
2026-07-17 08:56:03 +02:00
Daniele Lacamera c6af916e81 tests: fix CI regressions in MC/DC coverage Part 3
- CMakeLists.txt: register the new tests/api sources (test_kdf.c,
  test_coding.c, test_error.c, test_wolfentropy.c) with the unit_test
  target; fixes cmake link failure (undefined
  test_wc_GetErrorStringDecisionCoverage/test_wc_ErrorStringDecisionCoverage).
- tests/api/test_mldsa.c: guard the wc_MlDsaKey_MakeKey NULL-arg checks
  in test_wc_MldsaDecisionCoverage with WOLFSSL_MLDSA_NO_MAKE_KEY; fixes
  link failure in verify-only builds (tinytls13-psk-mldsa,
  all-pq-verify-only-noasm).
- tests/unit-mcdc/*: reword 'statics' to 'static helpers' in comments to
  satisfy codespell.
2026-07-17 08:56:03 +02:00
Daniele Lacamera 6859a144cb tests: MC/DC coverage for remaining wolfCrypt modules (Part 3)
Adds/extends tests/api MC/DC DecisionCoverage + FeatureCoverage and
tests/unit-mcdc white-box supplements for the remaining wolfCrypt
primitives (first-pass per-module union; gap-closing to follow):

- classic bigint: tfm.c, integer.c (extend test_wolfmath.c; tfm/integer whiteboxes)
- coding.c, error.c, wc_encrypt.c, pwdbased.c
- ed448.c + curve448.c (shared fe_448/ge_448 backends; ed448 whitebox)
- random.c deepened + new wolfentropy.c (MemUse SP800-90B), whiteboxes
- hash.c, kdf.c, signature.c, chacha20_poly1305.c
- LMS/XMSS (wc_lms*.c, wc_xmss*.c) with impl whiteboxes
- ML-KEM (wc_mlkem*.c), ML-DSA (wc_mldsa.c), SLH-DSA (wc_slhdsa.c) with whiteboxes

New tests register in tests/api.c + tests/api/include.am. Frozen-module
guards (!HAVE_SELFTEST && !HAVE_FIPS) applied to new random.c/pwdbased.c
tests that call post-v4.1.0 symbols.
2026-07-17 08:56:03 +02:00
jackctj117andGitHub 2c5e135bf9 Merge pull request #10934 from kaleb-himes/ISOLATED-FIXES
Bare minimum change set to stabalize fips-ready
2026-07-16 16:25:34 -06:00
JacobBarthelmehandGitHub 4e27e2ca63 Merge pull request #10893 from SparkiDev/riscv64_asm_1
RISC-V 64-bit: rework assembly code.
2026-07-16 16:10:46 -06:00
JacobBarthelmehandGitHub 5418d6cfdc Merge pull request #10927 from danielinux/fix-error-consistency-with-debug
Hash: consistent error code for uninitialized wc_Hash ops under DEBUG_WOLFSSL
2026-07-16 15:06:51 -06:00
kaleb-himes 432d5e375d Bare minimum change set to stabalize fips-ready 2026-07-16 11:03:07 -06:00
JacobBarthelmehandGitHub 43936e64c8 Merge pull request #10914 from stenslae/fix/apache-mynewt-header-build
Apache mynewt header build fix
2026-07-16 10:24:18 -06:00
JacobBarthelmehandGitHub 08539e40a6 Merge pull request #10903 from miyazakh/f_issues_SCE
[Renesas RA6M4] Fix Renesas RA6M4 SCE session-key generation issues
2026-07-16 10:04:52 -06:00
JacobBarthelmehandGitHub 7a062fd563 Merge pull request #10924 from holtrop-wolfssl/zd22155
Rust wrapper: check DH::shared_secret buffer size against prime size
2026-07-16 10:01:55 -06:00
Josh Holtrop 708357c403 Rust wrapper: check DH::shared_secret buffer size against prime size
The underlying C API treats the agreeSz parameter as output-only.
2026-07-15 23:37:49 -04:00
Sean Parkinson 3606633b22 RISC-V 64-bit: rework assembly code.
Assembly code generated from scripts.
Have separate assembly files and new inline code.
2026-07-16 09:39:09 +10:00
JacobBarthelmehandGitHub 139522b92d Merge pull request #10892 from embhorn/gh10792
Reject HelloRetryRequest lacking supported_versions before downgrade
2026-07-15 15:53:05 -06:00
JacobBarthelmehandGitHub 8510488d6b Merge pull request #10910 from Frauschi/lms_xmss_test_fix
Testing: unique per-process temp paths for stateful LMS/XMSS key tests
2026-07-15 15:48:22 -06:00
Daniele Lacamera 546b78c14c hash: consistent error code for uninitialized wc_Hash ops under debug
Under DEBUG_WOLFSSL the hash->type != type check in wc_HashUpdate,
wc_HashFinal and wc_HashFree fired for an uninitialized hash
(hash->type == WC_HASH_TYPE_NONE), returning BAD_FUNC_ARG where a non-debug
build returns HASH_TYPE_E from the type switch, so the returned error code
depended on whether DEBUG_WOLFSSL was defined. Only apply the mismatch check
to initialized hashes; the genuine init-then-wrong-type misuse check is
preserved.
2026-07-15 23:44:40 +02:00
Daniel PouzznerandGitHub fc74ebdc74 Merge pull request #10885 from philljj/fips_v7_guards
random.c: fix fips v7 define guards.
2026-07-15 16:34:22 -05:00
JacobBarthelmehandGitHub 05c84bcd94 Merge pull request #10908 from LinuxJedi/valgrind-fixes
Fix a couple of Valgrind hits
2026-07-15 15:27:49 -06:00
Emma Stensland 5bd7348512 apache mynewt header build fix 2026-07-15 11:55:59 -06:00
Tobias FrauenschlägerandDaniele Lacamera 9d86960672 Fix AES GCM decrypt auth tag failure test 2026-07-15 15:10:52 +02:00
Tobias Frauenschläger fc87614cdc Testing: unique per-process temp paths for stateful LMS/XMSS key tests
The LMS and XMSS X.509 generation tests persist their stateful private
keys through read/write callbacks to hardcoded /tmp paths
(/tmp/wolfssl_test_lms.key, /tmp/wolfssl_test_xmss_gen.key). When
make check runs multiple configs in parallel on a shared /tmp (CI
shards), concurrent unit.test processes clobber the same file; a
subsequent read then gets a different-sized key and signing fails with
IO_FAILED_E (e.g. test_rfc9802_xmss_x509_gen returning -291).

Give the LMS and XMSS test key-file paths a per-process name via
getpid(), guarded by HAVE_GETPID/WOLFSSL_NO_GETPID with <unistd.h>
included under the same guard and a plain-path fallback, so the file
still compiles on Windows / NO_WOLFSSL_DIR / no-OS builds. Verified by
racing six concurrent unit.test processes: 5/6 failed before, 6/6 pass
after; the HAVE_GETPID and fallback paths both compile clean under
-Werror.
2026-07-15 14:08:19 +02:00
Andrew Hutchings 8066fbceaa Fix a couple of Valgrind hits
```
==485951==  Uninitialised value was created by a stack allocation
==485951==    at 0x207D47: des3_key_wrap_test (test.c:12773)
```

and

```
==485951==  Uninitialised value was created by a stack allocation
==485951==    at 0x3A075E: test_wc_AesGcmArgMcdc (test_aes.c:8968)
```
2026-07-15 11:28:45 +01:00
Tobias FrauenschlägerandGitHub 986fed770c Merge pull request #10907 from SparkiDev/asm_include_fix
Include the correct wolfSSL header for inline C asm.
2026-07-15 10:44:47 +02:00
Tobias FrauenschlägerandGitHub 55d06ec678 Merge pull request #10866 from kojo1/rsaKeySz
check RSA key size for PSS
2026-07-15 10:43:43 +02:00
Tobias FrauenschlägerandGitHub c327ea36bf Merge pull request #10904 from aidangarske/fix/pkcs7-stream-signed-content
Fix PKCS7 streamed SignedData dropping content
2026-07-15 09:43:34 +02:00
Sean Parkinson b0dfa35bbe Include the correct wolfSSL header for inline C asm.
wolfssl/wolfcrypt/libwolfssl_sources_asm.h is for assembly files.
wolfssl/wolfcrypt/libwolfssl_sources.h is for C files.
2026-07-15 17:40:19 +10:00
Tobias FrauenschlägerandGitHub 2494da4a46 Merge pull request #10895 from danielinux/aes-gcm-fix-ct-compare
AES-GCM: constant-time output clear on decrypt auth failure
2026-07-15 08:54:27 +02:00
Tobias FrauenschlägerandGitHub a182896115 Merge pull request #10906 from SparkiDev/test_fixes_4
Testing fixes: unit.test - PKCS#7 and --send-ticket
2026-07-15 08:22:06 +02:00
Sean Parkinson 043f798ef8 Testing fixes: unit.test - PKCS#7 and --send-ticket
test_pkcs7.c: test_wc_PKCS7_BER also accepts ret >= 0 (Bleichenbacher mitigation hides the RSA key error, making the result non-deterministic).
suites.c: skip --send-ticket cases as NOT_BUILT_IN when HAVE_SESSION_TICKET
  is off (avoids port-11111 race).
2026-07-15 11:28:08 +10:00
aidan garske 9b1aad457d Fix PKCS7 streamed SignedData dropping content 2026-07-14 16:47:31 -07:00
JacobBarthelmehandGitHub 26538a252c Merge pull request #10884 from kareem-wolfssl/zd22127_2
Adjust wolfEntropy size calculation and error out if an invalid combination of settings is given.
2026-07-14 16:12:50 -06:00
Takashi Kojo 14d939b801 Key-size check for RSA-PSS/SHA-256/384/512 2026-07-15 06:53:13 +09:00
Hideki Miyazaki c0c2588baf addressed review comments 2026-07-15 06:03:03 +09:00
Hideki Miyazaki 3fac5bf57b Addressed comments 2026-07-15 06:03:03 +09:00
Hideki Miyazaki 36a9e4404e fix fenrir issues for Renesas SCE 2026-07-15 06:03:02 +09:00
Daniele Lacamera 3ad29463ff test: exclude WOLFSSL_RISCV_ASM from AES-GCM auth-fail zero-check
The RISC-V ASM build provides its own AES-GCM implementation
(wolfcrypt/src/port/riscv/riscv-64-aes.c) rather than AES_GCM_decrypt_C, so
it does not clear the output buffer on authentication failure. Exclude it
from the zero-check, matching the other non-C decrypt paths. Fixes the
riscv64 multi-arch testwolfcrypt failure.
2026-07-14 20:17:48 +02:00
Daniele Lacamera 601ad77e15 test: fix AES-GCM auth-fail zero-check guard (review + run on x86)
Skoll review of the auth-fail zero-check test in aesgcm_test:

- The guard listed WOLFSSL_ARMASM_NO_HW_CRYPTO and __aarch64__, which are
  defined on default x86-64 builds, so the zero-check block was compiled out
  and the assertion never actually ran there. They are subsumed by
  WOLFSSL_ARMASM (the condition under which AES_GCM_decrypt_C is not the
  decrypt path), so use that instead and the check runs on the C path.

- Exclude WC_AES_GCM_DEC_AUTH_EARLY (out is not written on an early-auth
  failure) and WOLFSSL_ASYNC_CRYPT (a real async device may offload the
  decrypt and not clear the output).

Verified: default make check passes with the zero-check now executing;
testwolfcrypt AES-GCM passes with --enable-aesni and with
-DWC_AES_GCM_DEC_AUTH_EARLY.
2026-07-14 19:53:01 +02:00
JacobBarthelmehandGitHub 6722de5635 Merge pull request #10882 from kareem-wolfssl/zd22127
Use safe sum in PKCS7_VerifySignedData.
2026-07-14 10:00:50 -06:00
JacobBarthelmehandGitHub 7b501242b8 Merge pull request #10876 from danielinux/mcdc-test-coverage
Mcdc test coverage campaign - part 2
2026-07-14 09:59:45 -06:00
Daniele Lacamera e7938b3a07 Remove unneeded .wolfssl_known_macro_extras entries
check-source-text reports these as unneeded because the macros are now
defined in the checked build config, so their known-extra whitelist entries
are redundant:
  WOLFSSL_ASN_TEMPLATE_NEED_SET_INT32
  WOLFSSL_ASYNC_CERT_YIELD
  WOLFSSL_MLKEM_DYNAMIC_KEYS
2026-07-14 17:12:42 +02:00
Daniele Lacamera 23ad1c1d7a AES-GCM: skip output clear for AUTH_EARLY; test auth-fail output zeroing
Review follow-ups for the constant-time AES-GCM decrypt output clear:

- Guard the output-masking pass with #ifndef WC_AES_GCM_DEC_AUTH_EARLY. In
  that configuration the tag is verified before decryption and a mismatch
  returns before any output is written, so the masking pass is a guaranteed
  no-op; skipping it avoids a wasted O(sz) pass.

- Add a test in aesgcm_test: decrypt with a corrupted tag into a pre-filled
  buffer and assert wc_AesGcmDecrypt returns AES_GCM_AUTH_E and, on the
  software C path, that the output buffer is cleared to zero. The AES-NI/asm
  decrypt paths and the FIPS module do not clear the output on auth failure,
  so the zero check forces the C path (use_aesni = 0) and is limited to it
  (and skipped under HAVE_FIPS). The AES_GCM_AUTH_E comparison uses
  WC_NO_ERR_TRACE().

Verified (gcc 15.2): make check passes on the default (C path) build;
testwolfcrypt AES-GCM passes with --enable-aesni and with
-DWC_AES_GCM_DEC_AUTH_EARLY; ct-valgrind aes_gcm reports 0 errors.
2026-07-14 17:12:42 +02:00
Daniele Lacamera 9dffa3ce63 AES-GCM: constant-time output clear on decrypt auth failure
AES_GCM_decrypt_C cleared the output on a tag mismatch with
'if (ret != 0) ForceZero(out, sz)'. That is a conditional branch on the
secret-dependent authentication result, which is not constant time and is
flagged by the ct-valgrind constant-time test (Conditional jump depends on
uninitialised value in AES_GCM_decrypt_C).

Mask the output with 'res' (already computed as all-ones on tag mismatch,
zero on match) instead of branching, matching the constant-time idiom used
for the tag comparison itself. C path only; the AES-NI/ASM paths are
unaffected.
2026-07-14 10:43:25 +02:00