Skip to main content

Command

Enum Command 

Source
pub(crate) enum Command {
Show 23 variants Enumerate, Info, ReadConfig, ReadConfigSlot { slot: u8, }, ReadSlotBlock { slot: u8, block: u8, }, ReadSlotWord { slot: u8, block: u8, offset: u8, }, WriteConfig { path: String, }, ProvisionSlot { slot: u8, value: String, }, ProvisionToken { secrets_file: String, }, GetPubkey { slot: u8, }, Genkey { slot: u8, }, Sign { slot: u8, challenge: String, }, VerifyPin { pin: String, }, SetPin { old: String, new: String, io_key: String, }, UnblockPin { puk: String, new_pin: String, io_key: String, }, SetPuk { old: String, new: String, io_key: String, }, CloseSession, EmergencyResetDangerous { io_key: String, }, PinStatus, ReadCounter { id: u8, }, LockConfigDangerous, LockDataDangerous, LockSlotDangerous { slot: u8, },
}

Variants§

§

Enumerate

Enumerate all USB HID devices and print those matching the mini-HSM vendor / product IDs.

§

Info

Send an Info request and pretty-print the response.

§

ReadConfig

Read the chip’s 128-byte config zone and dump it as hex.

§

ReadConfigSlot

Read the per-slot configuration (SlotConfig + KeyConfig). Returns 4 bytes : [SlotConfig lo/hi, KeyConfig lo/hi].

Fields

§slot: u8
§

ReadSlotBlock

Read one 32-byte block of a data slot. The chip enforces the slot’s read policy (private ECC slots refuse reads). Mostly useful for bring-up diagnostics and to verify what ProvisionSlot wrote before locking the data zone.

Fields

§slot: u8
§block: u8

Block index inside the slot (slot-size dependent).

§

ReadSlotWord

Read one 4-byte word of a data slot.

Fields

§slot: u8
§block: u8

Block index inside the slot.

§offset: u8

Word offset inside the block (0..=7).

§

WriteConfig

Write the writable bytes of the config zone (provisioning). Reversible while the zone is unlocked.

Fields

§path: String

Path to the 128-byte config blob produced by tools/config-generator.

§

ProvisionSlot

Write a 32-byte value in cleartext into one of the data slots 5, 6, or 8. Only legal before the data zone is locked. Used for the initial provisioning of the PIN hash, PUK hash, and IO key.

Fields

§slot: u8
§value: String

32-byte value, hex-encoded (64 chars).

§

ProvisionToken

Orchestrate the full data-zone provisioning of a fresh, config-locked token in one shot: generate IO key (slot 8), initial PIN hash (slot 5, PIN = “0000”), initial PUK (slot 6, random 8 digits), and the primary identity key (slot 0). The IO key and PUK are written to secrets_file (JSON) and also printed on stdout. Both are required for later operations and cannot be retrieved later.

Fields

§secrets_file: String

Path to the JSON file that will receive the chip’s serial, the IO key, and the initial PUK. Refuses to overwrite an existing file.

§

GetPubkey

Read the public key of a slot.

Fields

§slot: u8
§

Genkey

Regenerate the private key in a slot (P-256, on-chip).

Fields

§slot: u8
§

Sign

Sign a 32-byte challenge after PIN + touch.

Fields

§slot: u8
§challenge: String

32-byte challenge as a hex string (64 chars).

§

VerifyPin

Open a PIN session.

Fields

§

SetPin

Change the PIN. Requires an active PIN session.

Fields

§io_key: String

32-byte IO Protection Key as a hex string (64 chars).

§

UnblockPin

Reset the PIN using the PUK.

Fields

§new_pin: String
§io_key: String

32-byte IO Protection Key as a hex string (64 chars).

§

SetPuk

Change the PUK. Requires an active PIN session (call verify-pin first) AND the current PUK. The current PUK is re-verified against slot 6, which consumes one Counter1 attempt internally (refreshed on success).

Fields

§io_key: String

32-byte IO Protection Key as a hex string (64 chars).

§

CloseSession

Close the active PIN session immediately. Idempotent: succeeds even if no session is open. Use this to lock the dongle proactively after a signing burst instead of waiting for the 30 s inactivity timeout.

§

EmergencyResetDangerous

LAST-CHANCE RECOVERY. Only usable when both the PIN and the PUK batches are exhausted (i.e. the user has forgotten both and tried until they hit zero attempts on both). Destroys every user secret in the chip and rebuilds a clean baseline with PIN “0000” and a fresh random PUK. ECC private keys in slots 0..=4 and 7 are lost. The chip survives.

Fields

§io_key: String

32-byte IO Protection Key as a hex string (64 chars).

§

PinStatus

Read current PIN / PUK retry counters and session state.

§

ReadCounter

Read the raw value of one of the chip’s monotonic counters.

Diagnostic command. Returns the binary count the chip’s Counter command sees, without the batch-arithmetic conversion that pin-status applies. Use during bring-up to verify what the chip actually stores.

Fields

§id: u8

0 for Counter0 (PIN slot, slot 5), 1 for Counter1 (PUK slot, slot 6).

§

LockConfigDangerous

Lock the config zone. Irreversible. Reads the chip’s configuration zone, computes the CRC-16 over the full 128 bytes, and shows it in the double-confirmation prompt. The same CRC is passed to the chip, which verifies one last time before committing.

§

LockDataDangerous

Lock the data zone. Irreversible. No CRC is checked at lock time: every secret-bearing slot has IsSecret=1 and cannot be read back. The double-confirmation prompt is the only safety beyond the magic-word check.

§

LockSlotDangerous

Lock an individual slot. Irreversible. Requires the slot index and an interactive confirmation.

Fields

§slot: u8

Trait Implementations§

Source§

impl Debug for Command

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromArgMatches for Command

Source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from [ArgMatches], parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from [ArgMatches], parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut<'b>( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

impl Subcommand for Command

Source§

fn augment_subcommands<'b>(__clap_app: Command) -> Command

Append to [Command] so it can instantiate Self via [FromArgMatches::from_arg_matches_mut] Read more
Source§

fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command

Append to [Command] so it can instantiate self via [FromArgMatches::update_from_arg_matches_mut] Read more
Source§

fn has_subcommand(__clap_name: &str) -> bool

Test whether Self can parse a specific subcommand

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.