Skip to content

reverse RKTH order as boot ROM expects it. - #58

Merged
JamesHuard merged 2 commits into
OpenDevicePartnership:mcxa-secure-bootfrom
alamfarjadf:fix-cmpa-rotkh-order
Oct 23, 2026
Merged

JamesHuard merged 2 commits into
OpenDevicePartnership:mcxa-secure-bootfrom
alamfarjadf:fix-cmpa-rotkh-order

Conversation

@alamfarjadf

Copy link
Copy Markdown

With the degrade / degrade_original the RKTH order is reversed from how ROM wants it on boot.

Dev mode or ROM API call always works because the read/write is in correct order, but for boot SB verify, the order needs to be the original BE order; without it ROM won't authenticate the SBL.

JamesHuard
JamesHuard previously approved these changes Oct 22, 2026

@JamesHuard JamesHuard 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.

Confusing to me that we were reversing byte ordering here in the first place

@JamesHuard
JamesHuard enabled auto-merge (squash) October 22, 2026 15:07
@jerrysxie
jerrysxie requested review from felipebalbi and a balanced review from Copilot October 22, 2026 15:36
@jerrysxie jerrysxie added this to EC Oct 22, 2026
@jerrysxie jerrysxie moved this to In Progress in EC Oct 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The persistent trust-anchor ordering change needs target-device validation of secure cold boot and ROM API authentication.

No open issues 🎉

What changed in this PR

This PR removes root-key hash array reversal to align provisioning data with the order expected by the boot ROM for secure boot authentication.

Changes:

  • Store classical and post-quantum root-key hashes as plain arrays in CMPA.
  • Update provisioning assignments and hash comparisons to use those arrays directly.
  • Pass stored hashes directly to ROM image-authentication parameters.
File Description
libs/​mcxa-security-provisioning/​src/​lib.rs Removes reversal wrappers from hash assignment and comparison.
libs/​mcxa-ifr/​src/​lib.rs Changes both CMPA hash fields and defaults to plain arrays.
libs/​ec-slimloader-mcxa/​src/​verification.rs Uses stored hash arrays directly for ROM authentication.

Review effort: Balanced

@alamfarjadf

Copy link
Copy Markdown
Author

🔵 Needs a closer look

The persistent trust-anchor ordering change needs target-device validation of secure cold boot and ROM API authentication.

No open issues 🎉

What changed in this PR
This PR removes root-key hash array reversal to align provisioning data with the order expected by the boot ROM for secure boot authentication.

Changes:

  • Store classical and post-quantum root-key hashes as plain arrays in CMPA.
  • Update provisioning assignments and hash comparisons to use those arrays directly.
  • Pass stored hashes directly to ROM image-authentication parameters.

File Description
libs/​mcxa-security-provisioning/​src/​lib.rs Removes reversal wrappers from hash assignment and comparison.
libs/​mcxa-ifr/​src/​lib.rs Changes both CMPA hash fields and defaults to plain arrays.
libs/​ec-slimloader-mcxa/​src/​verification.rs Uses stored hash arrays directly for ROM authentication.
Review effort: Balanced

Validated on EVK.

@felipebalbi

Copy link
Copy Markdown
Contributor

Confusing to me that we were reversing byte ordering here in the first place

#49 (comment)

@felipebalbi felipebalbi 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.

This is the implementation of what I had already commented on PR #49. I would really like to see some unit tests pinning the behavior to prevent re-litigation in the future.

Some tests can be added to this PR while further testing would require some refactoring.

Can you add some basic tests before we merge this? Maybe a "golden vector" type test?

auto-merge was automatically disabled October 22, 2026 17:15

Head branch was pushed to by a user without write access

@alamfarjadf

Copy link
Copy Markdown
Author

This is the implementation of what I had already commented on PR #49. I would really like to see some unit tests pinning the behavior to prevent re-litigation in the future.

Some tests can be added to this PR while further testing would require some refactoring.

Can you add some basic tests before we merge this? Maybe a "golden vector" type test?

Added.

@felipebalbi felipebalbi 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.

Thank you

@JamesHuard
JamesHuard merged commit aa8cf1a into OpenDevicePartnership:mcxa-secure-boot Oct 23, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in EC Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants