gmrtd

package module
v0.0.0-...-8267baa Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 30 Imported by: 0

README

Go Report Card codebeat badge Coverage Lines of Code Security Rating Maintainability Rating Reliability Rating Vulnerabilities Code Smells Technical Debt

gmrtd

GO library for reading Machine Readable Travel Documents (MRTDs), such as Passports and Identity Cards.

Documentation

Index

Constants

View Source
const CLA_MASK byte = 0x0C
View Source
const COMTag = 0x60
View Source
const DES_BLOCK_SIZE_BYTES = 8
View Source
const DG11Tag = 0x6B
View Source
const DG12Tag = 0x6C
View Source
const DG13Tag = 0x6D
View Source
const DG14Tag = 0x6E
View Source
const DG15Tag = 0x6F
View Source
const DG16Tag = 0x70
View Source
const DG1Tag = 0x61
View Source
const DG2Tag = 0x75
View Source
const DG7Tag = 0x67
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_READ_BINARY = byte(0xB0)
View Source
const INS_SELECT = byte(0xA4)
View Source
const MRTDFileIdCardAccess = 0x011C

TODO - look at moving to short-file id if that is actually the mandatory one

View Source
const MRTDFileIdCardSecurity = 0x011D
View Source
const MRTDFileIdDG1 = 0x0101
View Source
const MRTDFileIdDG11 = 0x010B
View Source
const MRTDFileIdDG12 = 0x010C
View Source
const MRTDFileIdDG13 = 0x010D
View Source
const MRTDFileIdDG14 = 0x010E
View Source
const MRTDFileIdDG15 = 0x010F
View Source
const MRTDFileIdDG16 = 0x0110
View Source
const MRTDFileIdDG2 = 0x0102
View Source
const MRTDFileIdDG7 = 0x0107
View Source
const MRTDFileIdEFCOM = 0x011E
View Source
const MRTDFileIdEFDIR = 0x2F00
View Source
const MRTDFileIdEFSOD = 0x011D
View Source
const MRTD_AID = "A0000002471001"
View Source
const MRZLengthTD1 = 90
View Source
const MRZLengthTD2 = 72
View Source
const MRZLengthTD3 = 88
View Source
const RAPDU_STATUS_FILENOTFOUND = 0x6A82
View Source
const RAPDU_STATUS_SUCCESS = 0x9000
View Source
const SODTag = 0x77

Variables

This section is empty.

Functions

func BytesToHex

func BytesToHex(bytes []byte) string

func CryptCBC

func CryptCBC(blockCipher cipher.Block, iv []byte, data []byte, encrypt bool) []byte

func CryptoHash

func CryptoHash(alg crypto.Hash, data []byte) []byte

func CryptoHashByOid

func CryptoHashByOid(oid asn1.ObjectIdentifier, data []byte) []byte

hashes the data using the hash algorithm specified by oid panics if hash algorithm is not supported

func DecodeAsn1objectId

func DecodeAsn1objectId(data []byte) string

func DesKeyAdjustParity

func DesKeyAdjustParity(key []byte) []byte

func GetCipherForKey

func GetCipherForKey(alg BlockCipherAlg, key []byte) (cipher.Block, error)

TODO - maybe this should panic.. as this should only be caused by a code issue NB supports 8/16/24 byte key lengths for DES

func HexToBytes

func HexToBytes(str string) []byte

func ISO9797Method2Pad

func ISO9797Method2Pad(data []byte, blockSize int) []byte

func ISO9797Method2Unpad

func ISO9797Method2Unpad(data []byte) []byte

panics if data is not padded

func ISO9797RetailMacDes

func ISO9797RetailMacDes(key []byte, data []byte) (mac []byte, err error)

ISO-9797 Retail MAC (DES) key: 16 bytes (double) DES key error: if invalid key length (not 16 bytes) or data not aligned to block boundary (8 bytes)

func KDF

