Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
95cf231
Revert "[nrf noup] bootutil: ed25519_psa: multi verification revocation"
tomchy Nov 6, 2025
4637f80
Revert "[nrf noup] bootutil: Fix ITS key locking compile error"
tomchy Nov 4, 2025
066f15d
Revert "[nrf noup] Handle pending confirm requests"
tomchy Nov 4, 2025
ffa4a65
Revert "[nrf noup] boot: zephyr: remove nonsecure ram cleanup"
tomchy Oct 23, 2025
6a3badd
Revert "[nrf noup] boot: zephyr: Region protection adjustments for nR…
tomchy Oct 23, 2025
9ea0263
Revert "[nrf noup] boards/thingy53_nrf5340_cpuapp: defaulat to LTO"
tomchy Oct 23, 2025
7ba1005
Revert "[nrf noup] boot/zephyr: improve S2RAM resume support using de…
tomchy Oct 23, 2025
adcdc11
Revert "[nrf noup] bootutil: Use correct set of KMU key slots"
tomchy Oct 23, 2025
98a7dc7
Revert "[nrf noup] bootutil/loader: integrate nRF54h S2RAM with diect…
tomchy Oct 23, 2025
760b114
Revert "[nrf noup] mcuboot: Use dedicated type for slot numbers"
tomchy Oct 23, 2025
9cd9e79
Revert "[nrf noup] nrf_cleanup: temporary GRTC cleanup with no counte…
tomchy Oct 23, 2025
7ac4fe5
Revert "[nrf noup] boot: bootutil: Fix b0 checks"
tomchy Oct 23, 2025
97aa207
Revert "[nrf noup] loader: Too many params when calling bootutil_img_…
tomchy Oct 23, 2025
da4e6e1
Revert "[nrf noup] loader: Use BOOT_SLOT_PRIMARY and BOOT_SLOT_SECOND…
tomchy Oct 23, 2025
750c041
Revert "[nrf noup] loader: Use BOOT_SLOT_PRIMARY and BOOT_SLOT_SECOND…
tomchy Oct 23, 2025
a9dc12a
Revert "[nrf noup] loader: Use BOOT_SLOT_PRIMARY and BOOT_SLOT_SECOND…
tomchy Oct 23, 2025
b6e04be
Revert "[nrf noup] loader: Use BOOT_SLOT_PRIMARY and BOOT_SLOT_SECOND…
tomchy Oct 23, 2025
e3d203b
Revert "[nrf noup] loader: Use BOOT_SLOT_PRIMARY and BOOT_SLOT_SECOND…
tomchy Oct 23, 2025
344ac59
Revert "[nrf noup] loader: Use BOOT_SLOT_PRIMARY and BOOT_SLOT_SECOND…
tomchy Oct 23, 2025
7d9e0be
Revert "[nrf noup] loader: Use BOOT_SLOT_PRIMARY and BOOT_SLOT_SECOND…
tomchy Oct 23, 2025
959f460
Revert "[nrf noup] loader: Use BOOT_SLOT_PRIMARY and BOOT_SLOT_SECOND…
tomchy Oct 23, 2025
3426fc7
Revert "[nrf noup] loader: Use BOOT_SLOT_PRIMARY and BOOT_SLOT_SECOND…
tomchy Oct 23, 2025
9e9958a
Revert "[nrf noup] loader: Use BOOT_SLOT_PRIMARY and BOOT_SLOT_SECOND…
tomchy Oct 23, 2025
b7ee0e0
Revert "[nrf noup] bootutil: Remove bootutil_find_key from code"
tomchy Oct 23, 2025
7d50b7c
Revert "[nrf noup] bootutil: Locking KMU keys"
tomchy Oct 23, 2025
e3c3f99
Revert "[nrf noup] bootloader: Fix logging in bootloader requests mod…
tomchy Oct 23, 2025
5cfd1c7
Revert "[nrf noup] boot: Fix test failing with bootloader requests"
tomchy Oct 23, 2025
fa735ff
Revert "[nrf noup] Support for ed25519 signature verification using ITS"
tomchy Oct 23, 2025
6afe632
Revert "[nrf noup] boot: Use NCS_ prefix for sdk-nrf specific Kconfigs"
tomchy Oct 23, 2025
eae1d3f
Revert "[nrf noup] Added BOOT_SIGNATURE_USING_ITS for ecdsa configura…
tomchy Oct 23, 2025
66a342c
Revert "[nrf noup] bootutil: key revocation"
tomchy Oct 23, 2025
f047aad
Revert "[nrf noup] boot: bootutil: Allow configuring number of KMU keys"
tomchy Oct 23, 2025
aefceaf
Revert "[nrf noup] bootutil: Add support for KMU stored ED25519 signa…
tomchy Oct 23, 2025
5c7e864
Revert "[nrf noup] boot: zephyr: Add experimental selection to compre…
tomchy Oct 23, 2025
c629f45
Revert "[nrf noup] decompression: Align to changes in nrfcompress API"
tomchy Oct 23, 2025
7cee68f
Revert "[nrf noup] zephyr: Add support for compressed image updates"
tomchy Oct 23, 2025
e3265fe
Revert "[nrf noup] boot: Improve bootloader request handling"
tomchy Oct 23, 2025
1eb0245
Revert "[nrf noup] bootloader: Add bootloader requests"
tomchy Oct 23, 2025
90f1ccc
Revert "[nrf noup] boot: zephyr: Disable self RWX"
tomchy Oct 23, 2025
d74a7c8
Revert "[nrf noup] boot/zephyr/nrf_cleanup: fix index error"
tomchy Oct 23, 2025
d4dac35
Revert "[nrf noup] boot: Use NCS_ prefix for sdk-nrf specific Kconfigs"
tomchy Oct 23, 2025
fce1fec
Revert "[nrf noup] boot: Add retry for image verification"
tomchy Oct 23, 2025
3ba9203
Revert "[nrf noup] nrf_cleanup: nRF54h: fix missing peripheral cleanup"
tomchy Oct 23, 2025
7a66e56
Revert "[nrf noup] nrf_cleanup: nRF54l: disable cleanup on UARTE pins"
tomchy Oct 23, 2025
d00acf4
Revert "[nrf noup] boot/zephyr/nrf_cleanup: cleanup uarte pins"
tomchy Oct 23, 2025
8bd7a43
Revert "[nrf noup] boot/zephyr: nrf54h20dk cleanup adaptations"
tomchy Oct 23, 2025
ea9dbc0
Revert "[nrf noup] partition_manager: Add support for internal flash …
tomchy Oct 23, 2025
5b3a161
Revert "[nrf noup] boot: zephyr: boards: Disabled NCS boot banner for…
tomchy Oct 23, 2025
fadada8
Revert "[nrf noup] sysflash: Add missing _FLASH_0_ID definitions"
tomchy Oct 23, 2025
96751a2
Revert "[nrf noup] boot: Remove child/parent references"
tomchy Oct 23, 2025
77919fb
Revert "[nrf noup] boot: bootutil: loader: Add s0/s1 checking of MCUb…
tomchy Oct 23, 2025
8ac241e
Revert "[nrf noup] treewide: Add support for sysbuild assigned images"
tomchy Oct 23, 2025
7337f2f
Revert "[nrf noup] boot: zephyr: Do not lock PCD region with TF-M"
tomchy Oct 23, 2025
5df29e6
Revert "[nrf noup] bootutil: loader: Fix netcore address checking"
tomchy Oct 23, 2025
b2d3d7a
Revert "[nrf noup] boot/../loader: reboot after updating s0/s1"
tomchy Oct 23, 2025
63e5ade
Revert "[nrf noup] boot/../loader: skip downgrade prevention for s1/s0"
tomchy Oct 23, 2025
082353e
Revert "[nrf noup] boot/zephyr: fix fw_info search"
tomchy Oct 23, 2025
d14a308
Revert "[nrf noup] loader: remove cleanup for direct xip mode"
tomchy Oct 23, 2025
8b341a9
Revert "[nrf noup] loader: introduced cleanup of unusable secondary s…
tomchy Oct 23, 2025
5912f0c
Revert "[nrf noup] sysflash: Add support for three images"
tomchy Oct 23, 2025
efe48dc
Revert "[nrf noup] sysflash: Move partition manager definitions to pm…
tomchy Oct 23, 2025
a985b24
Revert "[nrf noup] boot: Add support for NSIB and multi-image"
tomchy Oct 23, 2025
3d3908f
Revert "[nrf noup] loader: Fix missing PCD define check"
tomchy Oct 23, 2025
65e4e60
Revert "[nrf noup] boards: thingy53: disable GPIO ISR support"
tomchy Oct 23, 2025
f21f984
Revert "[nrf noup] loader: Add firmware version check downgrade preve…
tomchy Oct 23, 2025
bcc53a1
Revert "[nrf noup] zephyr: Boot even if EXT_ABI is not provided"
tomchy Oct 23, 2025
758c8c9
Revert "[nrf noup] zephyr: Add RAM flash configuration to cache for s…
tomchy Oct 23, 2025
08131d6
Revert "[nrf noup] loader: Do not check reset vector for XIP image"
tomchy Oct 23, 2025
96401df
Revert "[nrf noup] loader: Fix reading reset addr to support ext flash"
tomchy Oct 23, 2025
84da9dc
Revert "[nrf noup] zephyr: Clean up non-secure RAM if enabled"
tomchy Oct 23, 2025
62d6ffb
Revert "[nrf noup] zephyr: clean peripherals state before boot"
tomchy Oct 23, 2025
22a3b04
Revert "[nrf noup] boot: nrf53-specific customizations"
tomchy Oct 23, 2025
5e225c4
Revert "[nrf noup] treewide: add NCS partition manager support"
tomchy Oct 23, 2025
676fea8
[nrf fromtree] bootutil: Add MCUBOOT_CHECK_HEADER_LOAD_ADDRESS
de-nordic Oct 7, 2025
f5c9d09
[nrf fromtree] zephyr: Added MCUBOOT_CHECK_HEADER_LOAD_ADDRESS Kconfig
de-nordic Oct 7, 2025
c3848d4
[nrf fromtree] sim: Parametrize make_bad_secondary_slot_image
de-nordic Oct 8, 2025
f163442
[nrf fromtree] sim: Add test for MCUBOOT_CHECK_HEADER_LOAD_ADDRESS
de-nordic Oct 8, 2025
20f981e
[nrf fromtree] zephyr: Deprecate MCUBOOT_VERIFY_IMG_ADDRESS
de-nordic Oct 8, 2025
06383a0
[nrf fromtree] bootutil: Move boot_enc_init in boot_swap_image
de-nordic Oct 9, 2025
e571827
[nrf fromtree] bootutil: Replace literal slot indexes with identifiers
de-nordic Oct 14, 2025
663cd87
[nrf fromtree] bootutil: Replace boot_write_enc_key with boot_write_e…
de-nordic Oct 14, 2025
88c7a77
[nrf fromtree] boot: bootutil: swap_offset: Fix not including unprote…
nordicjm Oct 15, 2025
7571f8c
[nrf fromtree] docs: design: Add update on swap using offset
nordicjm Oct 15, 2025
2439b0a
[nrf fromtree] bootutil: Drop slot number and boot_state from most bo…
de-nordic Oct 17, 2025
6b2fd50
[nrf fromtree] boot: bootutil: fix image_index definition
stgloorious Oct 2, 2025
157bac2
[nrf fromtree] loader: Fix compile-time issues in loader.c
tomchy Oct 22, 2025
fb94c2f
[nrf fromtree] loader: Rename boot_version_cmp
tomchy Oct 21, 2025
1db194b
[nrf fromtree] loader: Optimize boot_check_header_erased(..)
tomchy Oct 21, 2025
e3a2d66
[nrf fromtree] loader: Unify header_valid(..) API
tomchy Oct 21, 2025
bea9d0a
[nrf fromtree] loader: Unify image check API.
tomchy Oct 21, 2025
6cb0be4
[nrf fromtree] bootutil: Add missing docs
tomchy Oct 21, 2025
568a35d
[nrf fromtree] bootutil: Move state-independent area APIs
tomchy Oct 21, 2025
37f00fa
[nrf fromtree] loader: Move boot_get_max_app_size(..) API
tomchy Oct 21, 2025
591da85
[nrf fromtree] bootutil: Move update-independent code
tomchy Oct 21, 2025
46f2d5c
[nrf fromlist] boot: Add MCUboot manifest TLV
tomchy Oct 9, 2025
672f30a
[nrf fromlist] imgtool: Add a possibility to attach manifest TLV
tomchy Oct 9, 2025
7ea3a09
[nrf fromlist] bootutil: Add manifest-based loader for Direct XIP
tomchy Oct 15, 2025
e9eada7
[nrf fromlist] doc: Add manifest conceptual description
tomchy Nov 4, 2025
0b380d8
[nrf noup] treewide: add NCS partition manager support
SebastianBoe Dec 12, 2018
c7e51f6
[nrf noup] boot: nrf53-specific customizations
sigvartmh Aug 27, 2020
1799f15
[nrf noup] zephyr: clean peripherals state before boot
nvlsianpu Feb 27, 2020
43fe5e7
[nrf noup] zephyr: Clean up non-secure RAM if enabled
sigvartmh Jan 6, 2023
61be32f
[nrf noup] loader: Fix reading reset addr to support ext flash
chrta Feb 10, 2022
2b78d90
[nrf noup] loader: Do not check reset vector for XIP image
de-nordic Sep 22, 2023
0f3b981
[nrf noup] zephyr: Add RAM flash configuration to cache for sysbuild
nordicjm Sep 18, 2023
9dcb162
[nrf noup] zephyr: Boot even if EXT_ABI is not provided
sigvartmh Oct 17, 2023
25ae80d
[nrf noup] loader: Add firmware version check downgrade prevention
sigvartmh Sep 27, 2023
99c2c4c
[nrf noup] boards: thingy53: disable GPIO ISR support
nika-nordic Oct 9, 2023
8b0df15
[nrf noup] loader: Fix missing PCD define check
nordicjm Aug 31, 2023
c6ebd73
[nrf noup] boot: Add support for NSIB and multi-image
sigvartmh May 31, 2023
fffd071
[nrf noup] sysflash: Move partition manager definitions to pm_sysflash.h
de-nordic Aug 10, 2023
d48508c
[nrf noup] sysflash: Add support for three images
de-nordic Aug 11, 2023
a074d6f
[nrf noup] loader: introduced cleanup of unusable secondary slot
nvlsianpu Feb 15, 2024
264c371
[nrf noup] loader: remove cleanup for direct xip mode
gchwier May 17, 2024
5f4682d
[nrf noup] boot/zephyr: fix fw_info search
nvlsianpu May 27, 2024
304f4fb
[nrf noup] boot/../loader: skip downgrade prevention for s1/s0
nvlsianpu Jun 13, 2024
18b8778
[nrf noup] boot/../loader: reboot after updating s0/s1
nvlsianpu Jun 18, 2024
8d6462a
[nrf noup] bootutil: loader: Fix netcore address checking
nordicjm Aug 29, 2024
d83b270
[nrf noup] boot: zephyr: Do not lock PCD region with TF-M
MarkusLassila Aug 30, 2024
5c06e3d
[nrf noup] treewide: Add support for sysbuild assigned images
nordicjm Sep 10, 2024
8e86689
[nrf noup] boot: bootutil: loader: Add s0/s1 checking of MCUboot image
nordicjm Oct 15, 2024
ee17caa
[nrf noup] boot: Remove child/parent references
nordicjm Dec 5, 2024
3471d3e
[nrf noup] sysflash: Add missing _FLASH_0_ID definitions
de-nordic Jan 15, 2025
46d3758
[nrf noup] boot: zephyr: boards: Disabled NCS boot banner for thingy 53
kkasperczyk-no Jan 24, 2025
7e6db20
[nrf noup] partition_manager: Add support for internal flash netcore DFU
hellesvik-nordic Feb 6, 2025
9448d4b
[nrf noup] boot/zephyr: nrf54h20dk cleanup adaptations
nordic-mik7 Mar 28, 2025
a9a32d2
[nrf noup] boot/zephyr/nrf_cleanup: cleanup uarte pins
nvlsianpu Mar 5, 2024
e45283b
[nrf noup] nrf_cleanup: nRF54l: disable cleanup on UARTE pins
nvlsianpu Apr 11, 2025
2059cdf
[nrf noup] nrf_cleanup: nRF54h: fix missing peripheral cleanup
ahasztag Apr 28, 2025
217e9b0
[nrf noup] boot: Add retry for image verification
adsz-nordic Jul 8, 2025
bd8a6ab
[nrf noup] boot: zephyr: Disable self RWX
michalek-no Aug 5, 2025
2575520
[nrf noup] bootloader: Add bootloader requests
tomchy Jul 28, 2025
ff0d213
[nrf noup] zephyr: Add support for compressed image updates
nordicjm Aug 22, 2024
496e9f4
[nrf noup] decompression: Align to changes in nrfcompress API
nordic-mik7 May 13, 2025
df60648
[nrf noup] boot: zephyr: Add experimental selection to compression
nordicjm Nov 7, 2024
f7f87cd
[nrf noup] bootutil: Add support for KMU stored ED25519 signature key
de-nordic Sep 20, 2024
15cc89a
[nrf noup] boot: bootutil: Allow configuring number of KMU keys
nordicjm Dec 2, 2024
3a044cf
[nrf noup] bootutil: key revocation
michalek-no Mar 17, 2025
55a4637
[nrf noup] Added BOOT_SIGNATURE_USING_ITS for ecdsa configuration
ahasztag Jul 24, 2025
5f54788
[nrf noup] Support for ed25519 signature verification using ITS
nordic-mik7 Aug 22, 2025
5960e00
[nrf noup] bootutil: Locking KMU keys
de-nordic Jul 3, 2025
d2d0527
[nrf noup] bootutil/loader: integrate nRF54h S2RAM with diect-xip
nvlsianpu Sep 30, 2025
d8e5582
[nrf noup] bootutil: Use correct set of KMU key slots
nordicjm Sep 12, 2025
c9a0ff8
[nrf noup] boot/zephyr: improve S2RAM resume support using dedicated API
nvlsianpu Sep 18, 2025
5f8a387
[nrf noup] boards/thingy53_nrf5340_cpuapp: defaulat to LTO
nvlsianpu Oct 13, 2025
148d7d5
[nrf noup] Handle pending confirm requests
tomchy Oct 27, 2025
14de127
[nrf noup] bootutil: Fix ITS key locking compile error
ahasztag Oct 31, 2025
317fabe
[nrf noup] Add routines for application
tomchy Nov 4, 2025
49908e8
[nrf noup] bootutil: ed25519_psa: multi verification revocation
michalek-no Nov 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions boot/boot_serial/src/boot_serial_encryption.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ boot_image_validate_encrypted(struct boot_loader_state *state,
int rc;

if (MUST_DECRYPT(fa_p, BOOT_CURR_IMG(state), hdr)) {
rc = boot_enc_load(state, 1, hdr, fa_p, bs);
rc = boot_enc_load(state, BOOT_SLOT_SECONDARY, hdr, fa_p, bs);
if (rc < 0) {
FIH_RET(fih_rc);
}
rc = boot_enc_set_key(BOOT_CURR_ENC(state), 1, bs);
rc = boot_enc_set_key(BOOT_CURR_ENC_SLOT(state, BOOT_SLOT_SECONDARY), bs->enckey[BOOT_SLOT_SECONDARY]);
if (rc < 0) {
FIH_RET(fih_rc);
}
Expand Down Expand Up @@ -169,7 +169,7 @@ decrypt_region_inplace(struct boot_loader_state *state,
blk_sz = tlv_off - (off + bytes_copied);
}
}
boot_enc_decrypt(BOOT_CURR_ENC(state), slot,
boot_enc_decrypt(BOOT_CURR_ENC_SLOT(state, slot),
(off + bytes_copied + idx) - hdr->ih_hdr_size, blk_sz,
blk_off, &buf[idx]);
}
Expand Down Expand Up @@ -235,11 +235,11 @@ decrypt_image_inplace(const struct flash_area *fa_p,
#endif
memset(&boot_data, 0, sizeof(struct boot_loader_state));
/* Load the encryption keys into cache */
rc = boot_enc_load(state, 0, hdr, fa_p, bs);
rc = boot_enc_load(state, BOOT_SLOT_PRIMARY, hdr, fa_p, bs);
if (rc < 0) {
FIH_RET(fih_rc);
}
if (rc == 0 && boot_enc_set_key(BOOT_CURR_ENC(state), 0, bs)) {
if (rc == 0 && boot_enc_set_key(BOOT_CURR_ENC_SLOT(state, BOOT_SLOT_PRIMARY), bs->enckey[BOOT_SLOT_PRIMARY])) {
FIH_RET(fih_rc);
}
}
Expand Down
3 changes: 3 additions & 0 deletions boot/bootutil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ target_sources(bootutil
src/bootutil_img_hash.c
src/bootutil_img_security_cnt.c
src/bootutil_misc.c
src/bootutil_area.c
src/bootutil_loader.c
src/bootutil_public.c
src/caps.c
src/encrypted.c
Expand All @@ -31,6 +33,7 @@ target_sources(bootutil
src/image_rsa.c
src/image_validate.c
src/loader.c
src/loader_manifest_xip.c
src/swap_misc.c
src/swap_move.c
src/swap_scratch.c
Expand Down
27 changes: 27 additions & 0 deletions boot/bootutil/include/bootutil/bootutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,36 @@ fih_ret boot_go_for_image_id(struct boot_rsp *rsp, uint32_t image_id);

void boot_state_clear(struct boot_loader_state *state);
fih_ret context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp);

/**
* Returns a pointer to the boot loader state structure.
*
* @return Pointer to the boot loader state structure.
*/
struct boot_loader_state *boot_get_loader_state(void);

#if defined(MCUBOOT_SERIAL_IMG_GRP_SLOT_INFO) || defined(MCUBOOT_DATA_SHARING)
/**
* Returns pointer to array of image maximum sizes.
*
* @note This function provides a RAW access to the structure. The sizes may not be
* calculated yet. Use boot_get_max_app_size() to ensure the sizes are calculated.
*
* @return Pointer to array of image maximum sizes.
*/
struct image_max_size *boot_get_image_max_sizes(void);

/**
* Fetches the maximum allowed size of all application images.
*
* @note In contrast to boot_get_image_max_sizes(), this function will fetch the sizes
* if they are not yet calculated.
*
* @return A pointer to the structure containing the maximum sizes of images.
*/
const struct image_max_size *boot_get_max_app_size(void);
#endif /* MCUBOOT_SERIAL_IMG_GRP_SLOT_INFO || MCUBOOT_DATA_SHARING */

void boot_fetch_slot_state_sizes(void);
uint32_t boot_get_state_secondary_offset(struct boot_loader_state *state,
const struct flash_area *fap);
Expand Down
14 changes: 7 additions & 7 deletions boot/bootutil/include/bootutil/enc_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ struct boot_loader_state;
/* Decrypt random, symmetric encryption key */
int boot_decrypt_key(const uint8_t *buf, uint8_t *enckey);

int boot_enc_init(struct enc_key_data *enc_state, uint8_t slot);
int boot_enc_drop(struct enc_key_data *enc_state, uint8_t slot);
int boot_enc_set_key(struct enc_key_data *enc_state, uint8_t slot,
const struct boot_status *bs);
int boot_enc_init(struct enc_key_data *enc_state);
int boot_enc_drop(struct enc_key_data *enc_state);
int boot_enc_set_key(struct enc_key_data *enc_state, const uint8_t *key);
int boot_enc_load(struct boot_loader_state *state, int slot,
const struct image_header *hdr, const struct flash_area *fap,
struct boot_status *bs);
bool boot_enc_valid(struct enc_key_data *enc_state, int slot);
void boot_enc_encrypt(struct enc_key_data *enc_state, int slot,
bool boot_enc_valid(const struct enc_key_data *enc_state);
void boot_enc_encrypt(struct enc_key_data *enc_state,
uint32_t off, uint32_t sz, uint32_t blk_off, uint8_t *buf);
void boot_enc_decrypt(struct enc_key_data *enc_state, int slot,
void boot_enc_decrypt(struct enc_key_data *enc_state,
uint32_t off, uint32_t sz, uint32_t blk_off, uint8_t *buf);
/* Note that boot_enc_zeorize takes BOOT_CURR_ENC, not BOOT_CURR_ENC_SLOT */
void boot_enc_zeroize(struct enc_key_data *enc_state);

#ifdef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions boot/bootutil/include/bootutil/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ extern "C" {
#define IMAGE_TLV_COMP_DEC_SIZE 0x73 /* Compressed decrypted image size */
#define IMAGE_TLV_UUID_VID 0x74 /* Vendor unique identifier */
#define IMAGE_TLV_UUID_CID 0x75 /* Device class unique identifier */
#define IMAGE_TLV_MANIFEST 0x76 /* Transaction manifest */
/*
* vendor reserved TLVs at xxA0-xxFF,
* where xx denotes the upper byte
Expand Down
121 changes: 121 additions & 0 deletions boot/bootutil/include/bootutil/mcuboot_manifest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef __MCUBOOT_MANIFEST_H__
#define __MCUBOOT_MANIFEST_H__

/**
* @file mcuboot_manifest.h
*
* @note This file is only used when MCUBOOT_MANIFEST_UPDATES is enabled.
*/

#include <stdint.h>
#include "bootutil/bootutil.h"
#ifdef CONFIG_MCUBOOT
#include "bootutil/crypto/sha.h"
#elif defined(CONFIG_MCUBOOT_BOOTLOADER_USES_SHA512)
#define IMAGE_HASH_SIZE (64)
#else
#define IMAGE_HASH_SIZE (32)
#endif

#ifndef MCUBOOT_MANIFEST_IMAGE_NUMBER
#ifdef CONFIG_NCS_MCUBOOT_MANIFEST_IMAGE_NUMBER
#define MCUBOOT_MANIFEST_IMAGE_NUMBER CONFIG_NCS_MCUBOOT_MANIFEST_IMAGE_NUMBER
#else
#error "MCUBOOT_MANIFEST_IMAGE_NUMBER must be defined when MCUBOOT_MANIFEST_UPDATES is enabled"
#endif
#endif

#ifndef MCUBOOT_IMAGE_NUMBER
#ifdef CONFIG_UPDATEABLE_IMAGE_NUMBER
#define MCUBOOT_IMAGE_NUMBER CONFIG_UPDATEABLE_IMAGE_NUMBER
#else
#error "MCUBOOT_IMAGE_NUMBER must be defined when MCUBOOT_MANIFEST_UPDATES is enabled"
#endif
#endif

#ifndef __packed
#define __packed __attribute__((__packed__))
#endif

#ifdef __cplusplus
extern "C" {
#endif

/** Manifest structure for image updates. */
struct mcuboot_manifest {
uint32_t format;
uint32_t image_count;
/* Skip a digest of the MCUBOOT_MANIFEST_IMAGE_NUMBER image. */
uint8_t image_hash[MCUBOOT_IMAGE_NUMBER - 1][IMAGE_HASH_SIZE];
} __packed;

/**
* @brief Check if the specified manifest has the correct format.
*
* @param[in] manifest The reference to the manifest structure.
*
* @return true on success.
*/
static inline bool bootutil_verify_manifest(const struct mcuboot_manifest *manifest)
{
if (manifest == NULL) {
return false;
}

/* Currently only the simplest manifest format is supported */
if (manifest->format != 0x1) {
return false;
}

if (manifest->image_count != MCUBOOT_IMAGE_NUMBER - 1) {
return false;
}

return true;
}

/**
* @brief Get the image hash from the manifest.
*
* @param[in] manifest The reference to the manifest structure.
* @param[in] image_index The index of the image to get the hash for.
* Must be in range <0, MCUBOOT_IMAGE_NUMBER - 1>, but
* must not be equal to MCUBOOT_MANIFEST_IMAGE_NUMBER.
*
* @return true if hash matches with the manifest, false otherwise.
*/
static inline bool bootutil_verify_manifest_image_hash(const struct mcuboot_manifest *manifest,
const uint8_t *exp_hash, uint32_t image_index)
{
if (!bootutil_verify_manifest(manifest)) {
return false;
}

if (image_index >= MCUBOOT_IMAGE_NUMBER) {
return false;
}

if (image_index < MCUBOOT_MANIFEST_IMAGE_NUMBER) {
if (memcmp(exp_hash, manifest->image_hash[image_index], IMAGE_HASH_SIZE) == 0) {
return true;
}
} else if (image_index > MCUBOOT_MANIFEST_IMAGE_NUMBER) {
if (memcmp(exp_hash, manifest->image_hash[image_index - 1], IMAGE_HASH_SIZE) == 0) {
return true;
}
}

return false;
}

#ifdef __cplusplus
}
#endif

#endif /* __MCUBOOT_MANIFEST_H__ */
Loading
Loading