cmd

package
v0.0.0-...-3fd909d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2026 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const MaxStoreDataLen = 1020

MaxStoreDataLen is the maximum number of bytes that can be stored in a single store-data operation. The applet encodes the offset as a single byte (offset/4), so offsets ≥ 1024 would wrap and overwrite earlier data.

Variables

View Source
var Version = "dev"

Version is the CLI version string. Set by main package at startup from the -ldflags value; defaults to "dev" for local builds.

Functions

func CashCommands

func CashCommands() []*cli.Command

CashCommands returns the cash applet command group.

func CredentialsCommands

func CredentialsCommands() []*cli.Command

CredentialsCommands returns the credentials management command group.

func DataCommands

func DataCommands() []*cli.Command

DataCommands returns the data management command group.

func IdentCommands

func IdentCommands() []*cli.Command

IdentCommands returns the identity management commands.

func IdentifyCommand

func IdentifyCommand() *cli.Command

IdentifyCommand returns the identify command (applet < 4.0 only).

func KeyCommands

func KeyCommands() []*cli.Command

KeyCommands returns the key management command group.

func LifecycleCommands

func LifecycleCommands() []*cli.Command

LifecycleCommands returns the lifecycle command group (version, info, install, delete, init, factory-reset).

func MetadataCommands

func MetadataCommands() []*cli.Command

MetadataCommands returns the metadata management command group.

func PairingCommands

func PairingCommands() []*cli.Command

PairingCommands returns the pairing command group.

func PinlessCommands

func PinlessCommands() []*cli.Command

PinlessCommands returns the pinless signing command group.

func PrintResult

func PrintResult(mode OutputMode, r Result, showSecrets bool) error

PrintResult writes r to stdout as JSON (if mode == OutputJSON) or as formatted text (r.Format(showSecrets)).

func PrintResultCLI

func PrintResultCLI(cmd interface{ Bool(string) bool }, r Result) error

PrintResultCLI is a convenience wrapper for standalone CLI commands. It reads the --json and --show-secrets flags from cmd and dispatches to PrintResult.

func RegisterShellCommands

func RegisterShellCommands() []shellCommand

RegisterShellCommands returns the full list of shell commands. This is the single source of truth for what the shell can execute. When new commands are added to the top-level CLI, add them here too.

func ShellCommand

func ShellCommand() *cli.Command

ShellCommand returns the shell (scripting) command.

func SigningCommands

func SigningCommands() []*cli.Command

SigningCommands returns the signing command group.

Types

type ActionResult

type ActionResult struct {
	Message string `json:"message"`
}

ActionResult — simple confirmation messages

func (ActionResult) Format

func (r ActionResult) Format(_ bool) string

type AppStatusResult

type AppStatusResult struct {
	PinRetryCount  int    `json:"pin_retry_count"`
	PUKRetryCount  int    `json:"puk_retry_count"`
	KeyInitialized bool   `json:"key_initialized"`
	KeyPath        string `json:"key_path"`
}

AppStatusResult holds keycard application status.

func (AppStatusResult) Format

func (r AppStatusResult) Format(_ bool) string

type AuthLevel

type AuthLevel int

AuthLevel controls how far the authentication pipeline proceeds.

const (
	// AuthNone — connect, create CommandSet, Select. No secure channel.
	AuthNone AuthLevel = iota
	// AuthSecureChannel — open secure channel (pair on V1 if pairing password available). No PIN check.
	AuthSecureChannel
	// AuthPIN — full auth: secure channel + PIN verification.
	AuthPIN
)

type BIP85KeyResult

type BIP85KeyResult struct {
	Key  string `json:"key"`
	Path string `json:"path"`
}

BIP85KeyResult — "export-bip85"

func (BIP85KeyResult) Format

func (r BIP85KeyResult) Format(_ bool) string

type CashInfo

type CashInfo struct {
	Installed bool   `json:"installed"`
	PublicKey string `json:"public_key,omitempty"`
	Address   string `json:"address,omitempty"`
	Version   string `json:"version,omitempty"`
}

