Skip to content

MC/DC: close aes.c condition gaps (part 10) - #12176

Open
danielinux wants to merge 5 commits into
wolfSSL:masterfrom
danielinux:mcdc-10-aes
Open

danielinux wants to merge 5 commits into
wolfSSL:masterfrom
danielinux:mcdc-10-aes

Conversation

@danielinux

Copy link
Copy Markdown
Member

aes gap 23 -> 7 (all 7 excluded, 0 open; check-closure CLOSED). Full union 477/484 (98.55%), native 416/470 (88.51%) across 8 native variants + m33mu lane; aarch64 lane excluded (pre-existing sha3.c build break + unaligned-allocator test issue).

Closed:

  • 15698 stream Final guard x4: test_wc_AesGcmStreamMcdc rewritten around the real state model (GcmInit-with-IV sets nonceSet only; SetIV sets ctrSet only) with 6 vectors including complete (T,T,T,T) and (T,F,-,-) rows; clang-21 pairs a vector only against rows where the unvaried operands are evaluated, so the old 5-vector set left idx0/2/3 unpaired.
  • 17329 wc_AesGetKeySize claimed-key guard x2: whitebox Class 13 corrupts the context (rounds=0, keylen=16) under plain WOLF_CRYPTO_CB.
  • 5289/8916/16032/16220/17963:1: whitebox Classes 12/14/15 (counter overflow preload, SetIV carry scan with deterministic RNG device, CFB loop ret guard) on the m33mu lane.
  • 13369 idx2: removed the redundant 'out != NULL' operand from the GcmDecrypt auth-fail wipe guard (the entry arg check already rejects NULL out); shrinks the decision from 3 to 2 operands.

Excluded (structural, in the campaign exclusion ledger):

  • 5991 x2 devOwned constant 0: needs WOLF_CRYPTO_CB_AES_SETKEY, which breaks upstream test_wc_CryptoCb_Tls13_Key_Zero_After_Offload (double SetKeysSide in SendTls13Finished re-imports the zeroed client_write_key; genuine upstream bug, to be fixed separately).
  • 8645 x2 CTR drain loop drained unconditionally before the ARM/PPC arm.
  • 15372:5 / 15992:5 complementary-operand pairs (ivSz>0, ivFixed!=NULL).
  • 17963:0 CFB loop ret guard: the arm wc_AesEncrypt (WOLFSSL_ARMASM_NO_HW_CRYPTO) returns 0 unconditionally, so ret is provably 0 at every evaluation.

Verification: sweep6 (8 native variants + m33mu) all green; check-closure.py aes: gap 7 = excluded 7 + open 0, CLOSED; fips-dev-no-post --enable-all (FIPS v7, AESGCM_STREAM on): aes group 78 tests, 0 failed; check-api-guards.py clean; baselines.json rebaselined to the native union 416/470 with the part-10 note.

Copilot AI balanced review requested due to automatic review settings November 18, 2026 17:10
@danielinux danielinux self-assigned this Nov 18, 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@danielinux

Copy link
Copy Markdown
Member Author

@claude review

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

gcc-arm-cortex-m0plus

  • FLASH: .text +40 B (+0.1%, 72,120 B / 262,144 B, total: 28% used)

gcc-arm-cortex-m3

  • FLASH: .text +40 B (+0.0%, 133,686 B / 262,144 B, total: 51% used)

gcc-arm-cortex-m4

  • FLASH: +5 B (+0.0%, 210,989 B / 262,144 B, total: 80% used)

gcc-arm-cortex-m4-baremetal

  • FLASH: +5 B (+0.0%, 74,932 B / 262,144 B, total: 29% used)

gcc-arm-cortex-m4-crypto-only

  • FLASH: .text +64 B (+0.0%, 183,824 B / 262,144 B, total: 70% used)

gcc-arm-cortex-m4-dtls13

  • FLASH: .rodata +4 B, .text +64 B (+0.0%, 198,756 B / 1,048,576 B, total: 19% used)

