ledger

package
v0.0.0-...-e8a7bc5 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const LDG = "ledger"

Variables

View Source
var CLEANING_APDU = APDU{0xe0, 0x50, 0x00, 0x00}
View Source
var GET_ADDRESS_APDU = APDU{0xe0, 0x02, 0x00, 0x00}
View Source
var GET_DEVICE_NAME_APDU = APDU{0xe0, 0xd2, 0x00, 0x00}
View Source
var GET_INFO_APDU = APDU{0xb0, 0x01, 0x00, 0x00}
View Source
var LAUNCH_APP_APDU = APDU{0xe0, 0xd8, 0x00, 0x00}
View Source
var QUIT_APP_APDU = APDU{0xb0, 0xa7, 0x00, 0x00}
View Source
var SIGN_MSG_APDU = APDU{0xe0, 0x0c, 0x00, 0x01}
View Source
var SIGN_MSG_PERSONAL_APDU = APDU{0xe0, 0x08, 0x00, 0x00}
View Source
var SIGN_TX_APDU = APDU{0xe0, 0x04, 0x00, 0x00}
View Source
var STRUCT_DEF_FIELD = APDU{0xe0, 0x1a, 0x00, 0xff}
View Source
var STRUCT_DEF_NAME = APDU{0xe0, 0x1a, 0x00, 0x00}
View Source
var STRUCT_IMPL_ARRAY = APDU{0xe0, 0x1c, 0x00, 0x0f}
View Source
var STRUCT_IMPL_FIELD = APDU{0xe0, 0x1c, 0x00, 0xff}
View Source
var STRUCT_IMPL_ROOT = APDU{0xe0, 0x1c, 0x00, 0x00}
View Source
var StatusCodes = map[int]string{
	0x5102: "NOT_ENOUGH_SPACE",
	0x5123: "APP_NOT_FOUND_OR_INVALID_CONTEXT",
	0x5419: "GEN_AES_KEY_FAILED",
	0x541a: "INTERNAL_CRYPTO_OPERATION_FAILED",
	0x541b: "INTERNAL_COMPUTE_AES_CMAC_FAILED",
	0x541c: "ENCRYPT_APP_STORAGE_FAILED",
	0x5501: "USER_REFUSED_ON_DEVICE",
	0x5502: "PIN_NOT_SET",
	0x5515: "LOCKED_DEVICE",
	0x6300: "GP_AUTH_FAILED",
	0x63c0: "PIN_REMAINING_ATTEMPTS",
	0x6511: "WRONG APP",
	0x6611: "DEVICE_NOT_ONBOARDED_2",
	0x662e: "CUSTOM_IMAGE_EMPTY",
	0x662f: "DEVICE_IN_RECOVERY_MODE",
	0x6642: "INVALID_BACKUP_STATE",
	0x6643: "INVALID_RESTORE_STATE",
	0x6700: "INCORRECT_LENGTH",
	0x670a: "INVALID_APP_NAME_LENGTH",
	0x6733: "INVALID_BACKUP_LENGTH",
	0x6734: "INVALID_CHUNK_LENGTH",
	0x684a: "INVALID_BACKUP_HEADER",
	0x6800: "MISSING_CRITICAL_PARAMETER",
	0x6807: "REQUESTED APP IS NOT PRESENT",
	0x6981: "COMMAND_INCOMPATIBLE_FILE_STRUCTURE",
	0x6982: "SECURITY_STATUS_NOT_SATISFIED",
	0x6985: "CONDITIONS_OF_USE_NOT_SATISFIED",
	0x6a80: "INCORRECT_DATA",
	0x6a84: "NOT_ENOUGH_MEMORY_SPACE",
	0x6a88: "REFERENCED_DATA_NOT_FOUND",
	0x6a89: "FILE_ALREADY_EXISTS",
	0x6b00: "INCORRECT_P1_P2",
	0x6d00: "INS_NOT_SUPPORTED",
	0x6d02: "UNKNOWN_APDU",
	0x6d07: "DEVICE_NOT_ONBOARDED",
	0x6e00: "CLA_NOT_SUPPORTED",
	0x6f00: "TECHNICAL_PROBLEM",
	0x6f42: "LICENSING",
	0x6faa: "HALTED",
	0x9000: "OK",
	0x9240: "MEMORY_PROBLEM",
	0x9400: "NO_EF_SELECTED",
	0x9402: "INVALID_OFFSET",
	0x9404: "FILE_NOT_FOUND",
	0x9408: "INCONSISTENT_FILE",
	0x9484: "ALGORITHM_NOT_SUPPORTED",
	0x9485: "INVALID_KCV",
	0x9802: "CODE_NOT_INITIALIZED",
	0x9804: "ACCESS_CONDITION_NOT_FULFILLED",
	0x9808: "CONTRADICTION_SECRET_CODE_STATUS",
	0x9810: "CONTRADICTION_INVALIDATION",
	0x9840: "CODE_BLOCKED",
	0x9850: "MAX_VALUE_REACHED",
}
View Source
var TP_Id int

Functions

func DeserializePacket

func DeserializePacket(
	channel uint16,
	buffer []byte,
	sequenceIdx uint16) (result []byte, totalResponseLength uint16, isSequenceZero bool, err error)

func GetTypeOrder

func GetTypeOrder(typedData apitypes.TypedData) []string

func Loop

func Loop()

func SendFieldValue

func SendFieldValue(msg *bus.Message, ledger *Ledger, value interface{}, typeStr string) error

func SendMessagePayloads

func SendMessagePayloads(msg *bus.Message, ledger *Ledger, typedData apitypes.TypedData, typeName string, messageData map[string]interface{}) error

func SendRootStruct

func SendRootStruct(msg *bus.Message, ledger *Ledger, rootStructName string) error

func SendStructDefinition

func SendStructDefinition(msg *bus.Message, ledger *Ledger, typedData apitypes.TypedData) error

func SendStructFieldDef

func SendStructFieldDef(msg *bus.Message, ledger *Ledger, field apitypes.Type) error

func SendStructImplementation

func SendStructImplementation(msg *bus.Message, ledger *Ledger, typedData apitypes.TypedData) error

func UnwrapResponseAPDU

func UnwrapResponseAPDU(channel uint16, pipe <-chan []byte, packetSize int) ([]byte, error)

UnwrapResponseAPDU parses a response of 64 byte packets into the real data

Types

type APDU

type APDU struct {
	// contains filtered or unexported fields
}

type Ledger

type Ledger struct {
	USB_ID  string
	Name    string
	Product string
	Pane    *LedgerPane
}

connected Ledger

type LedgerPane

type LedgerPane struct {
	ui.PaneDescriptor
	*Ledger
	On       bool
	Id       int
	ViewName string
	Mode     string
	Template string
}

func NewLedgerPane

func NewLedgerPane(t *Ledger) *LedgerPane

func (*LedgerPane) EstimateLines

func (p *LedgerPane) EstimateLines(w int) int

func (*LedgerPane) GetDesc

func (p *LedgerPane) GetDesc() *ui.PaneDescriptor

func (*LedgerPane) IsOn

func (p *LedgerPane) IsOn() bool

func (*LedgerPane) SetMode

func (p *LedgerPane) SetMode(mode string)

func (*LedgerPane) SetOn

func (p *LedgerPane) SetOn(on bool)

func (*LedgerPane) SetView

func (p *LedgerPane) SetView(x0, y0, x1, y1 int, overlap byte)

Jump to

Keyboard shortcuts

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