image: check integrity in wolfBoot_verify_authenticity()#808
Open
rizlik wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a hybrid-signature verification failure caused by the global digest buffer being clobbered during secondary key lookup, by ensuring integrity verification is performed (and img->sha_hash is set to the stored header SHA) before authenticity checks proceed.
Changes:
- Update
wolfBoot_verify_authenticity()to invokewolfBoot_verify_integrity()when the image SHA hasn’t been verified (sha_hash == NULLorsha_ok != 1). - Extend unit tests to cover the hybrid-signature direct-call scenario and to open images via
wolfBoot_open_image()where needed. - Add a dedicated
unit-image-hybridunit-test target to exercise hybrid verification paths with a larger header size.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/image.c |
Ensures integrity verification is performed before authenticity verification when SHA state is missing/invalid, preventing hybrid verification from using a clobbered digest buffer. |
tools/unit-tests/unit-image.c |
Adds helpers and a hybrid-specific unit test that asserts the verified SHA is used consistently across hybrid verification steps. |
tools/unit-tests/Makefile |
Introduces unit-image-hybrid target and includes it in the unit-test run set. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8f0b38b to
ab80578
Compare
mattia-moffa
approved these changes
Jun 25, 2026
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.
invoking
wolfBoot_verify_authenticity()without invokingwolfBoot_verify_integrity()led to the following scenario in hybrid signatures:keyslot_id_by_shaclobber the global digest when getting the secondary keyNow
wolfBoot_verify_authenticity()invokeswolfBoot_verify_integrity()ifimg->sha_hashis NULL or ifimg->sha_ok != 1.After
wolfBoot_verify_integrity()img->sha_hashpoints to the in-header stored SHA instead of the globals.BREAKING CHANGE:
Now image that do not pass integrity can't be verified.
Now image that do not include the hash inside the header can't be authenticated.