CashInfo holds cash applet info.

type CashInfoResult

type CashInfoResult struct {
	Cash CashInfo `json:"cash"`
}

CashInfoResult holds cash applet info (for the "cash-info" CLI/shell command).

func (*CashInfoResult) Format

func (r *CashInfoResult) Format(_ bool) string

type ChallengeResult

type ChallengeResult struct {
	Challenge string `json:"challenge"`
}

ChallengeResult holds a random challenge.

func (ChallengeResult) Format

func (r ChallengeResult) Format(_ bool) string

type DataResult

type DataResult struct {
	Type  string `json:"type"`
	Data  string `json:"data,omitempty"`
	Bytes int    `json:"bytes,omitempty"`
}

DataResult holds stored/retrieved data.

func (DataResult) Format

func (r DataResult) Format(_ bool) string

type ExportedKeyResult

type ExportedKeyResult struct {
	PrivateKey string `json:"private_key,omitempty"`
	PublicKey  string `json:"public_key"`
	ChainCode  string `json:"chain_code,omitempty"`
	Address    string `json:"address,omitempty"`
	Path       string `json:"path,omitempty"`
}

ExportedKeyResult holds exported key data.

func (ExportedKeyResult) Format

func (r ExportedKeyResult) Format(_ bool) string

type GPResult

type GPResult struct {
	SW   uint16 `json:"-"`
	Data []byte `json:"-"`

	SWStr   string `json:"sw"`
	DataHex string `json:"data"`
}

GPResult holds the result of a GP APDU send.

func (GPResult) Format

func (r GPResult) Format(_ bool) string

type GPStatusResult

type GPStatusResult struct {
	Lifecycle string `json:"lifecycle"`
}

GPStatusResult — "gp-get-status"

func (GPStatusResult) Format

func (r GPStatusResult) Format(_ bool) string

type GenerateMnemonicResult

type GenerateMnemonicResult struct {
	Phrase string `json:"phrase"`
	Words  int    `json:"words"`
	KeyID  string `json:"key_id,omitempty"` // set when mnemonic is also loaded onto the card
}

GenerateMnemonicResult holds the result of generating a mnemonic phrase.

func (GenerateMnemonicResult) Format

func (r GenerateMnemonicResult) Format(showSecrets bool) string

type IdentifyResult

type IdentifyResult struct {
	Identified bool   `json:"identified"`
	PublicKey  string `json:"public_key"`
}

IdentifyResult holds card identification result.

func (IdentifyResult) Format

func (r IdentifyResult) Format(_ bool) string

type InitResult

type InitResult struct {
	Pin             string `json:"pin"`
	Puk             string `json:"puk"`
	PairingPassword string `json:"pairing_password,omitempty"`
}

InitResult — "init" (no "Card initialized." prefix)

func (InitResult) Format

func (r InitResult) Format(showSecrets bool) string

type KeyGenerateResult

type KeyGenerateResult struct {
	KeyUID string `json:"key_uid"`
}

KeyGenerateResult — "generate-key"

func (KeyGenerateResult) Format

func (r KeyGenerateResult) Format(_ bool) string

type KeyLoadResult

type KeyLoadResult struct {
	KeyID string `json:"key_id"`
}

KeyLoadResult — "load-seed"

func (KeyLoadResult) Format

func (r KeyLoadResult) Format(_ bool) string

type KeycardInfo

type KeycardInfo struct {
	Installed            bool     `json:"installed"`
	Initialized          bool     `json:"initialized"`
	AppVersion           string   `json:"app_version,omitempty"`
	AppVersionHex        string   `json:"app_version_hex,omitempty"`
	HasMasterKey         bool     `json:"has_master_key"`
	KeyUID               string   `json:"key_uid,omitempty"`
	SecureChannelVersion string   `json:"secure_channel_version,omitempty"`
	Capabilities         []string `json:"capabilities,omitempty"`
	PINRetries           int      `json:"pin_retries"`
	LEEMode              bool     `json:"lee_mode"`
	HasFactoryResetCap   bool     `json:"has_factory_reset_capability"`
	// V1-V3 fields
	InstanceUID    string `json:"instance_uid,omitempty"`
	AvailableSlots *int   `json:"available_slots,omitempty"`
	// V4+ fields
	Certificate      string `json:"certificate,omitempty"`
	IdentityPubKey   string `json:"identity_pub_key,omitempty"`
	CertVerification string `json:"certificate_verification_error,omitempty"`
}