func KDF(k []byte, c KDFCounterType, alg BlockCipherAlg, keySizeBits int) []byte

NB expects keySizeBits=112 for TDES

func MrtdPassiveAuth

func MrtdPassiveAuth(doc *Document)

func PrintableBytes

func PrintableBytes(data []byte) bool

func RandomBytes

func RandomBytes(length int) []byte

func TlvEncodeLength

func TlvEncodeLength(length int) []byte

func TlvEncodeTag

func TlvEncodeTag(tag TlvTag) []byte

func TlvGetLength

func TlvGetLength(buf *bytes.Buffer) (length int)

func TlvIsConstructedTag

func TlvIsConstructedTag(tag TlvTag) bool

func WriteFile

func WriteFile(filename string, data []byte)

Types

type ActiveAuthenticationInfo

type ActiveAuthenticationInfo struct {
	Protocol           asn1.ObjectIdentifier
	Version            int
	SignatureAlgorithm asn1.ObjectIdentifier
}

type AlgorithmIdentifier

type AlgorithmIdentifier struct {
	Algorithm  asn1.ObjectIdentifier
	Parameters int `asn1:"optional"` // TODO - spec technically says ANY type
}

type Attribute

type Attribute struct {
	Type   asn1.ObjectIdentifier
	Values asn1.RawValue
}

type AttributeList

type AttributeList []Attribute

type BAC

type BAC struct {
	// contains filtered or unexported fields
}

func NewBAC

func NewBAC() *BAC

type BiometricDataBlock

type BiometricDataBlock struct {
	Facial Facial
}

type BiometricHeaderTemplate

type BiometricHeaderTemplate struct {
	IcaoHeaderVersion []byte // optional
	BiometricType     []byte // optional
	BiometricSubType  []byte // optional (for DG2)
	CreationDateTime  []byte // optional
	ValidityPeriod    []byte // optional
	PID               []byte // optional
	FormatOwner       []byte // required
	FormatType        []byte // required
}

type BiometricInfoTemplate

type BiometricInfoTemplate struct {
	BHT BiometricHeaderTemplate
	BDB BiometricDataBlock
}

type BlockCipherAlg

type BlockCipherAlg int
const (
	DES BlockCipherAlg = iota
	TDES
	AES
)

type CApdu

type CApdu struct {
	// contains filtered or unexported fields
}

func NewCApdu

func NewCApdu(cla byte, ins byte, p1 byte, p2 byte, data []byte, le int) *CApdu

func (*CApdu) Encode

func (apdu *CApdu) Encode() []byte

func (*CApdu) EncodeHeader

func (apdu *CApdu) EncodeHeader() []byte

func (*CApdu) EncodeLc

func (apdu *CApdu) EncodeLc() []byte

func (*CApdu) EncodeLe

func (apdu *CApdu) EncodeLe() []byte

func (*CApdu) HaveData

func (apdu *CApdu) HaveData() bool

func (*CApdu) HaveLe

func (apdu *CApdu) HaveLe() bool

func (*CApdu) IsExtended

func (apdu *CApdu) IsExtended() bool

func (CApdu) String

func (cApdu CApdu) String() string

type COM

type COM struct {
	RawData        []byte
	LdsVersion     string
	UnicodeVersion string
	TagList        []TlvTag
}

func NewCOM

func NewCOM(data []byte) (*COM, error)

type CardAccess

type CardAccess struct {
	RawData       []byte
	SecurityInfos *SecurityInfos
}

func NewCardAccess

func NewCardAccess(data []byte) (*CardAccess, error)

type CardSecurity

type CardSecurity struct {
	RawData       []byte
	SecurityInfos *SecurityInfos
}

func NewCardSecurity

func NewCardSecurity(data []byte) (out *CardSecurity, err error)

type ChipAuthStatus

