Skip to content

Conversation

nordicjm
Copy link
Contributor

@nordicjm nordicjm commented Sep 2, 2025

Adds support for images signed with SHA512.

de-nordic
de-nordic previously approved these changes Sep 2, 2025
@kartben kartben requested a review from Copilot September 2, 2025 16:00
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for SHA512 hash verification in the MCUmgr image management subsystem. The change enables the system to handle images signed with SHA512 instead of being limited to SHA256.

  • Introduces conditional compilation to support both SHA256 and SHA512 based on MCUboot configuration
  • Updates hash buffer sizes and TLV type checks throughout the image management code
  • Increases main stack size to accommodate larger hash processing requirements

Reviewed Changes

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

File Description
img_mgmt_priv.h Adds conditional macros for SHA algorithm selection and hash length based on MCUboot configuration
img_mgmt_state.c Updates hash buffer declarations and length checks to use new SHA-agnostic macros
img_mgmt.c Replaces hardcoded SHA256 references with configurable SHA macros in hash processing functions
prj.conf Increases main stack size to handle additional memory requirements for SHA512 processing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

uint8_t hash[IMAGE_HASH_LEN]; /* SHA256 hash */
struct zcbor_string zhash = { .value = hash, .len = IMAGE_HASH_LEN };
uint8_t hash[IMAGE_SHA_LEN];
struct zcbor_string zhash = { .value = hash, .len = IMAGE_SHA_LEN};
Copy link
Preview

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

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

[nitpick] Missing space before the closing brace. Should be IMAGE_SHA_LEN }; for consistency with coding style.

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Adds support for images signed with SHA512.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Increase stack size as support for SHA512 requires more data.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Copy link

sonarqubecloud bot commented Sep 3, 2025

@henrikbrixandersen henrikbrixandersen merged commit 81413f0 into zephyrproject-rtos:main Sep 4, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants