Documentation ¶
Overview ¶
Package iso7816 implements utilities for interacting with the Contactless IC.
Support is provided for: - Command/Response APDUs (C-APDU.R-APDU) - Secure Messaging - NFC Session (including APDU logging) - Transceiver interface
Index ¶
- Constants
- type ApduLog
- type CApdu
- type MockTransceiver
- type MockTransceiverReqRsp
- type NfcSession
- func (nfc *NfcSession) DoAPDU(cApdu *CApdu, desc string) (rApdu *RApdu, err error)
- func (nfc *NfcSession) ExternalAuthenticate(data []byte, le int) (out []byte, err error)
- func (nfc *NfcSession) GeneralAuthenticate(commandChaining bool, data []byte) *RApdu
- func (nfc *NfcSession) GetChallenge(length int) (out []byte, err error)
- func (nfc *NfcSession) MseSetAT(p1 uint8, p2 uint8, data []byte) (err error)
- func (nfc *NfcSession) ReadBinaryFromOffset(offset int, length int) []byte
- func (nfc *NfcSession) ReadFile(fileId uint16) (fileData []byte)
- func (nfc *NfcSession) SelectAid(aid []byte) (selected bool, err error)
- func (nfc *NfcSession) SelectEF(fileId uint16) (selected bool, err error)
- func (nfc *NfcSession) SelectMF() (err error)
- type RApdu
- type SecureMessaging
- func (sm *SecureMessaging) Decode(rApduBytes []byte) (rApdu *RApdu, err error)
- func (sm *SecureMessaging) Encode(cApdu *CApdu) (out *CApdu, err error)
- func (sm1 SecureMessaging) Equal(sm2 SecureMessaging) bool
- func (sm SecureMessaging) GetKsEnc() []byte
- func (sm *SecureMessaging) SetSSC(ssc []byte)
- func (sm SecureMessaging) String() string
- type StaticTransceiver
- type Transceiver
Constants ¶
View Source
const CLA_MASK byte = 0x0C
View Source
const INS_EXTERNAL_AUTHENTICATE = byte(0x82)
View Source
const INS_GENERAL_AUTHENTICATE = byte(0x86)
View Source
const INS_GET_CHALLENGE = byte(0x84)
View Source
const INS_INTERNAL_AUTHENTICATE = byte(0x88)
View Source
const INS_MANAGE_SE = byte(0x22)
View Source
const INS_READ_BINARY = byte(0xB0)
View Source
const INS_SELECT = byte(0xA4)
View Source
const RAPDU_SECURITY_CONDITION_NOT_SATIFIED = 0x6982
View Source
const RAPDU_STATUS_FILENOTFOUND = 0x6A82
View Source
const RAPDU_STATUS_SELECTED_FILE_INVALIDATED = 0x6283 // warning
View Source
const RAPDU_STATUS_SUCCESS = 0x9000
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApduLog ¶
type ApduLog struct { Desc string Tx []byte Rx []byte Child *ApduLog // optional (e.g. if secure-messaging enabled) DurMs int StartTime time.Time }
func NewApduLog ¶
creates a new instance, records the desc/tx information and starts the timer
type CApdu ¶
type CApdu struct {
// contains filtered or unexported fields
}
func (*CApdu) EncodeHeader ¶
func (*CApdu) IsExtended ¶
type MockTransceiver ¶
type MockTransceiver struct {
// contains filtered or unexported fields
}
func (*MockTransceiver) AddReqRsp ¶
func (transceiver *MockTransceiver) AddReqRsp(reqHexStr string, rspHexStr string)
type MockTransceiverReqRsp ¶
type MockTransceiverReqRsp struct {
// contains filtered or unexported fields
}
type NfcSession ¶
type NfcSession struct { SM *SecureMessaging MaxLe int ApduLog []ApduLog // contains filtered or unexported fields }
func NewNfcSession ¶
func NewNfcSession(transceiver Transceiver) *NfcSession
func (*NfcSession) DoAPDU ¶
func (nfc *NfcSession) DoAPDU(cApdu *CApdu, desc string) (rApdu *RApdu, err error)
func (*NfcSession) ExternalAuthenticate ¶
func (nfc *NfcSession) ExternalAuthenticate(data []byte, le int) (out []byte, err error)
func (*NfcSession) GeneralAuthenticate ¶
func (nfc *NfcSession) GeneralAuthenticate(commandChaining bool, data []byte) *RApdu
func (*NfcSession) GetChallenge ¶
func (nfc *NfcSession) GetChallenge(length int) (out []byte, err error)
func (*NfcSession) MseSetAT ¶
func (nfc *NfcSession) MseSetAT(p1 uint8, p2 uint8, data []byte) (err error)
func (*NfcSession) ReadBinaryFromOffset ¶
func (nfc *NfcSession) ReadBinaryFromOffset(offset int, length int) []byte
NB may not return requested length
func (*NfcSession) ReadFile ¶
func (nfc *NfcSession) ReadFile(fileId uint16) (fileData []byte)
returns: file contents OR nil if file not found
func (*NfcSession) SelectAid ¶
func (nfc *NfcSession) SelectAid(aid []byte) (selected bool, err error)
func (*NfcSession) SelectEF ¶
func (nfc *NfcSession) SelectEF(fileId uint16) (selected bool, err error)
returns: false if file-not-found, otherwise true
func (*NfcSession) SelectMF ¶
func (nfc *NfcSession) SelectMF() (err error)
0 0 0 0 1 0 0 0 – Select from MF (data field=path without the identifier of the MF)
type SecureMessaging ¶
type SecureMessaging struct {
// contains filtered or unexported fields
}
func NewSecureMessaging ¶
func NewSecureMessaging(alg cryptoutils.BlockCipherAlg, ksEnc []byte, ksMac []byte) (sm *SecureMessaging, err error)
func (*SecureMessaging) Decode ¶
func (sm *SecureMessaging) Decode(rApduBytes []byte) (rApdu *RApdu, err error)
func (*SecureMessaging) Encode ¶
func (sm *SecureMessaging) Encode(cApdu *CApdu) (out *CApdu, err error)
func (SecureMessaging) Equal ¶
func (sm1 SecureMessaging) Equal(sm2 SecureMessaging) bool
func (SecureMessaging) GetKsEnc ¶
func (sm SecureMessaging) GetKsEnc() []byte
func (*SecureMessaging) SetSSC ¶
func (sm *SecureMessaging) SetSSC(ssc []byte)
func (SecureMessaging) String ¶
func (sm SecureMessaging) String() string
type StaticTransceiver ¶
type StaticTransceiver struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.