Documentation ¶
Index ¶
- Constants
- Variables
- func DeserializePacket(channel uint16, packet []byte, sequenceIdx uint16) ([]byte, uint16, bool, error)
- func ErrorMessage(errorCode uint16) string
- func RegisterZemuCommandServer(s *grpc.Server, srv ZemuCommandServer)
- func SerializePacket(channel uint16, command []byte, packetSize int, sequenceIdx uint16) ([]byte, int, error)
- func UnwrapResponseAPDU(channel uint16, pipe <-chan []byte, packetSize int) ([]byte, error)
- func WrapCommandAPDU(channel uint16, command []byte, packetSize int) ([]byte, error)
- type ExchangeReply
- type ExchangeRequest
- type LedgerAdmin
- type LedgerAdminHID
- type LedgerDevice
- type LedgerDeviceHID
- type UnimplementedZemuCommandServer
- type ZemuCommandClient
- type ZemuCommandServer
Constants ¶
const ( MinPacketSize = 3 TagValue = 0x05 )
const ( ErrMsgPacketSize = "packet size must be at least 3" ErrMsgInvalidChannel = "invalid channel" ErrMsgInvalidTag = "invalid tag" ErrMsgWrongSequenceIdx = "wrong sequenceIdx" )
const ( VendorLedger = 0x2c97 UsagePageLedgerNanoS = 0xffa0 Channel = 0x0101 PacketSize = 64 )
Variables ¶
var ( ErrPacketSize = errors.New(ErrMsgPacketSize) ErrInvalidChannel = errors.New(ErrMsgInvalidChannel) ErrInvalidTag = errors.New(ErrMsgInvalidTag) ErrWrongSequenceIdx = errors.New(ErrMsgWrongSequenceIdx) )
var File_zemu_proto protoreflect.FileDescriptor
Functions ¶
func DeserializePacket ¶
func DeserializePacket( channel uint16, packet []byte, sequenceIdx uint16) ([]byte, uint16, bool, error)
DeserializePacket deserializes a packet into its original command.
func ErrorMessage ¶ added in v0.5.0
ErrorMessage returns a human-readable error message for a given APDU error code.
func RegisterZemuCommandServer ¶ added in v0.12.0
func RegisterZemuCommandServer(s *grpc.Server, srv ZemuCommandServer)
func SerializePacket ¶
func SerializePacket( channel uint16, command []byte, packetSize int, sequenceIdx uint16) ([]byte, int, error)
SerializePacket serializes a command into a packet for transmission.
func UnwrapResponseAPDU ¶
UnwrapResponseAPDU parses a response of 64 byte packets into the real data.
Types ¶
type ExchangeReply ¶ added in v0.12.0
type ExchangeReply struct { Reply []byte `protobuf:"bytes,1,opt,name=reply,proto3" json:"reply,omitempty"` // contains filtered or unexported fields }
func (*ExchangeReply) Descriptor
deprecated
added in
v0.12.0
func (*ExchangeReply) Descriptor() ([]byte, []int)
Deprecated: Use ExchangeReply.ProtoReflect.Descriptor instead.
func (*ExchangeReply) GetReply ¶ added in v0.12.0
func (x *ExchangeReply) GetReply() []byte
func (*ExchangeReply) ProtoMessage ¶ added in v0.12.0
func (*ExchangeReply) ProtoMessage()
func (*ExchangeReply) ProtoReflect ¶ added in v0.12.0
func (x *ExchangeReply) ProtoReflect() protoreflect.Message
func (*ExchangeReply) Reset ¶ added in v0.12.0
func (x *ExchangeReply) Reset()
func (*ExchangeReply) String ¶ added in v0.12.0
func (x *ExchangeReply) String() string
type ExchangeRequest ¶ added in v0.12.0
type ExchangeRequest struct { Command []byte `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"` // contains filtered or unexported fields }
func (*ExchangeRequest) Descriptor
deprecated
added in
v0.12.0
func (*ExchangeRequest) Descriptor() ([]byte, []int)
Deprecated: Use ExchangeRequest.ProtoReflect.Descriptor instead.
func (*ExchangeRequest) GetCommand ¶ added in v0.12.0
func (x *ExchangeRequest) GetCommand() []byte
func (*ExchangeRequest) ProtoMessage ¶ added in v0.12.0
func (*ExchangeRequest) ProtoMessage()
func (*ExchangeRequest) ProtoReflect ¶ added in v0.12.0
func (x *ExchangeRequest) ProtoReflect() protoreflect.Message
func (*ExchangeRequest) Reset ¶ added in v0.12.0
func (x *ExchangeRequest) Reset()
func (*ExchangeRequest) String ¶ added in v0.12.0
func (x *ExchangeRequest) String() string
type LedgerAdmin ¶ added in v0.12.0
type LedgerAdmin interface { CountDevices() int ListDevices() ([]string, error) Connect(deviceIndex int) (LedgerDevice, error) }
LedgerAdmin defines the interface for managing Ledger devices.
func NewLedgerAdmin ¶ added in v0.12.0
func NewLedgerAdmin() LedgerAdmin
type LedgerAdminHID ¶ added in v0.12.0
type LedgerAdminHID struct{}
func (*LedgerAdminHID) Connect ¶ added in v0.12.0
func (admin *LedgerAdminHID) Connect(requiredIndex int) (LedgerDevice, error)
func (*LedgerAdminHID) CountDevices ¶ added in v0.12.0
func (admin *LedgerAdminHID) CountDevices() int
func (*LedgerAdminHID) ListDevices ¶ added in v0.12.0
func (admin *LedgerAdminHID) ListDevices() ([]string, error)
type LedgerDevice ¶ added in v0.12.0
LedgerDevice defines the interface for interacting with a Ledger device.
type LedgerDeviceHID ¶ added in v0.12.0
type LedgerDeviceHID struct {
// contains filtered or unexported fields
}
func (*LedgerDeviceHID) Close ¶ added in v0.12.0
func (ledger *LedgerDeviceHID) Close() error
func (*LedgerDeviceHID) Exchange ¶ added in v0.12.0
func (ledger *LedgerDeviceHID) Exchange(command []byte) ([]byte, error)
func (*LedgerDeviceHID) Read ¶ added in v0.12.0
func (ledger *LedgerDeviceHID) Read() <-chan []byte
type UnimplementedZemuCommandServer ¶ added in v0.12.0
type UnimplementedZemuCommandServer struct { }
UnimplementedZemuCommandServer can be embedded to have forward compatible implementations.
func (*UnimplementedZemuCommandServer) Exchange ¶ added in v0.12.0
func (*UnimplementedZemuCommandServer) Exchange(context.Context, *ExchangeRequest) (*ExchangeReply, error)
type ZemuCommandClient ¶ added in v0.12.0
type ZemuCommandClient interface {
Exchange(ctx context.Context, in *ExchangeRequest, opts ...grpc.CallOption) (*ExchangeReply, error)
}
ZemuCommandClient is the client API for ZemuCommand service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewZemuCommandClient ¶ added in v0.12.0
func NewZemuCommandClient(cc grpc.ClientConnInterface) ZemuCommandClient
type ZemuCommandServer ¶ added in v0.12.0
type ZemuCommandServer interface {
Exchange(context.Context, *ExchangeRequest) (*ExchangeReply, error)
}
ZemuCommandServer is the server API for ZemuCommand service.