feat(tbor): implement SdRestoreRemoteBackup (remote SD recovery) - #567
Merged
Conversation
vsonims
force-pushed
the
sd/restore-local-backup
branch
from
July 17, 2026 00:57
132470e to
4ffcf19
Compare
vsonims
force-pushed
the
sd/restore-remote-backup
branch
4 times, most recently
from
July 17, 2026 11:31
67cafc8 to
b838686
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Implements firmware + host support for TBOR SdRestoreRemoteBackup (opcode 0x0C), enabling security-domain recovery from a remote HPKE-authenticated backup by combining sender-evidence verification with the existing SD provisioning/restore mechanics.
Changes:
- Added the
SdRestoreRemoteBackuphandler, wired opcode/dispatch/session classification, and updated the wire schema to usemasked_sealing_key,src_remote_backup, and requiredprev_sd_mk_backup. - Refactored SD restore provisioning into a shared
sd_backup::reprovision_sd_from_bks3path, and updated local restore to reuse it. - Added docs and emu integration tests for remote restore, plus minor test harness visibility adjustments.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| fw/core/lib/src/op.rs | Adds SD_RESTORE_REMOTE_BACKUP to the in-session opcode classification. |
| fw/core/lib/src/ddi/tbor/sd_restore_remote_backup.rs | New handler implementing remote SD restore: evidence verification + HPKE open + provisioning. |
| fw/core/lib/src/ddi/tbor/sd_restore_local_backup.rs | Refactors local restore to reuse the shared provisioning function. |
| fw/core/lib/src/ddi/tbor/sd_backup.rs | Extracts shared SD reprovisioning logic (reprovision_sd_from_bks3). |
| fw/core/lib/src/ddi/tbor/mod.rs | Wires new opcode constant, dispatch arm, and opcode classifiers. |
| fw/core/ddi/tbor/types/src/sd_restore_remote_backup.rs | Updates firmware-side TBOR wire schema and schema unit tests. |
| docs/tbor-ddi/README.md | Updates command table entry to reflect handler is implemented (not schema-only). |
| docs/tbor-ddi/commands/sd_restore_remote_backup.md | Adds full command documentation for remote restore flow, schema, and errors. |
| ddi/tbor/types/tests/commands/sd_restore_remote_backup.rs | Adds new emu integration tests for remote restore (round-trip, one-shot, pre-finalize reject). |
| ddi/tbor/types/tests/commands/sd_create_remote_backup.rs | Exposes evidence fields for reuse by remote restore tests. |
| ddi/tbor/types/tests/commands/mod.rs | Registers the new remote restore integration test module. |
| ddi/tbor/types/src/sd_restore_remote_backup.rs | Updates host-side request/response wrapper to match the new schema. |
vsonims
force-pushed
the
sd/restore-remote-backup
branch
from
July 17, 2026 12:00
b838686 to
aeb070b
Compare
jaygmsft
previously approved these changes
Jul 17, 2026
vsonims
force-pushed
the
sd/restore-remote-backup
branch
3 times, most recently
from
July 19, 2026 03:17
401df3b to
ce8c882
Compare
jaygmsft
approved these changes
Jul 20, 2026
vsonims
enabled auto-merge
July 20, 2026 18:32
Restores a security domain from a **remote** backup (manticore §3.3.8):
the peer/migration recovery counterpart to SdRestoreLocalBackup. It is
SdResealRemoteBackup's HPKE-open front-end + the shared SD provisioning
back-end:-
1. Gate to a Crypto-Officer Active session on an Initialized partition;
fail-fast one-shot (SdAlreadyInitialized).
2. Bind the caller policy to the partition policy_hash, then verify the
sender evidence (cert chains anchored to the policy SATA key; report
v2 policy_hash == SHA-384(policy)) → SndrPub.
3. Unmask masked_sealing_key → RcvrPriv (must be SdSealing); derive
RcvrPub on-device.
4. HPKE-Auth-open src_remote_backup (sender-auth SndrPub) → BKS3.
5. reprovision_sd_from_bks3: recover SDMK from prev_sd_mk_backup,
re-mask both backups at the current {svn, owner}, vault SDMK, and
mark the partition SD-initialized — undo-guarded. RcvrPriv, BKS3,
SDMK, SDBMK scrubbed on every exit path.
Reworks the stale wire schema (masked_sealing_key(180); policy(484);
src_remote_backup(161); prev_sd_mk_backup(164) required) and extracts the
shared reprovision_sd_from_bks3 helper into sd_backup.rs, refactoring
SdRestoreLocalBackup to reuse it. Wires opcode 0x0C through dispatch,
op.rs (from_tbor_opcode), and the mod.rs classifiers.
Adds emu integration tests: create→reboot→PartFinal(restore
PartLocalMK)→restore-remote HPKE round-trip, one-shot rejection, and
reject-before-finalize. Full emu suite: 113/113. Updates the command doc
and README table.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0b09e50a-a9be-4bae-b347-d42dc775a258
vsonims
force-pushed
the
sd/restore-remote-backup
branch
from
July 20, 2026 18:35
ce8c882 to
2b03645
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implements
SdRestoreRemoteBackup(opcode0x0C, manticore §3.3.8) — the peer/migration recovery path for a security domain. It isSdResealRemoteBackup's HPKE-open front-end +SdRestoreLocalBackup's provisioning back-end.Flow
Activesession on anInitializedpartition; fail-fast one-shot (SdAlreadyInitialized).policyto the partitionpolicy_hash, then verify the sender evidence: cert chains validated + anchored to the policySATAkey, report v2policy_hash == SHA-384(policy)→ recoverSndrPub.masked_sealing_key→RcvrPriv(must beSdSealing); deriveRcvrPubon-device.src_remote_backup(sender-authSndrPub) → BKS3.reprovision_sd_from_bks3: recoverSDMKfromprev_sd_mk_backup, re-mask both backups at the current{svn, owner}, vaultSDMK, mark the partition SD-initialized — undo-guarded.RcvrPriv, BKS3, SDMK, SDBMK are zeroized on every exit path.Changes
fw/core/lib/src/ddi/tbor/sd_restore_remote_backup.rs(new).masked_sealing_key(180) ·policy(484) ·sender_evidence·src_remote_backup(161) ·prev_sd_mk_backup(164, required). Host + fw schemas + round-trip unit tests.reprovision_sd_from_bks3intosd_backup.rs(recover SDMK + anti-rollback + re-mask + vault-commit); refactoredSdRestoreLocalBackupto reuse it — both restores now share one provisioning path.0x0C:mod.rs(dispatch arm +is_known_opcode/is_in_session/needs_session_id_cross_check) andop.rsfrom_tbor_opcode(required, else the SQE session-flag check rejects it asInvalidArg).docs/tbor-ddi/commands/sd_restore_remote_backup.md+ README table row (drops "schema-only").Tests
New emu integration tests (
ddi/tbor/types/tests/commands/sd_restore_remote_backup.rs):PartFinal(prev_local_mk_backup)restoresPartLocalMK(so the captured sealing key unmasks) → HPKE-open restore returns non-zero refreshed local backups.SdAlreadyInitialized.InvalidArg.Validation
cargo xtask nextest --features emu -p azihsm_ddi_tbor_types→ 113/113 pass (109 prior + 4 new, no regression).cargo xtask build -p azihsm_fw_hsm_std✓ · unocargo xtask clippy(core lib + uno PAL) ✓ · maincargo xtask clippy(full workspace) ✓.cargo +nightly fmt+cargo xtask copyrightclean.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com
Copilot-Session: 0b09e50a-a9be-4bae-b347-d42dc775a258