type ChipAuthStatus int
const (
	CHIP_AUTH_STATUS_NA ChipAuthStatus = iota
	CHIP_AUTH_STATUS_PACE_CAM
	CHIP_AUTH_STATUS_CA
	CHIP_AUTH_STATUS_AA
)

type ChipAuthenticationInfo

type ChipAuthenticationInfo struct {
	Protocol asn1.ObjectIdentifier
	Version  int
	KeyId    int `asn1:"optional"`
}

type ChipAuthenticationPublicKeyInfo

type ChipAuthenticationPublicKeyInfo struct {
	Protocol                    asn1.ObjectIdentifier
	ChipAuthenticationPublicKey SubjectPublicKeyInfo
	KeyId                       int `asn1:"optional"`
}

type DG1

type DG1 struct {
	RawData []byte
	Mrz     *MRZ
}

func NewDG1

func NewDG1(data []byte) (dg1 *DG1, err error)

type DG11

type DG11 struct {
	RawData []byte
}

func NewDG11

func NewDG11(data []byte) (*DG11, error)

type DG12

type DG12 struct {
	RawData []byte
}

func NewDG12

func NewDG12(data []byte) (*DG12, error)

type DG13

type DG13 struct {
	RawData []byte
}

func NewDG13

func NewDG13(data []byte) (*DG13, error)

type DG14

type DG14 struct {
	RawData  []byte // TODO - add to test cases (for all other DGs also)
	SecInfos *SecurityInfos
}

func NewDG14

func NewDG14(data []byte) (dg14 *DG14, err error)

type DG15

type DG15 struct {
	RawData []byte
}

func NewDG15

func NewDG15(data []byte) (*DG15, error)

type DG16

type DG16 struct {
	RawData []byte
}

func NewDG16

func NewDG16(data []byte) (*DG16, error)

type DG2

type DG2 struct {
	RawData []byte
	BITs    []BiometricInfoTemplate
}

func NewDG2

func NewDG2(data []byte) (*DG2, error)

type DG7

type DG7 struct {
	RawData []byte
	Images  []DG7Image
}

func NewDG7

func NewDG7(data []byte) (*DG7, error)

type DG7Image

type DG7Image struct {
	Image []byte
}

type DataGroupHash

type DataGroupHash struct {
	DataGroupNumber    int    ``
	DataGroupHashValue []byte ``
}

type Document

type Document struct {
	CardAccess     *CardAccess
	CardSecurity   *CardSecurity // NB only read for PACE-CAM - read during PACE flow
	Dir            *EFDIR        // indicates which applications are present - generally not acvailable
	Com            *COM          // largely deprecated by SOD, but used to determine Lds/Unicode Version if older SOD formatis present
	Sod            *SOD          // Document Security Object EF.SOD (MANDATORY)
	Dg1            *DG1          // DATA GROUP 1 — Machine Readable Zone Information (MANDATORY)
	Dg2            *DG2          // DATA GROUP 2 — Encoded Identification Features — Face (MANDATORY)
	Dg7            *DG7          // DATA GROUP 7 — Displayed Signature or Usual Mark (OPTIONAL)
	Dg11           *DG11         // DATA GROUP 11 — Additional Personal Detail(s) (OPTIONAL)
	Dg12           *DG12         // DATA GROUP 12 — Additional Document Detail(s) (OPTIONAL)
	Dg13           *DG13         // DATA GROUP 13 — Optional Details(s) (OPTIONAL)
	Dg14           *DG14         // DATA GROUP 14 — Security Options (CONDITIONAL)
	Dg15           *DG15         // DATA GROUP 15 — Active Authentication Public Key Info (CONDITIONAL)
	Dg16           *DG16         // DATA GROUP 16 — Person(s) to Notify (OPTIONAL)
	ChipAuthStatus ChipAuthStatus
}

func ReadDocument

func ReadDocument(transceiver Transceiver, password *Password) (doc *Document, err error)

NB returns partial data (MrtdDocument) in the event of an error

func (Document) LdsVersion

