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 ApduLogEntry
- type CApdu
- type MockTransceiver
- type MockTransceiverReqRsp
- type NfcSession
- func (nfc *NfcSession) ApduLog() *ApduLog
- 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) ([]byte, error)
- func (nfc *NfcSession) GetChallenge(length int) (out []byte, err error)
- func (nfc *NfcSession) InternalAuthenticate(data []byte) (out []byte, err error)
- func (nfc *NfcSession) LastApdu() *ApduLogEntry
- func (nfc *NfcSession) MseSetAT(p1 uint8, p2 uint8, data []byte) (err error)
- func (nfc *NfcSession) ReadBinaryFromOffset(offset, length int) ([]byte, error)
- func (nfc *NfcSession) ReadFile(fileId uint16) (fileData []byte, err error)
- func (nfc *NfcSession) SM() SecureMessenger
- 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)
- func (nfc *NfcSession) SetMaxLe(value int)
- func (nfc *NfcSession) SetSecureMessaging(sm SecureMessenger)
- 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) KsEnc() []byte
- func (sm SecureMessaging) SSC() []byte
- func (sm *SecureMessaging) SetSSC(ssc []byte) error
- func (sm SecureMessaging) String() string
- type SecureMessenger
- 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_FUNCTION_NOT_SUPPORTED = 0x6A81
View Source
const RAPDU_STATUS_INCORRECT_P1_OR_P2_PARAMETER = 0x6A86
View Source
const RAPDU_STATUS_LC_INCONSISTENT_WITH_P1P2 = 0x6A87 // Lc inconsistent with P1-P2
View Source
const RAPDU_STATUS_SELECTED_FILE_INVALIDATED = 0x6283 // warning
View Source
const RAPDU_STATUS_SUCCESS = 0x9000
View Source
const READ_FILE_MAX_CHUNKS = 1000
default to 1,000 chunks when reading a file - some older passports support <100 byte reads
View Source
const READ_FILE_MAX_TLV_LENGTH = tlv.TlvLength(65535)
default to 65,535 maximum file (TLV) size - as we always read the first 4 bytes (so max 2 byte length)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApduLog ¶
type ApduLog struct {
Entries []*ApduLogEntry `json:"entries,omitempty"`
}
func NewApduLog ¶
func NewApduLog() *ApduLog
func (*ApduLog) Add ¶ added in v0.19.3
func (l *ApduLog) Add(entry *ApduLogEntry)
func (*ApduLog) AllEntries ¶ added in v0.19.3
func (l *ApduLog) AllEntries() []*ApduLogEntry
type ApduLogEntry ¶ added in v0.19.3
type ApduLogEntry struct {
Desc string `json:"desc,omitempty"`
Tx []byte `json:"tx,omitempty"`
Rx []byte `json:"rx,omitempty"`
Child *ApduLogEntry `json:"child,omitempty"`
DurMs int64 `json:"durMs,omitempty"`
StartTime time.Time `json:"startTime"`
// contains filtered or unexported fields
}
func NewApduLogEntry ¶ added in v0.19.3
func NewApduLogEntry(desc string, tx []byte) *ApduLogEntry
func (*ApduLogEntry) Finalise ¶ added in v0.19.3
func (e *ApduLogEntry) Finalise(rx []byte)
func (*ApduLogEntry) SetChild ¶ added in v0.19.3
func (e *ApduLogEntry) SetChild(child *ApduLogEntry)
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, rspHexStr string)
type MockTransceiverReqRsp ¶
type MockTransceiverReqRsp struct {
// contains filtered or unexported fields
}
type NfcSession ¶
type NfcSession struct {
// contains filtered or unexported fields
}
func NewNfcSession ¶
func NewNfcSession(transceiver Transceiver) *NfcSession
func (*NfcSession) ApduLog ¶
func (nfc *NfcSession) ApduLog() *ApduLog
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) ([]byte, error)
func (*NfcSession) GetChallenge ¶
func (nfc *NfcSession) GetChallenge(length int) (out []byte, err error)
func (*NfcSession) InternalAuthenticate ¶ added in v0.19.3
func (nfc *NfcSession) InternalAuthenticate(data []byte) (out []byte, err error)
func (*NfcSession) LastApdu ¶ added in v0.37.0
func (nfc *NfcSession) LastApdu() *ApduLogEntry
func (*NfcSession) MseSetAT ¶
func (nfc *NfcSession) MseSetAT(p1 uint8, p2 uint8, data []byte) (err error)
func (*NfcSession) ReadBinaryFromOffset ¶
func (nfc *NfcSession) ReadBinaryFromOffset(offset, length int) ([]byte, error)
NB may not return requested length
func (*NfcSession) ReadFile ¶
func (nfc *NfcSession) ReadFile(fileId uint16) (fileData []byte, err error)
returns: file contents OR nil if file not found
func (*NfcSession) SM ¶
func (nfc *NfcSession) SM() SecureMessenger
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)
func (*NfcSession) SetMaxLe ¶ added in v0.19.3
func (nfc *NfcSession) SetMaxLe(value int)
func (*NfcSession) SetSecureMessaging ¶ added in v0.19.3
func (nfc *NfcSession) SetSecureMessaging(sm SecureMessenger)
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) KsEnc ¶ added in v0.13.0
func (sm SecureMessaging) KsEnc() []byte
func (SecureMessaging) SSC ¶ added in v0.19.3
func (sm SecureMessaging) SSC() []byte
func (*SecureMessaging) SetSSC ¶
func (sm *SecureMessaging) SetSSC(ssc []byte) error
func (SecureMessaging) String ¶
func (sm SecureMessaging) String() string
type SecureMessenger ¶ added in v0.19.3
type StaticTransceiver ¶
type StaticTransceiver struct {
RApdu []byte
}
Click to show internal directories.
Click to hide internal directories.