KeycardInfo holds keycard applet info.

type KeycardInfoResult

type KeycardInfoResult struct {
	Keycard KeycardInfo `json:"keycard"`
}

KeycardInfoResult holds keycard applet info (for the "info" CLI/shell command).

func (*KeycardInfoResult) Format

func (r *KeycardInfoResult) Format(_ bool) string

type LEEKeyResult

type LEEKeyResult struct {
	Key  string `json:"key"`
	Path string `json:"path"`
}

LEEKeyResult — "export-lee-key"

func (LEEKeyResult) Format

func (r LEEKeyResult) Format(_ bool) string

type LoadIdentResult

type LoadIdentResult struct {
	Bytes int `json:"bytes"`
}

LoadIdentResult holds the result of loading an identity certificate.

func (LoadIdentResult) Format

func (r LoadIdentResult) Format(_ bool) string

type NameResult

type NameResult struct {
	Name string `json:"name"`
}

NameResult holds card display name.

func (NameResult) Format

func (r NameResult) Format(_ bool) string

type OutputMode

type OutputMode int

OutputMode controls output format.

const (
	OutputText OutputMode = iota
	OutputJSON
)

type PairingResult

type PairingResult struct {
	PairingKey   string `json:"pairing_key"`
	PairingIndex int    `json:"pairing_index"`
}

PairingResult holds pairing information.

func (PairingResult) Format

func (r PairingResult) Format(showSecrets bool) string

type Result

type Result interface {
	Format(showSecrets bool) string
}

Result is implemented by all command result types.

type SecureChannelVersionResult

type SecureChannelVersionResult struct {
	Version string `json:"secure_channel_version"`
}

SecureChannelVersionResult holds the secure channel version.

func (SecureChannelVersionResult) Format

type SetNDEFResult

type SetNDEFResult struct {
	Bytes int `json:"bytes"`
}

SetNDEFResult — "set-ndef"

func (SetNDEFResult) Format

func (r SetNDEFResult) Format(_ bool) string

type SetPairingResult

type SetPairingResult struct {
	PairingKey   string `json:"pairing_key"`
	PairingIndex int    `json:"pairing_index"`
}

SetPairingResult — "keycard-set-pairing" (shell-only)

func (SetPairingResult) Format

func (r SetPairingResult) Format(showSecrets bool) string

type SetSecretsResult

type SetSecretsResult struct {
	Pin             string `json:"pin"`
	Puk             string `json:"puk"`
	PairingPassword string `json:"pairing_password"`
}

SetSecretsResult — "keycard-set-secrets" (shell-only)

func (SetSecretsResult) Format

func (r SetSecretsResult) Format(showSecrets bool) string

type SignatureResult

type SignatureResult struct {
	R    string `json:"signature_r"`
	S    string `json:"signature_s"`
	V    int    `json:"signature_v"`
	Path string `json:"path,omitempty"`
	File string `json:"file,omitempty"`
}

SignatureResult holds signature data.

func (SignatureResult) Format

func (r SignatureResult) Format(_ bool) string

type StoreDataResult

type StoreDataResult struct {
	Type  string `json:"type"`
	Bytes int    `json:"bytes"`
}

StoreDataResult — "store-data"

func (StoreDataResult) Format

func (r StoreDataResult) Format(_ bool) string

type UnpairResult

type UnpairResult struct {
	Index int `json:"index"`
}

UnpairResult — "unpair" (includes index)

func (UnpairResult) Format

func (r UnpairResult) Format(_ bool) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL