feat(tbor): implement ShaDigest#587
Closed
vsonims wants to merge 1 commit into
Closed
Conversation
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
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.
Summary
Adds the TBOR
ShaDigestcommand (opcode0x1B): 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 MBORShaDigest.0x1BShaDigestDesign
HashAlgoenum fromkey_props(SHA-256/384/512).session_idcross-checked by the dispatcher, default-PSK gate applies (like the other TBOR crypto commands), but with no masked keys.Changes
fw/core/lib/src/ddi/tbor/sha_digest.rs; dispatch + 3 classifiers inmod.rs;op.rsfrom_tbor_opcode(InSession).lib.rsregistration.azihsm_crypto) for all three algorithms over short / empty / long messages, plus an unknown-mode reject.sha_digest.md+ README row.Testing
cargo checkfw core (host + Uno no_std) ✅Notes
tbor/unwrap-key) for the sharedHashAlgoenum. Uses opcode0x1Bto avoid collision with the sibling AES / ECC / RSA crypto branches (0x15..0x1A).HkdfDerive/KbkdfCounterHmacDerive/ cert-chain commands remain.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com