Skip to main content

Module commands

Module commands 

Source
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§

UnknownOpcode
Returned when a byte cannot be mapped to a known CommandOpcode.

Enums§

CommandOpcode
Opcode byte for each command.
PayloadError
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::EmergencyReset to confirm the caller’s intent. Picked to be improbable for any byte sequence arising from a typo or a buggy host. Same role as LOCK_CONFIG_MAGIC in 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, and CommandOpcode::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§

SetPinParts 🔒
Result of parse_set_pin: (old_pin, new_pin, io_key).
SetPukParts 🔒
Result of parse_set_puk: (old_puk, new_puk, io_key).
UnblockPinParts 🔒
Result of parse_unblock_pin: (puk, new_pin, io_key).