Skip to content

feat(fw): implement DDI DeleteKey handler#431

Open
jaygmsft wants to merge 1 commit into
mainfrom
user/jayg/delete_key
Open

feat(fw): implement DDI DeleteKey handler#431
jaygmsft wants to merge 1 commit into
mainfrom
user/jayg/delete_key

Conversation

@jaygmsft
Copy link
Copy Markdown
Contributor

@jaygmsft jaygmsft commented Jun 6, 2026

Wire up the previously-unimplemented DeleteKey (1014) DDI op in the firmware application layer: within an open session, delete a vault-resident key by id and return an empty success response.

  • Internal device keys (anything carrying the internal attribute — the partition unwrapping key, session and credential keys) cannot be destroyed by the host and are rejected with CannotDeleteInternalKeys, matching the reference firmware.
  • An unknown key_id is rejected with KeyNotFound.
  • Session validation is framework-level (DeleteKey -> InSession), so a missing/mismatched session returns FileHandleSessionIdDoesNotMatch.

The handler is synchronous: the internal-attribute check and the vault deletion have no yield point between them, so no partition_lock is needed.

New: delete_key.rs handler; mod.rs dispatch wiring; delete_key_smoke.rs smoke tests (delete + reuse, unknown-key, and double-delete idempotency using an app AES key, so they run on both backends).

Validation:

  • emu delete_key_smoke 3/3; mock 3/3.
  • mock delete_key integration 8/8 (includes CannotDeleteInternalKeys for the unwrapping key). On emu the core delete_key integration tests pass (6/8); the unwrapping-key and bulk-import cases are setup-blocked by GetUnwrappingKey / RsaUnwrap, which are not yet implemented on main (a pre-existing limitation, not this handler) — the internal-key path is exercised on mock instead.
  • emu smoke 33/33 (no regression).
  • cargo xtask clippy clean; clippy --tests clean under emu and mock; fmt and copyright clean.

Wire up the previously-unimplemented DeleteKey (1014) DDI op in the
firmware application layer: within an open session, delete a
vault-resident key by id and return an empty success response.

- Internal device keys (anything carrying the `internal` attribute —
  the partition unwrapping key, session and credential keys) cannot be
  destroyed by the host and are rejected with
  CannotDeleteInternalKeys, matching the reference firmware.
- An unknown key_id is rejected with KeyNotFound.
- Session validation is framework-level (DeleteKey -> InSession), so
  a missing/mismatched session returns FileHandleSessionIdDoesNotMatch.

The handler is synchronous: the `internal`-attribute check and the
vault deletion have no yield point between them, so no partition_lock
is needed.

New: delete_key.rs handler; mod.rs dispatch wiring; delete_key_smoke.rs
smoke tests (delete + reuse, unknown-key, and double-delete idempotency
using an app AES key, so they run on both backends).

Validation:
- emu delete_key_smoke 3/3; mock 3/3.
- mock delete_key integration 8/8 (includes CannotDeleteInternalKeys
  for the unwrapping key). On emu the core delete_key integration
  tests pass (6/8); the unwrapping-key and bulk-import cases are
  setup-blocked by GetUnwrappingKey / RsaUnwrap, which are not yet
  implemented on main (a pre-existing limitation, not this handler) —
  the internal-key path is exercised on mock instead.
- emu smoke 33/33 (no regression).
- cargo xtask clippy clean; clippy --tests clean under emu and mock;
  fmt and copyright clean.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 6, 2026 21:41
Copy link
Copy Markdown
Contributor

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 implements the MBOR DDI DeleteKey (op 1014) firmware handler, wiring it into the firmware dispatcher and adding end-to-end smoke tests to validate delete behavior across both mock and emu backends.

Changes:

  • Added a new synchronous firmware handler to delete a vault-resident key by id, rejecting internal keys and unknown ids with the expected DDI statuses.
  • Wired DeleteKey into the MBOR module exports and dispatch table.
  • Added integration smoke tests covering delete+reuse, unknown key deletion, and double-delete behavior; registered the new test module.

Reviewed changes

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

File Description
fw/core/lib/src/ddi/mbor/mod.rs Exposes the new handler and routes DdiOp::DeleteKey to it in the dispatcher.
fw/core/lib/src/ddi/mbor/delete_key.rs Implements the firmware-side DeleteKey operation (internal-key rejection, vault delete, empty success response).
ddi/mbor/types/tests/integration/delete_key_smoke.rs Adds backend-agnostic smoke tests for delete semantics using an app AES key.
ddi/mbor/types/tests/azihsm_ddi_tests.rs Registers the new delete_key_smoke integration test module.

Comment thread ddi/mbor/types/tests/integration/delete_key_smoke.rs
@jaygmsft jaygmsft enabled auto-merge (squash) June 6, 2026 22:15
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