Skip to content

Mcdc test coverage - part 7 - #11222

Open
danielinux wants to merge 56 commits into
wolfSSL:masterfrom
danielinux:mcdc-test-coverage
Open

Mcdc test coverage - part 7 #11222
danielinux wants to merge 56 commits into
wolfSSL:masterfrom
danielinux:mcdc-test-coverage

Conversation

@danielinux

Copy link
Copy Markdown
Member

Extends the MC/DC (modified condition/decision coverage) test suites for wolfCrypt and, for the first time, the TLS protocol engine in src/.

Goals

  • Bring src/tls13.c under MC/DC measurement. Previous work covered wolfCrypt only; this establishes coverage for the TLS 1.3 handshake and record paths, with TLS 1.2 to follow.
  • Finish the wolfCrypt work. Every measured condition should end either covered by a test or documented with an argument, from the source, for why no input can produce its independence pair.
  • Prefer API-level tests to white-box drivers. A white-box driver is only justified where no public entry point can vary the operand. Where a feature simply had no test, the fix is a test.
  • Keep results reproducible. Coverage must be stable run to run, and anything left uncovered carries either a written argument or an explicit note that it is unfinished.

Contents

TLS 1.3 (src/tls13.c). New API-level tests in tests/api/ covering handshake-flight boundary and fragmentation behaviour, and feature combinations with no prior test — ECH enable/disable at run time and its interaction with client authentication, session tickets and PSK; PSK key-exchange modes including psk_ke; HelloRetryRequest with an accepted cookie; post-handshake authentication, including OCSP stapling rebuilt during it; session tickets with no ticket-encryption callback; and post-handshake messages of illegal types. Plus white-box drivers in tests/unit-mcdc/ for internal helpers that no public caller can reach with the argument combinations required.

wolfCrypt. New and extended drivers across the ASN.1 and PKCS encoding paths, the SP math host and ARM backends, the classic big-integer backends, the post-quantum modules, and the smaller primitives. Several modules gain a driver for the first time. The bare-metal Cortex-M lane gains a white-box mechanism it lacked, bringing its SP, AES and PUF conditions into reach.

Fixes, each in its own commit and touching no test code:

  • DSA key and parameter generation cleared mp_ints that a failed mp_init_multi() had never constructed.
  • The XMSS exhausted-key index marker wrapped, re-enabling signing after exhaustion.
  • The AES key-wrap _ex test allocated an Aes without the alignment the type declares.

Modules covered

asn, pkcs7, pkcs12, tsp, dsa, dh, rsa, ecc, eccsi, sakke, srp, curve25519, ed25519, ed448, lms, xmss, mldsa, mlkem, slhdsa, falcon, frodokem, aes, chacha/poly1305/chacha20-poly1305, kdf, pwdbased, wc_encrypt, puf, she, the SP math backends, the classic big-integer backends, wolfmath, wolfentropy, cr

Notes for review

  • All changes are test-side except the three fixes above, which are separable by path.
  • tests/unit-mcdc/ sources are EXTRA_DIST only; they are not built by the library and define their own main().
  • New API tests use the existing in-process test_memio_* harness and reference no WOLFSSL_ary builds are unaffected.
  • Some conditions are deliberately left uncovered rather than argued away, where the route is understood but not yet built.

Copilot AI lite review requested due to automatic review settings August 20, 2026 16:19
@danielinux danielinux self-assigned this Aug 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request extends the ISO 26262 MC/DC coverage suite across wolfCrypt and (newly) the TLS 1.3 engine, primarily by adding/expanding API-level tests and unit MC/DC white-box drivers, plus a small set of correctness fixes in core crypto code discovered during coverage work.

