Documentation
¶
Overview ¶
Package apdu implements parsing and conversion of Application Protocol Data Units (APDU) which is the communication format between a card and off-card applications. The format of the APDU is defined in ISO specification 7816-4. The package has support for extended length APDUs as well.
Index ¶
Constants ¶
const ( // OffsetCla defines the offset to the Cla byte of a Capdu. OffsetCla int = 0 // OffsetIns defines the offset to the Ins byte of a Capdu. OffsetIns int = 1 // OffsetP1 defines the offset to the P1 byte of a Capdu. OffsetP1 int = 2 // OffsetP2 defines the offset to the P2 byte of a Capdu. OffsetP2 int = 3 // OffsetLcStandard defines the offset to the LC byte of a standard length Capdu. OffsetLcStandard int = 4 // OffsetLcExtended defines the offset to the LC byte of an extended length Capdu. OffsetLcExtended int = 5 // OffsetCdataStandard defines the offset to the beginning of the data field of a standard length Capdu. OffsetCdataStandard int = 5 // OffsetCdataExtended defines the offset to the beginning of the data field of an extended length Capdu. OffsetCdataExtended int = 7 // MaxLenCommandDataStandard defines the maximum command data length of a standard length Capdu. MaxLenCommandDataStandard int = 255 // MaxLenResponseDataStandard defines the maximum response data length of a standard length RAPDU. MaxLenResponseDataStandard int = 256 // MaxLenCommandDataExtended defines the maximum command data length of an extended length Capdu. MaxLenCommandDataExtended int = 65535 // MaxLenResponseDataExtended defines the maximum response data length of an extended length RAPDU. MaxLenResponseDataExtended int = 65536 // LenHeader defines the length of the header of an APDU. LenHeader int = 4 // LenLCStandard defines the length of the LC of a standard length APDU. LenLCStandard int = 1 // LenLCExtended defines the length of the LC of an extended length APDU. LenLCExtended int = 3 // LenResponseTrailer defines the length of the trailer of a Response APDU. LenResponseTrailer int = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Capdu ¶
type Capdu struct { Cla byte // Cla is the class byte. Ins byte // Ins is the instruction byte. P1 byte // P1 is the p1 byte. P2 byte // P2 is the p2 byte. Data []byte // Data is the data field. Ne int // Ne is the total number of expected response data byte (not LE encoded). }
Capdu is a Command APDU.
func ParseCapdu ¶
ParseCapdu parses a Command APDU and returns a Capdu.
func ParseCapduHexString ¶
ParseCapduHexString decodes the hex-string representation of a Command APDU, calls ParseCapdu and returns a Capdu.
func (*Capdu) IsExtendedLength ¶
IsExtendedLength returns true if the Capdu has extended length (len of Data > 65535 or Ne > 65536), else false.
type Rapdu ¶
type Rapdu struct { Data []byte // Data is the data field. SW1 byte // SW1 is the first byte of a status word. SW2 byte // SW2 is the second byte of a status word. }
Rapdu is a Response APDU.
func ParseRapdu ¶
ParseRapdu parses a Response APDU and returns a Rapdu.
func ParseRapduHexString ¶
ParseRapduHexString decodes the hex-string representation of a Response APDU, calls ParseRapdu and returns a Rapdu.
func (*Rapdu) IsError ¶
IsError returns true if the RAPDU indicates an error during the execution of a command ('0x64xx', '0x65xx' or from '0x67xx' to 0x6Fxx'), otherwise false.
func (*Rapdu) IsSuccess ¶
IsSuccess returns true if the RAPDU indicates the successful execution of a command ('0x61xx' or '0x9000'), otherwise false.