apdu

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2019 License: MIT Imports: 4 Imported by: 2

README

APDU

License Build Status Coverage Status Go Report Card GoDoc Release

Go package to work with ISO-7816 APDU command-response pairs

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseResponse

func ParseResponse(b []byte) (data []byte, err error)

ParseResponse parses response and returns response data and/or error if the status word is not 0x9000

Types

type APDU

type APDU struct {
	Cla  byte
	Ins  byte
	P1   byte
	P2   byte
	Data []byte
	Le   byte
}

APDU represents ISO-7816 APDU command

func FromBytes

func FromBytes(b []byte) (*APDU, error)

FromBytes creates APDU command from the byte slice

func FromString

func FromString(s string) (*APDU, error)

FromString creates APDU command from hexadecimal string

func MustFromString

func MustFromString(s string) APDU

MustFromString creates APDU command from hexadecimal string and panics on error

func Select

func Select(aid []byte) APDU

Select returns APDU command for selecting requested application ID

func (APDU) Bytes

func (a APDU) Bytes() []byte

Bytes return APDU encoded into a byte slice

func (APDU) String

func (a APDU) String() string

String implements fmt.Stringer

type Response

type Response struct {
	Data       []byte
	StatusWord StatusWord
}

Response to APDU command from the target

func NewResponse

func NewResponse(b []byte) (*Response, error)

NewResponse parses byte slice and returns Response struct or error

type StatusWord

type StatusWord [2]byte

StatusWord is a mandatory part of the response to APDU command

func (StatusWord) Error

func (sw StatusWord) Error() string

Error implements error interface

func (StatusWord) IsError

func (sw StatusWord) IsError() bool

IsError returns true if the status word is not 0x9fXX or 0x9000

Jump to

Keyboard shortcuts

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