Changes:

  • Expand TLS 1.3 and wolfCrypt MC/DC coverage via new tests/api/* cases and many tests/unit-mcdc/* white-box supplements.
  • Fix correctness issues found during coverage: XMSS exhausted-index validity, DSA mp_init_multi() failure cleanup handling, and AES key-wrap test alignment.
  • Update harness/docs glue (tests/include.am, tests/api/include.am, tests/api.c) to register/distribute new tests and white-box sources.

Reviewed changes

Copilot reviewed 127 out of 127 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
wolfssl/internal.h Make ChaCha20-Poly1305 header visible whenever suites are built; adjust PEM error-reason comparisons to use WC_NO_ERR_TRACE.
wolfcrypt/test/test.c Fix AES key-wrap _ex test to use properly aligned Aes storage on-stack.
wolfcrypt/src/wc_xmss_impl.c Fix XMSS index validity checks to avoid wrap-around at exhausted-key markers.
wolfcrypt/src/dsa.c Map mp_init_multi() failures to MP_INIT_E and gate cleanup accordingly.
tests/unit-mcdc/test_xmss_hash_fault_whitebox.c Update white-box notes/text to suite/harness terminology.
tests/unit-mcdc/test_xmss_fault_whitebox.c Update comments/notes to suite/harness terminology.
tests/unit-mcdc/test_wolfentropy_whitebox.c Add SHA3-256 interposer and new startup-noise failure vector for MC/DC; update harness wording.
tests/unit-mcdc/test_wc_port_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_wc_mlkem_poly_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_wc_mldsa_whitebox.c Add CheckKey range-row driver; ensure unbuffered stdout; comment wording updates.
tests/unit-mcdc/test_wc_lms_impl_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_wc_lms_impl_whitebox_gap.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_wc_encrypt_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_tsp_whitebox.c Comment wording updates for uncovered-condition report + harness terminology.
tests/unit-mcdc/test_tsp_fault_whitebox.c Add vectors around TspResponse_Verify cert operand; comment wording updates.
tests/unit-mcdc/test_tfm_whitebox.c Fix/clarify MC/DC rationale notes; ensure unbuffered stdout; comment wording updates.
tests/unit-mcdc/test_srp_whitebox.c New SRP hash-fault white-box supplement to close one open condition.
tests/unit-mcdc/test_sp_x86_64_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_sp_int_whitebox.c Ensure settings loaded before deterministic RNG header; add pinned seed and new closure path; comment wording updates.
tests/unit-mcdc/test_sp_int_fault_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_sp_fault_common.h Comment wording updates for harness terminology.
tests/unit-mcdc/test_sp_crafted_common.h Broaden asm-backend gating list; comment wording updates.
tests/unit-mcdc/test_sp_cortexm_whitebox.c Update lane description wording.
tests/unit-mcdc/test_sp_cortexm_fault_whitebox.c New Cortex-M SP heap-fault white-box supplement via new lane mechanism.
tests/unit-mcdc/test_sp_cortexm_crafted_whitebox.c New Cortex-M SP crafted-input white-box supplement via new lane mechanism.
tests/unit-mcdc/test_sp_c32_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_sp_armthumb_whitebox.c Add shared crafted-input driver include and alloc fault include; invoke shared vectors.
tests/unit-mcdc/test_sp_arm64_whitebox.c Add shared crafted-input driver include and alloc fault include; invoke shared vectors.
tests/unit-mcdc/test_sp_arm32_whitebox.c Add shared crafted-input driver include and alloc fault include; invoke shared vectors.
tests/unit-mcdc/test_sp_arm_fault_common.h Comment wording updates for suite/harness terminology.
tests/unit-mcdc/test_slhdsa_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_slhdsa_hash_fault_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_signature_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_she_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_sha256_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_sakke_fault_whitebox.c Add interposition-driven coverage for retry-loop and helper reductions; comment wording updates.
tests/unit-mcdc/test_rsa_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_rsa_fault_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_random_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_random_fault_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_pwdbased_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_puf_gf_whitebox.c New PUF GF(2^7) helper white-box supplement.
tests/unit-mcdc/test_poly1305_whitebox.c Comment wording updates for module registry / harness terminology.
tests/unit-mcdc/test_pkcs7_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_pkcs7_mutate_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_pkcs7_fault_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_pkcs7_arg_whitebox.c Add EncodeContentStream pad-gate driver; add unreachable rationale note; comment wording updates.
tests/unit-mcdc/test_pkcs12_whitebox.c Comment wording updates for suite terminology; small note updates.
tests/unit-mcdc/test_pkcs12_parse_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_pkcs12_fault_whitebox.c Comment wording updates for suite/harness terminology.
tests/unit-mcdc/test_mlkem_poly_hash_fault_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_mlkem_fault_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_mldsa_hash_fault_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_mldsa_fault_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_memory_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_logging_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_lms_hash_fault_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_kdf_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_kdf_hash_fault_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_integer_whitebox.c Comment wording updates for suite/harness terminology.
tests/unit-mcdc/test_integer_fault_whitebox.c Comment wording updates for suite/harness terminology.
tests/unit-mcdc/test_hpke_fault_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_frodokem_mat_hash_fault_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_frodokem_mat_fault_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_frodokem_fault_common.h Comment wording updates for suite terminology.
tests/unit-mcdc/test_frodokem_cryptocb_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_falcon_whitebox.c Update residual notes to refer to exclusion record; comment wording updates.
tests/unit-mcdc/test_ed448_whitebox.c Comment wording updates for suite/harness terminology.
tests/unit-mcdc/test_ed448_hash_fault_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_ed25519_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_ed25519_hash_fault_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_ecc_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_ecc_fault_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_dsa_fault_whitebox.c Add targeted fault hooks/vectors for DSA init/cleanup and MEMORY_E path; comment wording updates.
tests/unit-mcdc/test_dh_fault_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/test_curve25519_whitebox.c Add RNG interposer to close blinding rz rejection-loop condition; ensure unbuffered stdout.
tests/unit-mcdc/test_cmac_whitebox.c Comment wording updates for harness terminology.
tests/unit-mcdc/test_chacha20_poly1305_whitebox.c Comment wording updates for exclusion record / harness terminology.
tests/unit-mcdc/test_chacha_whitebox.c Comment wording updates for module registry / harness terminology.
tests/unit-mcdc/test_asn_whitebox.c Ensure unbuffered stdout; comment wording updates for suite terminology.
tests/unit-mcdc/test_asn_keys_whitebox.c Add additional MC/DC vectors for PKCS8/PBES encode and ECC key DER branches.
tests/unit-mcdc/test_aes_whitebox.c Comment wording updates for suite terminology.
tests/unit-mcdc/README.md Update documentation to “suite/harness” terminology and clarify build contract.
tests/unit-mcdc/mcdc_seed_rng.h Ensure settings included before feature probing; update harness terminology.
tests/unit-mcdc/mcdc_fault_mutex.h Comment wording updates for suite terminology.
tests/unit-mcdc/mcdc_fault_mpint.h Comment wording updates for suite terminology.
tests/unit-mcdc/mcdc_fault_mp.h Comment wording updates for suite terminology.
tests/unit-mcdc/mcdc_fault_hash.h Comment wording updates for suite terminology.
tests/unit-mcdc/mcdc_fault_alloc.h Comment wording updates for suite terminology.
tests/unit-mcdc/mcdc_der_edit.h Comment wording updates for suite terminology.
tests/include.am Add new unit-mcdc sources to EXTRA_DIST; update suite wording.
tests/api/test_wolfmath.c Comment wording updates for harness terminology.
tests/api/test_tls13.c Add additional TLS 1.3 API guard acceptance vectors and related coverage notes.
tests/api/test_tls13_features.h New header declaring TLS 1.3 feature coverage tests and registration macro.
tests/api/test_tls13_bounds.h New header declaring TLS 1.3 bounds/fragmentation tests and registration macro.
tests/api/test_sakke.c Comment wording update.
tests/api/test_rsa.c Comment wording update.
tests/api/test_random.c Comment wording updates for uncovered-condition report / suite terminology.
tests/api/test_port.c Comment wording update.
tests/api/test_poly1305.c Comment wording update.
tests/api/test_mlkem.c Comment wording update.
tests/api/test_mldsa.c Comment wording update.
tests/api/test_kdf.c Comment wording updates for suite terminology.
tests/api/test_hmac.c Comment wording updates for suite terminology.
tests/api/test_hash.c Comment wording update.
tests/api/test_dh.c Comment wording update.
tests/api/test_chacha.c Comment wording update.
tests/api/test_aes.c Comment wording update.
tests/api/include.am Register new TLS 1.3 API test sources and distribute new headers.
tests/api.c Include and register new TLS 1.3 bounds/features test groups.
tests/api/test_tls13_bounds.c New TLS 1.3 bounds/fragmentation API tests (registered in build).
tests/api/test_tls13_features.c New TLS 1.3 feature-combination API tests (registered in build).
tests/unit-mcdc/test_lms_bds_whitebox.c New LMS BDS white-box supplement (distributed via EXTRA_DIST).
tests/unit-mcdc/test_tls13_whitebox.c New TLS 1.3 MC/DC white-box supplement (distributed via EXTRA_DIST).
tests/unit-mcdc/test_tls13_null_whitebox.c New TLS 1.3 NULL/guard-focused white-box supplement (distributed via EXTRA_DIST).
tests/unit-mcdc/test_wolfmath_whitebox.c New wolfmath MC/DC white-box supplement (distributed via EXTRA_DIST).
Suppressed comments (1)

wolfcrypt/src/dsa.c:441

  • wc_MakeDsaParameters() maps a failed mp_init_multi() to MP_INIT_E, but the cleanup logic checks for WC_NO_ERR_TRACE(MP_INIT_E). Under WOLFSSL_DEBUG_TRACE_ERROR_CODES, assigning plain MP_INIT_E can make the cleanup think init succeeded and call mp_clear() on objects that mp_init_multi() never constructed.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread wolfcrypt/src/dsa.c
…_TICKET

--enable-ech alone leaves session tickets off, so the server sends nothing
after the handshake and got_session_ticket stays 0.
Empty skeletons registered with automake, cmake and the api test table so
cases can be added without further build-system changes.
…ditions

Covers TLSX_UseSNI/UseALPN/UseMaxFragment/UseCertificateStatusRequest(V2)
argument guards, TLSX_SupportExtensions, TLSX_CSR2_InitRequests/
ForceRequest, TLSX_CSR_GetRequest_ex, wolfSSL_make_eap_keys,
wolfSSL_SetTlsHmacInner, BuildTlsHandshakeHash, TLS_hmac's size-overflow
and constant-time dispatch, and the ALPN/Cookie extension size guards.
One case per extension, each parsing the same crafted record in every
message type RFC 8446 4.2 permits for it and in one it does not.

Also puts the existing extension tests in test_tls_ext.c into the tls
group; they were registered without one and ran only in a full sweep.
Covers ALPN, trusted CA keys, client/server certificate type, cookie,
encrypt-then-mac, max fragment length, truncated HMAC, session ticket,
secure renegotiation, supported versions, signature algorithms,
certificate status request (v1/v2), EC point formats/supported curves,
SNI, and the cipher-suite/curve compatibility check, driven directly
through TLSX_Parse() and TLSX_ParseVersion() with hand-built extension
bodies.
Adds direct TLSX_Parse()-driven tests for TLSX_SNI_Parse's cacheOnly/
checkPublic/ECH-publicName match logic and TLSX_SNI_Find, the RFC 8446
4.2.11 pre_shared_key identity/binder walk and server-side identity
selection/resumption checks, TLSX_Cookie_Parse's DTLS 1.3 and echoed-
cookie comparison, and TLSX_TCA_Parse/TLSX_TCA_Find/TLSX_TCA_New.
… in tls.c

Adds direct-call and memio-driven tests for the CSR/CSR2 OCSP write and
size paths, ProcessChainOCSPRequest, TLSX_PopulateExtensions/
PopulateSupportedGroups, the TLSX_Write/GetSize msgType dispatchers
(SupportedVersions, EncryptThenMac, Client/ServerCertificateType,
SecureRenegotiation), and the TLSX_SessionTicket_Parse REJECT/
VERSION_ERROR false-false row.
The public test_*() entry points in test_tls_bounds.c were defined inside
their #if regions while api.c registers them unconditionally, so any build
without the feature failed to link. Move each guard into the function body
with a TEST_SKIPPED #else, and name the guards that cover a file-scope
helper plus its test(s) so region and body cannot drift apart.

Add WOLFSSL_TEST_STATIC_BUILD to the two guards over regions that call the
WOLFSSL_LOCAL DtlsGetCidTxSize() and TLSX_ALPN_GetRequest().
Their callers sit behind differing feature guards, so a configuration that
compiles none of them in must not warn.
…ct it

OPENSSL_EXTRA compiles out the PSK_KEY_ERROR assignment, so the call
returns 0 and continues with a key size larger than its buffer.
TLSX_SupportedCurve_Preferred returns the first entry when the group is
in the supported set, and BAD_FUNC_ARG only when it is not.
Adds the missing WOLFSSL_TLS13 and WOLFSSL_SEND_HRR_COOKIE terms, keeps the
shared record builders available to the TLS 1.2 cases, and marks helpers whose
callers sit behind differing guards as possibly unused.
…lity

The server-side parse paths are compiled out by NO_WOLFSSL_SERVER, and a
TLS 1.2 server context cannot be created with no RSA and no ECC.
Configurations without a server or without RSA and ECC compile out every
caller.
It was placed inside #ifndef NO_DH, so a build without DH left it undefined
where the helpers use it.
…ility

Adds the HAVE_TLS_EXTENSIONS, per-extension and WOLFSSL_NO_TLS12 terms the
bodies need, and releases the SNI list a test detaches from its extension.
…y unused

Their callers sit behind differing feature guards, so any configuration can
compile in none of them.
Also guards the sni free helper on HAVE_SNI and gives the request-direction
key share entry a public key before it is written.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants