Expand description
Commands sent from the host to the token.
See crate::frame::Frame for the wire layout. The opcode byte is
CommandOpcode; the payload layout is documented per-opcode below
(in the variant doc-comments) and parsed via the helpers in this module.
§Opcode ranges
0x01..=0x0F: runtime operations. Read-only inspection, signing, PIN/PUK session management, recovery. Safe to call at any point after provisioning is complete.0x10..=0x1F: provisioning operations. Only effective while the relevant zone is unlocked. Sequenced once at the chip’s first boot and never again in normal operation.0xF0..=0xFF: destructive / irreversible operations (zone and slot locks). Protected by per-opcode magic words and, on the host side, by interactive double-confirmation prompts.
Structs§
- Unknown
Opcode - Returned when a byte cannot be mapped to a known
CommandOpcode.
Enums§
- Command
Opcode - Opcode byte for each command.
- Payload
Error - Errors returned when a payload does not match the expected shape.
Constants§
- DIGEST_
LEN - Digest length used for
CommandOpcode::Sign(SHA-256 output). - EMERGENCY_
RESET_ MAGIC - Magic word required in the payload of
CommandOpcode::EmergencyResetto confirm the caller’s intent. Picked to be improbable for any byte sequence arising from a typo or a buggy host. Same role asLOCK_CONFIG_MAGICin the lock commands. - IO_
KEY_ 🔒LEN - Length of the I/O Protection Key (slot 8 content), in bytes.
- LOCK_
CONFIG_ MAGIC - Magic word for
CommandOpcode::LockConfigZone. Picked to be a distinctive 32-bit value (DE AD BE EF). - LOCK_
DATA_ MAGIC - Magic word for
CommandOpcode::LockDataZone(CA FE BA BE). - LOCK_
MAGIC_ 🔒LEN - Length of the magic word protecting
CommandOpcode::LockConfigZone,CommandOpcode::LockDataZone, andCommandOpcode::LockSlot. - LOCK_
SLOT_ MAGIC - Magic word for
CommandOpcode::LockSlot(F0 0D CA FE). - PIN_LEN
- PIN length in bytes (4 digits).
- PUK_LEN
- PUK length in bytes (8 digits).
Functions§
- parse_
emergency_ reset - Parse the payload of
CommandOpcode::EmergencyReset. - parse_
lock_ config_ zone - Parse the payload of
CommandOpcode::LockConfigZone. - parse_
lock_ data_ zone - Parse the payload of
CommandOpcode::LockDataZone. - parse_
lock_ slot - Parse the payload of
CommandOpcode::LockSlot. - parse_
provision_ slot - Parse the payload of
CommandOpcode::ProvisionSlot. - parse_
read_ slot_ block - Parse the payload of
CommandOpcode::ReadSlotBlock. - parse_
read_ slot_ word - Parse the payload of
CommandOpcode::ReadSlotWord. - parse_
set_ pin - Parse the payload of
CommandOpcode::SetPin. - parse_
set_ puk - Parse the payload of
CommandOpcode::SetPuk. - parse_
sign - Parse the payload of
CommandOpcode::Sign. - parse_
slot_ only - Parse the payload of
CommandOpcode::GetPubkey/GenKey/ReadConfigSlot. - parse_
unblock_ pin - Parse the payload of
CommandOpcode::UnblockPin. - parse_
verify_ pin - Parse the payload of
CommandOpcode::VerifyPin. - parse_
write_ config_ zone - Parse the payload of
CommandOpcode::WriteConfigZone. - require_
len 🔒
Type Aliases§
- SetPin
Parts 🔒 - Result of
parse_set_pin:(old_pin, new_pin, io_key). - SetPuk
Parts 🔒 - Result of
parse_set_puk:(old_puk, new_puk, io_key). - Unblock
PinParts 🔒 - Result of
parse_unblock_pin:(puk, new_pin, io_key).