func (doc Document) LdsVersion() string

gets the LDS Version (e.g. '0108') from EF.SOD or EF.COM returns empty string if valid cannot be determined

func (*Document) NewDG

func (doc *Document) NewDG(dg int, data []byte) (err error)

func (Document) UnicodeVersion

func (doc Document) UnicodeVersion() string

gets the Unicode Version (e.g. '040000') from EF.SOD or EF.COM returns empty string if valid cannot be determined

type EC_POINT

type EC_POINT struct {
	// contains filtered or unexported fields
}

func KeyGeneratorEc

func KeyGeneratorEc(ec elliptic.Curve) (pri []byte, pub *EC_POINT)

func (EC_POINT) String

func (ec EC_POINT) String() string

type EFDIR

type EFDIR struct {
	RawData     []byte
	Application []EfDirApplication
}

func NewEFDIR

func NewEFDIR(data []byte) *EFDIR

type EFDirInfo

type EFDirInfo struct {
	Protocol asn1.ObjectIdentifier
	EFDir    []byte
}

type EfDirApplication

type EfDirApplication struct {
	// contains filtered or unexported fields
}

type EncapContentInfo

type EncapContentInfo struct {
	EContentType asn1.ObjectIdentifier ``
	EContent     []byte                `asn1:"explicit,tag:0"` // contains LDSSecurityObject
}

type Facial

type Facial struct {
	Header FacialHeader
	Images []Image
}

type FacialFeature

type FacialFeature struct {
	Type       uint8
	MajorPoint uint8
	MinorPoint uint8
	X          uint16
	Y          uint16
	Reserved   uint8
}

type FacialHeader

type FacialHeader struct {
	FormatID      [4]byte
	VersionID     [4]byte
	RecordLength  uint32
	NumberOfFaces uint16
}

type FacialInfo

type FacialInfo struct {
	Length          uint32
	NumberOfPoints  uint16
	Gender          uint8
	EyeColor        uint8
	HairColor       uint8
	Properties      [3]byte
	Expression      [2]byte
	Pose            [3]byte
	PoseUncertainty [3]byte
}

type Image

type Image struct {
	FacialInformation FacialInfo
	Features          []FacialFeature
	ImageInformation  ImageInfo
	Data              []byte
}

type ImageInfo

type ImageInfo struct {
	Type       uint8
	DataType   uint8
	Width      uint16
	Height     uint16
	ColorSpace uint8
	SourceType uint8
	DeviceType uint16
	Quality    uint16
}

type IssuerAndSerial

type IssuerAndSerial struct {
	IssuerName   asn1.RawValue
	SerialNumber *big.Int
}

type KDFCounterType

type KDFCounterType int
const (
	KDF_COUNTER_KSENC KDFCounterType = 1
	KDF_COUNTER_KSMAC KDFCounterType = 2
	KDF_COUNTER_PACE  KDFCounterType = 3
)

type KeyGeneratorEcFn

type KeyGeneratorEcFn func(ec elliptic.Curve) (pri []byte, pub *EC_POINT)

type LDSSecurityObject

type LDSSecurityObject struct {
	Version             int                      ``
	HashAlgorithm       pkix.AlgorithmIdentifier ``
	DataGroupHashValues []DataGroupHash          ``
	LdsVersionInfo      LDSVersionInfo           `asn1:"optional"`
}

type LDSVersionInfo

type LDSVersionInfo struct {
	LdsVersion     string ``
	UnicodeVersion string ``
}

TODO - present but empty strings if not present in parsed data

type MRZ

type MRZ struct {
	DocumentCode   string
	IssuingState   string
	NameOfHolder   string
	DocumentNumber string
	Nationality    string
	DateOfBirth    string
	Sex            string
	DateOfExpiry   string
	OptionalData   string
	OptionalData2  string // TODO - just required for TD1?.. should this be considered as a single logical field?
}

func MrzDecode

