Skip to content

Check disk decryption return codes and wipe the cipher state before boot - #1025

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:disk_aes_checks
Open

dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:disk_aes_checks

Conversation

@dgarske

@dgarske dgarske commented Dec 3, 2026

Copy link
Copy Markdown
Member

Description

  • disk_crypto_set_iv() returns the cipher error, and a failed IV set or decrypt of a header or payload fails that slot and falls over to the other instead of going on to verification.
  • aes_init() fails on a wc_AesInit or wc_AesSetKeyDirect error.
  • The ChaCha or AES context, which holds the expanded key, is wiped before handoff along with the key and nonce.

Testing

  • unit-update-disk covers an IV failure and a decrypt failure on one slot (falls over) and on both (fails closed), and checks the cipher context is zero at boot.

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.

🟡 Changes recommended

The context-wiping assertion cannot detect a missing wipe because the mocked cipher context stays zeroed; seed it with nonzero data before boot.

1 open issue
What changed in this PR

Hardens wolfBoot’s encrypted disk boot path by checking cipher errors and clearing sensitive state before handoff.

Changes:

  • Checks AES initialization and disk decryption results.
  • Rejects slots on cipher errors and wipes cipher contexts before boot.
  • Adds failure-injection tests and a context-zeroization assertion.
File Description
tools/​unit-tests/​unit-update-disk.c Adds cipher-error and cleanup checks.
src/​update_disk.c Handles decryption failures and clears cipher state.
src/​libwolfboot.c Checks AES initialization and key-setup errors.

Review effort: Balanced

Comment thread tools/unit-tests/unit-update-disk.c Resolved
@dgarske
dgarske requested review from danielinux and rizlik and a balanced review from Copilot December 3, 2026 22:23
@dgarske dgarske assigned wolfSSL-Bot and unassigned dgarske Dec 3, 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.

🟡 Changes recommended

The AES initialization error path can retain sensitive key material, and header-decryption failure handling lacks tests for slot fallback and rejection.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread src/libwolfboot.c Resolved
Comment thread src/update_disk.c Resolved

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.

🔵 Needs a closer look

Missing AES backend sources and ChaCha-only disk mocks leave wc_AesFree safety after partial initialization, repeated golden-slot rekeying on hardware backends, and pre-handoff teardown requiring human validation.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

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