Skip to content

feat(tbor): implement ShaDigest#587

Closed
vsonims wants to merge 1 commit into
tbor/unwrap-keyfrom
tbor/sha-digest
Closed

feat(tbor): implement ShaDigest#587
vsonims wants to merge 1 commit into
tbor/unwrap-keyfrom
tbor/sha-digest

Conversation

@vsonims

@vsonims vsonims commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds the TBOR ShaDigest command (opcode 0x1B): within an open session, compute a SHA-256 / 384 / 512 digest of a host-supplied message and return it. A pure hashing utility — no key, no scope, no partition state — the TBOR analogue of MBOR ShaDigest.

Opcode Command Session
0x1B ShaDigest InSession

Design

  • Reserve-then-fill: the response frame is encoded with the digest slot reserved, then the PAL hashes straight into it — no intermediate buffer, no copy.
  • Natural big-endian digest output (standard SHA byte order).
  • Reuses the shared HashAlgo enum from key_props (SHA-256/384/512).
  • In-session: session_id cross-checked by the dispatcher, default-PSK gate applies (like the other TBOR crypto commands), but with no masked keys.

Changes

  • Handler fw/core/lib/src/ddi/tbor/sha_digest.rs; dispatch + 3 classifiers in mod.rs; op.rs from_tbor_opcode (InSession).
  • Wire schemas (fw + host mirror) + lib.rs registration.
  • Emu tests: device digests verified byte-for-byte against host-computed SHA (azihsm_crypto) for all three algorithms over short / empty / long messages, plus an unknown-mode reject.
  • Docs: sha_digest.md + README row.

Testing

  • cargo check fw core (host + Uno no_std) ✅
  • clippy (fw + host) ✅ · nightly fmt ✅ · copyright ✅
  • Full TBOR emu suite: 119 passed.

Notes

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Add the TBOR Hash command (opcode 0x1B): within an open session,
compute a SHA-256 / 384 / 512 digest of a host-supplied message and
return it. A pure hashing utility — no key, no scope, no partition state
— the TBOR analogue of MBOR ShaDigest. Named generically (Hash rather
than ShaDigest) to leave room for future XOF / SHAKE variants.

Uses the reserve-then-fill pattern: the response frame is encoded with the
digest slot reserved, then the PAL hashes straight into it (natural
big-endian output) — no intermediate buffer, no copy. Reuses the shared
HashAlgo enum from key_props.

Wire schemas (fw + host mirror); dispatch / classifier / op.rs wiring
(in-session, session-id cross-checked, default-PSK gated). Emu tests
verify device digests byte-for-byte against host-computed SHA
(azihsm_crypto) for all three algorithms over short / empty / long
messages, plus an unknown-algo reject. Per-command docs added.

Based on tbor/unwrap-key (#583) for the shared HashAlgo enum; uses opcode
0x1B to avoid collision with the sibling AES / ECC / RSA crypto branches
(0x15..0x1A).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0b09e50a-a9be-4bae-b347-d42dc775a258
@vsonims vsonims closed this Jul 19, 2026
@vsonims
vsonims deleted the tbor/sha-digest branch July 19, 2026 02:00
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.

1 participant