func MrzDecode(mrz string) (*MRZ, error)

func (*MRZ) EncodeMrzi

func (mrz *MRZ) EncodeMrzi() string

type MockTransceiver

type MockTransceiver struct {
	// contains filtered or unexported fields
}

func (*MockTransceiver) AddReqRsp

func (transceiver *MockTransceiver) AddReqRsp(reqHexStr string, rspHexStr string)

func (*MockTransceiver) Transceive

func (transceiver *MockTransceiver) Transceive(capdu []byte) []byte

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) DoAPDU

func (nfc *NfcSession) DoAPDU(capdu *CApdu) (rapdu *RApdu, err error)

func (*NfcSession) ExternalAuthenticate

func (nfc *NfcSession) ExternalAuthenticate(data []byte, le int) (out []byte, err error)

func (*NfcSession) GetChallenge

func (nfc *NfcSession) GetChallenge(length int) (out []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 int) (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 int) (selected bool, err error)

returns: false if file-not-found, otherwise true

func (*NfcSession) SelectMF

func (nfc *NfcSession) SelectMF() (err error)

TODO - why not just try to directly select file from MF?

0 0 0 0 1 0 0 0	– Select from MF (data field=path without the identifier of the MF)

type PACEAuthToken

type PACEAuthToken int
const (
	CBC PACEAuthToken = iota
	CMAC
)

type PACEDomainParams

type PACEDomainParams struct {
	// contains filtered or unexported fields
}

type PACEMapping

type PACEMapping int
const (
	GM PACEMapping = iota
	IM
	CAM
)

type PACESeccureMessaging

type PACESeccureMessaging int
const (
	CBC_CBC PACESeccureMessaging = iota
	CBC_CMAC
)

TODO - is this even used in the code anywhere?... MAC code seems to just infer from cipher-alg... should allow this to be passed in?

type Pace

type Pace struct {
	// contains filtered or unexported fields
}

func NewPace

func NewPace() *Pace

type PaceConfig

type PaceConfig struct {
	// contains filtered or unexported fields
}

type PaceDomainParameterInfo

type PaceDomainParameterInfo struct {
	Protocol        asn1.ObjectIdentifier
	DomainParameter AlgorithmIdentifier
	ParameterId     int `asn1:"optional"`
}

type PaceInfo

type PaceInfo struct {
	Protocol    asn1.ObjectIdentifier
	Version     int
	ParameterId int `asn1:"optional"`
}

type Password

type Password struct {
	// contains filtered or unexported fields
}

func NewPasswordCan

func NewPasswordCan(can string) *Password

func NewPasswordMrz

func NewPasswordMrz(mrzStr string) (pass *Password, err error)

func NewPasswordMrzi

func NewPasswordMrzi(documentNo string, dateOfBirth string, dateOfExpiry string) *Password

type PasswordType

type PasswordType int
const (
	PASSWORD_TYPE_MRZi PasswordType = iota
	PASSWORD_TYPE_CAN
)

type RApdu

type RApdu struct {
	Data   []byte
	Status uint16
}

func GeneralAuthenticate

func GeneralAuthenticate(nfc *NfcSession, commandChaining bool, data []byte) *RApdu

func NewRApdu

func NewRApdu(status uint16, data []byte) *RApdu

func ParseRApdu

func ParseRApdu(data []byte) (rapdu *RApdu, err error)

func (*RApdu) FileNotFound

func (apdu *RApdu) FileNotFound() bool

func (*RApdu) IsSuccess

func (apdu *RApdu) IsSuccess() bool

func (*RApdu) String

func (apdu *RApdu) String() string

type RandomBytesFn

type RandomBytesFn func(length int) []byte

type SOD

type SOD struct {
	RawData []byte
	// nodes   *TlvNodes
	LdsSecurityObject *LDSSecurityObject
}

func NewSOD

func NewSOD(data []byte) (*SOD, error)

type SecureMessaging

