Skip to content

Add Crypto Engine error codes to HsmError/TborStatus - #697

Open
Aakash Sasidharan (asasidharan) wants to merge 1 commit into
Azure:mainfrom
asasidharan:asasidharan-mrvl/add-cryptocontroller-error-codes
Open

Add Crypto Engine error codes to HsmError/TborStatus#697
Aakash Sasidharan (asasidharan) wants to merge 1 commit into
Azure:mainfrom
asasidharan:asasidharan-mrvl/add-cryptocontroller-error-codes

Conversation

@asasidharan

Copy link
Copy Markdown

Mirror Crypto Engine error code range (0x090A_xxxx) into HsmError and its TborStatus wire mirror, using the same names and numeric values, so the engine originated codes are directly representable without a translation layer.

Copilot AI lite review requested due to automatic review settings September 4, 2026 08:11

Copilot AI 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.

🟡 Changes recommended

There is a concrete rustdoc formatting defect in the updated documentation comment, and the new CPT status mapping logic in api/lib is currently untested despite existing unit test coverage in that module.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR extends the AZIHSM error-code surface to directly represent CryptoController (CPT) engine-originated errors across firmware PAL traits (HsmError), the TBOR wire status mirror (TborStatus), and the host API layer, avoiding an extra translation step.

Changes:

  • Added the CPT (0x090A_xxxx) error-code range to firmware HsmError and DDI TborStatus, preserving numeric values and names.
  • Added host-facing HsmError variants and a 1:1 DdiError::TborStatus(...) -> HsmError mapping for the CPT statuses.
  • Added a firmware-side unit test pinning CPT numeric values to the external source of truth.
File summaries
File Description
fw/pal/traits/src/error.rs Adds CPT error variants to FW HsmError and a unit test asserting the numeric values.
ddi/tbor/types/src/status.rs Adds CPT status variants to TborStatus to mirror FW error codes on the wire.
api/lib/src/error.rs Adds host-facing HsmError variants corresponding to CPT statuses.
api/lib/src/ddi/mod.rs Maps CPT TborStatus values 1:1 into host HsmError variants.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread api/lib/src/ddi/mod.rs
Comment on lines +143 to +147
DdiError::TborStatus(TborStatus::CryptoNotInitialized) => {
HsmError::CryptoNotInitialized
}
DdiError::TborStatus(TborStatus::CryptoBufferTooSmall) => {
HsmError::CryptoBufferTooSmall
Comment thread api/lib/src/ddi/mod.rs Outdated
/// All remaining `DdiError` variants are logged and collapsed into
/// `HsmError::DdiCmdFailure`.
///
/// Every `TborStatus::Crypto*`/`CryptoCpt*` CPT (`CryptoController`)/// status is mapped 1:1 to its own `HsmError` variant of the same name,/// mirroring the FW-side range verbatim.
Mirror Crypto Engine error code  range (0x090A_xxxx)
into HsmError and its TborStatus wire mirror, using the same
names and numeric values, so the engine originated codes are
directly representable without a translation layer.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 7, 2026 10:32
@asasidharan
Aakash Sasidharan (asasidharan) force-pushed the asasidharan-mrvl/add-cryptocontroller-error-codes branch from 13f98bb to 54a5466 Compare September 7, 2026 10:32

Copilot AI 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.

🟢 Approval recommended

The changes consistently add and validate the CPT error-code range across FW, wire status, and host mapping layers without altering existing codes or introducing behavioral regressions.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread api/lib/src/ddi/mod.rs
Comment on lines +100 to +102
/// Every `TborStatus::Crypto*`/`CryptoCpt*` CPT (`CryptoController`) status is
/// mapped 1:1 to its own `HsmError` variant of the same name, mirroring the
/// FW-side range verbatim.
Comment thread api/lib/src/error.rs
Comment on lines +72 to +74
// -- CPT (CryptoController) host-facing errors ----------
// 1:1 mirror of the TborStatus/HsmError (FW) CPT range.

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.

2 participants