Skip to content

Kick out the ROM api and use the HAL ROM api - #47

Open
diondokter wants to merge 4 commits into
OpenDevicePartnership:mcxa-secure-bootfrom
diondokter:mcxa-rom
Open

Kick out the ROM api and use the HAL ROM api#47
diondokter wants to merge 4 commits into
OpenDevicePartnership:mcxa-secure-bootfrom
diondokter:mcxa-rom

Conversation

@diondokter

Copy link
Copy Markdown
Member

@diondokter
diondokter marked this pull request as ready for review September 7, 2026 12:39
@diondokter
diondokter requested a review from a team as a code owner September 7, 2026 12:39
@diondokter

Copy link
Copy Markdown
Member Author

Not super pretty. /libs is a workspace, but we're doing things there a workspace is not good at. Might pull that apart in a later PR.
Also cleaned up some of the feature flags and dependencies. But that will need another pass too later

@diondokter diondokter mentioned this pull request Sep 8, 2026
// Start as unused by default for safety; will be updated with real values from CMPA if read is successful.
soc_root_key_usage: [NbootRootKeyUsage::Unused; 4],
soc_root_key_type_and_length: NbootRootKeyType::EcdsaP384Mldsa87, //FIXED TO THIS because we are CNSA 2.0 compliant.
soc_lifecycle: 0,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LC as 0 is not a valid state, I know we are setting a default "unknown" here, but I still think we should use a strict starting point for proper diagnosis from the ROM API authenticate call (i.e. auth. fail vs invalid input).


if let Some(cmpa_rotkh) = load_rotkh_from_cmpa() {
parms.soc_RoTNVM.soc_rkh = cmpa_rotkh;
parms.soc_ro_tnvm.soc_rkh = cmpa_rotkh;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All of the ro_tnvm should be rot_nvm

Root of Trust _ NVM.

parms.soc_ro_tnvm.soc_rkh.copy_from_slice(&image_rkth_words);
} else {
verify_warn!("Production: image RKTH differs; not copying, will not call verify ");
n_boot_api.nboot_context_deinit(&mut ctx);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is more of a question, as soon as we return BootError, Nboot Drop implementation deinits the NBOOT APIs, right?


verify_trace!("begin auth");
let status = n_boot_api.nboot_img_authenticate_romapi(&mut ctx, image_base, &mut sig_ok, &mut parms);
let status = n_boot_api

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would leave this comment in embassy HAL for the ROM API PR 6910 but it's closed:

Rom API success return is actually a 32-bit Hamming pattern. I think we need to retain that comparison for the success case. NXP does provide a full 32-bit value for glitch hardening, and we should take advantage (unless there are Rust specifics at play that I'm not aware of).

All other APIs do a return a simple 0 (Ok()) for success, NBOOT is the exception.


verify_error!("Auth failed with status {:?}: {:?}", status, boot_error);
Err(boot_error)
Ok(true)

@alamfarjadf alamfarjadf Sep 8, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since we have done a considerable amount of work up until this point to harden against glitching, are we losing all of that by returning a bool here, instead of returning a Hamming bit pattern like NbootBoolTrue that is 32 bits wide?

This would mean despite all the glitch resistance up until now, a single bit flip causes a jump to unauthenticated image.

@@ -1,18 +1,19 @@
#![allow(clippy::not_unsafe_ptr_arg_deref)]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This whole file should have rot_nvm instead of ro_tnvm.

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.

3 participants