Repository navigation
Fix/update disk aes ctr iv carry - #1020
Open
night1rider wants to merge 2 commits into
Open
night1rider wants to merge 2 commits into
night1rider wants to merge 2 commits into
Conversation
Reproduce the 32-bit IV carry drop in disk_crypto_set_iv() with real AES-256-CTR and wire the test into tools/unit-tests/Makefile.
Propagate carry branch-free across all 16 bytes of the big-endian AES-CTR IV in disk_crypto_set_iv(), matching aes_set_iv().
night1rider
requested review from
wolfSSL-Fenrir-bot
and
a balanced review from Copilot
December 2, 2026 19:07
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the AES-CTR counter carry fix.
No open issues 🎉
What changed in this PR
Fixes disk-boot AES-CTR counter handling so payload decryption matches the signing tool when the IV’s low 32-bit word overflows.
Changes:
- Propagates carry across the full 128-bit counter.
- Adds AES-256-CTR regression tests for normal counters, multiword carry, and full wraparound.
- Registers the test target and ignores its generated binary.
| File | Description |
|---|---|
tools/unit-tests/unit-update-disk-aes-iv-carry.c |
Adds real AES-CTR carry regression tests. |
tools/unit-tests/Makefile |
Registers and builds the new test. |
src/update_disk.c |
Implements full 128-bit IV carry propagation. |
.gitignore |
Ignores the new test binary. |
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1020
Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .gitignore, tools/unit-tests/Makefile
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer
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: Max
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found this when reviewing #1015
disk_crypto_set_iv()insrc/update_disk.cpreviously addedblock_offsetonly to the last 4 bytes (iv[12..15]) of the 16-byte AES-CTR IV without carrying intoiv[0..11].Because
tools/keytools/sign.c(wc_AesCtrEncrypt()) andsrc/libwolfboot.c(aes_set_iv()) increment the full 128-bit big-endian counter, any IV whose low 32-bit word wraps across the header decrypts the payload with the wrong counter and fails verification.Commit 1 (
71568105) addsunit-update-disk-aes-iv-carry(wired intotools/unit-tests/Makefileand.github/workflows/test-units.yml) reproducing the failure with real AES-256-CTR (fails 3/4 before the fix).Commit 2 (
1d811020) propagates the carry branch-free across all four 32-bit big-endian words of the IV indisk_crypto_set_iv()(4/4 passing, along with all existingunit-update-disk*suites).How to run the test