gcc-arm-cortex-m4-min-ecc

  • FLASH: +5 B (+0.0%, 69,398 B / 262,144 B, total: 26% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .rodata +8 B, .text +640 B (+0.1%, 808,204 B / 1,048,576 B, total: 77% used)

gcc-arm-cortex-m4-pkcs7

  • FLASH: .text +64 B (+0.0%, 225,041 B / 262,144 B, total: 86% used)

gcc-arm-cortex-m4-pq

  • FLASH: .text +64 B (+0.0%, 316,912 B / 1,048,576 B, total: 30% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .text +64 B (+0.0%, 347,432 B / 1,048,576 B, total: 33% used)

gcc-arm-cortex-m4-sp-math

  • FLASH: +5 B (+0.0%, 69,398 B / 262,144 B, total: 26% used)

gcc-arm-cortex-m4-tls12

  • FLASH: +5 B (+0.0%, 134,414 B / 262,144 B, total: 51% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .text +64 B (+0.0%, 253,639 B / 262,144 B, total: 97% used)

gcc-arm-cortex-m7

  • FLASH: .text +64 B (+0.0%, 211,053 B / 262,144 B, total: 81% used)

gcc-arm-cortex-m7-tls13

  • FLASH: .text +64 B (+0.0%, 253,639 B / 262,144 B, total: 97% used)

stm32-sim-stm32h753

  • FLASH: .text +136 B (+0.1%, 209,580 B / 2,097,152 B, total: 10% used)

zephyr-frdm_rw612

  • FLASH: rodata +4 B, text +24 B (+0.0%, 296,076 B / 67,108,864 B, total: 0% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Separately from the inline comments, I checked the one library change: removing out != NULL from the guard on the GCM decrypt auth-fail wipe. It is safe. The argument check at the top of wc_AesGcmDecrypt (aes.c:13095) returns BAD_FUNC_ARG whenever sz != 0 and out == NULL, in every build. out is never reassigned before the wipe, so ForceZero(out, sz) cannot be called with a NULL pointer.

Extended reasoning...

The only library change is the ForceZero guard in wolfcrypt/src/aes.c. The unconditional argument check at the top of wc_AesGcmDecrypt already rejects a NULL out when sz is nonzero, and nothing in between reassigns out.

Findings marked 🟡 are optional suggestions and need no follow-up push.

Comment thread tests/unit-mcdc/test_aes_whitebox.c Resolved
Comment thread tests/api/test_aes.c Resolved
Comment thread tests/api/test_aes.c Resolved
Comment thread tests/api/test_aes.c Resolved
Comment thread tests/unit-mcdc/test_aes_whitebox.c Resolved
Comment thread tests/unit-mcdc/test_aes_whitebox.c Resolved
aes gap 23 -> 7 (all 7 excluded, 0 open; check-closure CLOSED).
Full union 477/484 (98.55%), native 416/470 (88.51%) across 8 native
variants + m33mu lane; aarch64 lane excluded (pre-existing sha3.c build
break + unaligned-allocator test issue).

Closed:
- 15698 stream Final guard x4: test_wc_AesGcmStreamMcdc rewritten around
  the real state model (GcmInit-with-IV sets nonceSet only; SetIV sets
  ctrSet only) with 6 vectors including complete (T,T,T,T) and (T,F,-,-)
  rows; clang-21 pairs a vector only against rows where the unvaried
  operands are evaluated, so the old 5-vector set left idx0/2/3 unpaired.
- 17329 wc_AesGetKeySize claimed-key guard x2: whitebox Class 13 corrupts
  the context (rounds=0, keylen=16) under plain WOLF_CRYPTO_CB.
- 5289/8916/16032/16220/17963:1: whitebox Classes 12/14/15 (counter
  overflow preload, SetIV carry scan with deterministic RNG device,
  CFB loop ret guard) on the m33mu lane.
- 13369 idx2: removed the redundant 'out != NULL' operand from the
  GcmDecrypt auth-fail wipe guard (the entry arg check already rejects
  NULL out); shrinks the decision from 3 to 2 operands.

Excluded (structural, in the campaign exclusion ledger):
- 5991 x2 devOwned constant 0: needs WOLF_CRYPTO_CB_AES_SETKEY, which
  breaks upstream test_wc_CryptoCb_Tls13_Key_Zero_After_Offload (double
  SetKeysSide in SendTls13Finished re-imports the zeroed client_write_key;
  genuine upstream bug, to be fixed separately).
- 8645 x2 CTR drain loop drained unconditionally before the ARM/PPC arm.
- 15372:5 / 15992:5 complementary-operand pairs (ivSz>0, ivFixed!=NULL).
- 17963:0 CFB loop ret guard: the arm wc_AesEncrypt
  (WOLFSSL_ARMASM_NO_HW_CRYPTO) returns 0 unconditionally, so ret is
  provably 0 at every evaluation.

Verification: sweep6 (8 native variants + m33mu) all green;
check-closure.py aes: gap 7 = excluded 7 + open 0, CLOSED;
fips-dev-no-post --enable-all (FIPS v7, AESGCM_STREAM on): aes group
78 tests, 0 failed; check-api-guards.py clean; baselines.json
rebaselined to the native union 416/470 with the part-10 note.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #12176

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-bugs
Not reviewed (no scan target covers them): tests/api/test_aes.h
Coverage: 3 of 3 in-scope changed file(s) opened by the reviewer

Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Max

Comment thread tests/api/test_aes.c Resolved
Comment thread tests/unit-mcdc/test_aes_whitebox.c Resolved

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #12176

Scan targets checked: wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs
Not reviewed (no scan target covers them): tests/api/test_aes.h
Coverage: 1 of 2 in-scope changed file(s) opened by the reviewer; not opened: tests/api/test_aes.c

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed their stale review November 18, 2026 19:44

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

@danielinux danielinux assigned wolfSSL-Bot and unassigned danielinux Nov 19, 2026
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.

4 participants