type SecureMessaging struct {
	KSenc []byte
	KSmac []byte
	SSC   []byte
	// contains filtered or unexported fields
}

func NewSecureMessaging

func NewSecureMessaging(alg 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, maxLe uint64) (out *CApdu, err error)

func (*SecureMessaging) SetSSC

func (sm *SecureMessaging) SetSSC(ssc []byte)

func (SecureMessaging) String

func (sm SecureMessaging) String() string

type SecurityInfoOid

type SecurityInfoOid struct {
	Raw      asn1.RawContent
	Protocol asn1.ObjectIdentifier `asn1:""`
}

type SecurityInfoOidSET

type SecurityInfoOidSET []SecurityInfoOid

type SecurityInfos

type SecurityInfos struct {
	PaceInfos            []PaceInfo
	PaceDomainParamInfos []PaceDomainParameterInfo
	ActiveAuthInfos      []ActiveAuthenticationInfo
	ChipAuthInfos        []ChipAuthenticationInfo
	ChipAuthPubKeyInfos  []ChipAuthenticationPublicKeyInfo
	TermAuthInfos        []TerminalAuthenticationInfo
	EfDirInfos           []EFDirInfo
	UnhandledInfos       []UnhandledInfo
	TotalCnt             int
}

func DecodeSecurityInfos

func DecodeSecurityInfos(secInfoData []byte) (secInfos *SecurityInfos, err error)

TODO - currently fails if anything wrong... maybe we should be more tolerant, but record issues?

type SignedData

type SignedData struct {
	Oid asn1.ObjectIdentifier ``
	SD2 SignedData2           `asn1:"explicit,tag:0"` // TODO - naming?
}

TODO - maybe handle this internally

type SignedData2

type SignedData2 struct {
	Version          int
	DigestAlgorithms []pkix.AlgorithmIdentifier `asn1:"set"`
	Content          EncapContentInfo           ``
	Certificates     []asn1.RawValue            `asn1:"optional,set,tag:0"`
	CRLs             []asn1.RawValue            `asn1:"optional,set,tag:1"`
	SignerInfos      []SignerInfo               `asn1:"set"`
}

type SignerInfo

type SignerInfo struct {
	Version                   int                      `asn1:"default:1"`
	IssuerAndSerialNumber     IssuerAndSerial          ``
	DigestAlgorithm           pkix.AlgorithmIdentifier ``
	AuthenticatedAttributes   AttributeList            `asn1:"optional,tag:0"`
	DigestEncryptionAlgorithm pkix.AlgorithmIdentifier ``
	EncryptedDigest           []byte                   ``
	UnauthenticatedAttributes AttributeList            `asn1:"optional,tag:1"`
}

type StaticTransceiver

type StaticTransceiver struct {
	// contains filtered or unexported fields
}

func (*StaticTransceiver) Transceive

func (transceiver *StaticTransceiver) Transceive(capdu []byte) []byte

type SubjectPublicKeyInfo

type SubjectPublicKeyInfo struct {
	Algorithm        AlgorithmIdentifier
	SubjectPublicKey asn1.BitString
}

type TerminalAuthenticationInfo

type TerminalAuthenticationInfo struct {
	Protocol asn1.ObjectIdentifier
	Version  int
}

type TlvConstructedNode

type TlvConstructedNode struct {
	Tag      TlvTag
	Children TlvNodes
}

func NewTlvConstructedNode

func NewTlvConstructedNode(tag TlvTag) *TlvConstructedNode

func (*TlvConstructedNode) AddChild

func (tlv *TlvConstructedNode) AddChild(child TlvNode)

func (TlvConstructedNode) Encode

func (node TlvConstructedNode) Encode() []byte

func (TlvConstructedNode) GetNode

func (node TlvConstructedNode) GetNode(tag TlvTag) TlvNode

func (TlvConstructedNode) GetNodeByOccur

func (node TlvConstructedNode) GetNodeByOccur(tag TlvTag, occurrence int) TlvNode

func (TlvConstructedNode) GetTag

func (node TlvConstructedNode) GetTag() TlvTag

func (TlvConstructedNode) GetValue

func (node TlvConstructedNode) GetValue() []byte

func (TlvConstructedNode) IsValidNode

func (node TlvConstructedNode) IsValidNode() bool

func (TlvConstructedNode) String

func (node TlvConstructedNode) String() string

type TlvNilNode

type TlvNilNode struct{}

func NewTlvNilNode

func NewTlvNilNode() *TlvNilNode

func (TlvNilNode) Encode

func (node TlvNilNode) Encode() []byte

func (TlvNilNode) GetNode

func (node TlvNilNode) GetNode(tag TlvTag) TlvNode

func (TlvNilNode) GetNodeByOccur

func (node TlvNilNode) GetNodeByOccur(tag TlvTag, occurrence int) TlvNode

func (TlvNilNode) GetTag

func (node TlvNilNode) GetTag() TlvTag

func (TlvNilNode) GetValue

func (node TlvNilNode) GetValue() []byte

func (TlvNilNode) IsValidNode

func (node TlvNilNode) IsValidNode() bool

func (TlvNilNode) String

func (node TlvNilNode) String() string

type TlvNode

type TlvNode interface {
	IsValidNode() bool
	GetTag() TlvTag
	GetValue() []byte
	GetNode(tag TlvTag) TlvNode
	GetNodeByOccur(tag TlvTag, occurrence int) TlvNode
	Encode() []byte
	String() string
	// contains filtered or unexported methods
}

type TlvNodes

type TlvNodes struct {
	Nodes []TlvNode
}

func NewTlvNodes

func NewTlvNodes() *TlvNodes

func TlvDecode

func TlvDecode(data []byte) *TlvNodes

func (*TlvNodes) AddNode

func (nodes *TlvNodes) AddNode(node TlvNode)

func (TlvNodes) Encode

func (nodes TlvNodes) Encode() []byte

func (TlvNodes) GetNode

func (nodes TlvNodes) GetNode(tag TlvTag) TlvNode

func (TlvNodes) GetNodeByOccur

func (nodes TlvNodes) GetNodeByOccur(tag TlvTag, occurrence int) TlvNode

occurrence: 1-n

func (TlvNodes) IsValidNode

func (node TlvNodes) IsValidNode() bool

func (TlvNodes) String

func (nodes TlvNodes) String() string

type TlvSimpleNode

type TlvSimpleNode struct {
	Tag   TlvTag
	Value []byte
}

func NewTlvSimpleNode

func NewTlvSimpleNode(tag TlvTag, value []byte) *TlvSimpleNode

func (TlvSimpleNode) Encode

func (node TlvSimpleNode) Encode() []byte

func (TlvSimpleNode) GetNode

func (node TlvSimpleNode) GetNode(tag TlvTag) TlvNode

func (TlvSimpleNode) GetNodeByOccur

func (node TlvSimpleNode) GetNodeByOccur(tag TlvTag, occurrence int) TlvNode

func (TlvSimpleNode) GetTag

func (node TlvSimpleNode) GetTag() TlvTag

func (TlvSimpleNode) GetValue

func (node TlvSimpleNode) GetValue() []byte

func (TlvSimpleNode) IsValidNode

func (node TlvSimpleNode) IsValidNode() bool

func (TlvSimpleNode) String

func (node TlvSimpleNode) String() string

type TlvTag

type TlvTag int

func TlvGetTag

func TlvGetTag(buf *bytes.Buffer) TlvTag

type Transceiver

type Transceiver interface {
	Transceive(capdu []byte) []byte
}

type UnhandledInfo

type UnhandledInfo struct {
	Protocol asn1.ObjectIdentifier
	RawData  []byte
}

Jump to

Keyboard shortcuts

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