apdu

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package apdu is a generated GoMock package.

Index

Constants

View Source
const (
	NoSMOrNoIndication                  = "No SM or no indication"
	ProprietarySMFormat                 = "Proprietary SM format"
	SMAccordingToSection6_NotProcessed  = "SM according to section 6, command header not processed according to 6.2.3.1"
	SMAccordingToSection6_Authenticated = "SM according to section 6, command header authenticated according to 6.2.3.1"
)

Variables

This section is empty.

Functions

func IsTrailerError

func IsTrailerError(err error, val TrailerError) bool

Types

type AFL

type AFL []byte

func (AFL) GetEntries

func (afl AFL) GetEntries() ([]AFLEntry, error)

func (AFL) GoString

func (afl AFL) GoString() string

type AFLEntry

type AFLEntry struct {
	SFI               int
	FirstRecord       int
	LastRecord        int
	RecordsInDataAuth int
}

type AIP added in v0.0.3

type AIP []byte

type ApplicationCryptogramType

type ApplicationCryptogramType byte

type ApplicationTemplate

type ApplicationTemplate struct {
	ID                []byte  `tlv:"4F"`
	Label             *string `tlv:"50"`
	PriorityIndicator *int    `tlv:"87"`
	PreferredName     *string `tlv:"9F12"`
}

type CVMList

type CVMList struct {
	Amount       int
	SecondAmount int
	CVRules      []CVRule
}

func (*CVMList) Unmarshal

func (l *CVMList) Unmarshal(data []byte) error

type CVRule

type CVRule struct {
	CVMCode       byte
	ConditionCode byte
}

func (CVRule) ConditionString

func (cv CVRule) ConditionString(amount1, amount2 int) string

func (CVRule) Description

func (cv CVRule) Description() string

func (CVRule) FailIfUncessful

func (cv CVRule) FailIfUncessful() bool

type Class

type Class byte

func (Class) Invalid

func (c Class) Invalid() bool

func (Class) LastInChain

func (c Class) LastInChain() bool

func (Class) Proprietary

func (c Class) Proprietary() bool

type Client

type Client struct {
	RawClient
	LowLevelCommands LowLevelCommands
	HighLevelCommands
}

func NewClient

func NewClient(driver Driver) Client

type Command

type Command struct {
	Class            Class
	Instruction      Instruction
	Parameters       Parameters
	Data             []byte
	MaxReponseLength byte
}

func (Command) Bytes

func (c Command) Bytes(enc tlv.LengthEncoder) ([]byte, error)

func (Command) String

func (c Command) String() string

func (Command) StringPretty

func (c Command) StringPretty() string

type CryptogramInformationData added in v0.0.4

type CryptogramInformationData byte

func (CryptogramInformationData) AAC added in v0.0.4

func (cid CryptogramInformationData) AAC() bool

func (CryptogramInformationData) ARQC added in v0.0.4

func (cid CryptogramInformationData) ARQC() bool

func (CryptogramInformationData) RFU added in v0.0.4

func (cid CryptogramInformationData) RFU() bool

func (CryptogramInformationData) String added in v0.0.4

func (cid CryptogramInformationData) String() string

func (CryptogramInformationData) TC added in v0.0.4

type Driver

type Driver interface {
	SendBytes(bytes []byte) ([]byte, error)
}

type EMVProprietaryTemplate

type EMVProprietaryTemplate struct {
	ApplicationTemplates []ApplicationTemplate `tlv:"61"`

	Track1DiscretionaryData    string  `tlv:"9f1f"`
	Track2EquivalentData       []byte  `tlv:"57"`
	CardholderName             string  `tlv:"5f20"`
	PAN                        string  `tlv:"5a,hex"`
	PANSequenceNumber          string  `tlv:"5f34,hex"`
	ExpirationDate             string  `tlv:"5f24,hex"`
	UsageControl               string  `tlv:"9f07,hex"`
	IssuerCountryCode          string  `tlv:"5f28,hex"`
	EffectiveDate              string  `tlv:"5f25,hex"`
	ServiceCode                string  `tlv:"5f30,hex"`
	IssuerActionCodeDenial     string  `tlv:"9f0e,hex"`
	IssuerActionCodeOnline     string  `tlv:"9f0f,hex"`
	IssuerActionCodeDefault    string  `tlv:"9f0d,hex"`
	CAPublicKeyIndex1          string  `tlv:"8f,hex"`
	IssuerPublicKeyExponent    string  `tlv:"9f32,hex"`
	IssuerPublicKeyCertificate string  `tlv:"90,hex"`
	CurrencyCode               string  `tlv:"9f42,hex"`
	CurrencyExponent           string  `tlv:"9f44,hex"`
	CDOL1                      tlv.TL  `tlv:"8c"`
	CDOL1Hex                   string  `tlv:"8c,hex"`
	CDOL2                      tlv.TL  `tlv:"8d,hex"`
	CDOL2Hex                   string  `tlv:"8d,hex"`
	VersionNumber1             string  `tlv:"9f08,hex"`
	ICCPublicKeyCertificate    string  `tlv:"9f46,hex"`
	ICCPublicKeyExponent       string  `tlv:"9f47,hex"`
	DDOL                       string  `tlv:"9f49,hex"`
	CVMList                    CVMList `tlv:"8e"`
	CVMListBytes               []byte  `tlv:"8e"`

	UnknownTag9F69 []byte  `tlv:"9f69"`
	RawTLV         tlv.TLV `tlv:"raw"`
}

func (EMVProprietaryTemplate) Merge

type FCITemplate

type FCITemplate struct {
	DFName                 *string                 `tlv:"84,hex"`
	ProprietaryInformation *ProprietaryFCITemplate `tlv:"A5"`

	RawA5 string `tlv:"A5,hex"`
}

type FileControlInformation

type FileControlInformation struct {
	FCPTemplate []byte       `tlv:"62"`
	FMDTemplate []byte       `tlv:"64"`
	FCITemplate *FCITemplate `tlv:"6F"`

	Raw6F string `tlv:"6F,hex"`
}

type GenerateACResponse

type GenerateACResponse struct {
	Format1 GenerateACResponseFormat1 `tlv:"80"`
	Format2 struct {
		CryptogramInformationData     CryptogramInformationData `tlv:"9f27"`
		ApplicationTransactionCounter string                    `tlv:"9f36,hex"`
		ApplicationCryptogram         string                    `tlv:"9f26,hex"`
		IssuerApplicationData         []byte                    `tlv:"9f10,hex"`
		SignedDynamicApplicationData  string                    `tlv:"9f4b,hex"`
		Raw                           tlv.TLV                   `tlv:"raw"`
	} `tlv:"77"`
	Raw tlv.TLV `tlv:"raw"`
}

func (GenerateACResponse) ApplicationCryptogram added in v0.0.4

func (resp GenerateACResponse) ApplicationCryptogram() string

func (GenerateACResponse) ApplicationTransactionCounter added in v0.0.4

func (resp GenerateACResponse) ApplicationTransactionCounter() string

func (GenerateACResponse) CryptogramInformationData added in v0.0.4

func (resp GenerateACResponse) CryptogramInformationData() CryptogramInformationData

func (GenerateACResponse) Format added in v0.0.5

func (resp GenerateACResponse) Format() (int, error)

func (GenerateACResponse) IssuerApplicationData added in v0.0.4

func (resp GenerateACResponse) IssuerApplicationData() []byte

type GenerateACResponseFormat1 added in v0.0.4

type GenerateACResponseFormat1 []byte

func (GenerateACResponseFormat1) ApplicationCryptogram added in v0.0.4

func (f1 GenerateACResponseFormat1) ApplicationCryptogram() string

func (GenerateACResponseFormat1) ApplicationTransactionCounter added in v0.0.4

func (f1 GenerateACResponseFormat1) ApplicationTransactionCounter() string

func (GenerateACResponseFormat1) CryptogramInformationData added in v0.0.4

func (f1 GenerateACResponseFormat1) CryptogramInformationData() CryptogramInformationData

func (GenerateACResponseFormat1) IssuerApplicationData added in v0.0.4

func (f1 GenerateACResponseFormat1) IssuerApplicationData() []byte

type GetProcessingOptionsResponse added in v0.0.3

type GetProcessingOptionsResponse struct {
	Format1 []byte                               `tlv:"80"`
	Format2 *GetProcessingOptionsResponseFormat2 `tlv:"77"`
}

func (GetProcessingOptionsResponse) FileLocator added in v0.0.3

func (resp GetProcessingOptionsResponse) FileLocator() AFL

func (GetProcessingOptionsResponse) InterchangeProfile added in v0.0.3

func (resp GetProcessingOptionsResponse) InterchangeProfile() AIP

type GetProcessingOptionsResponseFormat2 added in v0.0.3

type GetProcessingOptionsResponseFormat2 struct {
	InterchangeProfile AIP `tlv:"82"`
	FileLocator        AFL `tlv:"94"`
}

type HighLevelCommands

type HighLevelCommands interface {
	SelectByName(dfname []byte) (FileControlInformation, error)
	ReadRecord(sfi, recordNumber int) (RecordTemplate, error)

	// ReadAllRecords tries to read the records of a file starting from record 1. When a
	// status 6A83 (Record Not Found) is returned, it considers that the sequence ended
	// and returns the previous records returned.
	ReadAllRecords(sfi int) ([]RecordTemplate, error)
	GetPSE(contactless bool) ([]RecordTemplate, error)
	GetProcessingOptions(pdolData []byte) (GetProcessingOptionsResponse, error)
	GenerateARQC(cdolData []byte) (GenerateACResponse, error)
	GenerateTC(transactionData []byte) (GenerateACResponse, error)
}

type Instruction

type Instruction byte
const (
	Instruction44_ActivateFile                   Instruction = 0x44
	InstructionE2_AppendRecord                   Instruction = 0xE2
	Instruction24_ChangeReferenceData            Instruction = 0x24
	InstructionE0_CreateFile                     Instruction = 0xE0
	Instruction04_DeactivateFile                 Instruction = 0x04
	InstructionE4_DeleteFile                     Instruction = 0xE4
	Instruction26_DisableVerificationRequirement Instruction = 0x26
	Instruction28_EnableVerificationRequirement  Instruction = 0x28
	InstructionC2_Envelope                       Instruction = 0xC2
	InstructionC3_Envelope                       Instruction = 0xC3
	Instruction0E_EraseBinary                    Instruction = 0x0E
	Instruction0F_EraseBinary                    Instruction = 0x0F
	Instruction0C_EraseRecords                   Instruction = 0x0C
	Instruction82_ExternalMutualAuthenticate     Instruction = 0x82
	Instruction86_GeneralAuthenticate            Instruction = 0x86
	Instruction87_GeneralAuthenticate            Instruction = 0x87
	Instruction46_GenerateAsymmetricKeyPair      Instruction = 0x46
	Instruction84_GetChallenge                   Instruction = 0x84
	InstructionCA_GetData                        Instruction = 0xCA
	InstructionCB_GetData                        Instruction = 0xCB
	InstructionC0_GetResponse                    Instruction = 0xC0
	Instruction88_InternalAuthenticate           Instruction = 0x88
	Instruction70_ManageChannel                  Instruction = 0x70
	Instruction22_ManageSecurityEnvironment      Instruction = 0x22
	Instruction10_PerformScqlOperation           Instruction = 0x10
	Instruction2A_PerformSecurityOperation       Instruction = 0x2A
	Instruction12_PerformTransactionOperation    Instruction = 0x12
	Instruction14_PerformUserOperation           Instruction = 0x14
	InstructionDA_PutData                        Instruction = 0xDA
	InstructionDB_PutData                        Instruction = 0xDB
	InstructionB0_ReadBinary                     Instruction = 0xB0
	InstructionB1_ReadBinary                     Instruction = 0xB1
	InstructionB2_ReadRecords                    Instruction = 0xB2
	InstructionB3_ReadRecords                    Instruction = 0xB3
	Instruction2C_ResetRetryCounter              Instruction = 0x2C
	InstructionA0_SearchBinary                   Instruction = 0xA0
	InstructionA1_SearchBinary                   Instruction = 0xA1
	InstructionA2_SearchRecord                   Instruction = 0xA2
	InstructionA4_Select                         Instruction = 0xA4
	InstructionFE_TerminateCardUsage             Instruction = 0xFE
	InstructionE6_TerminateDf                    Instruction = 0xE6
	InstructionE8_TerminateEf                    Instruction = 0xE8
	InstructionD6_UpdateBinary                   Instruction = 0xD6
	InstructionD7_UpdateBinary                   Instruction = 0xD7
	InstructionDC_UpdateRecord                   Instruction = 0xDC
	InstructionDD_UpdateRecord                   Instruction = 0xDD
	Instruction20_Verify                         Instruction = 0x20
	Instruction21_Verify                         Instruction = 0x21
	InstructionD0_WriteBinary                    Instruction = 0xD0
	InstructionD1_WriteBinary                    Instruction = 0xD1
	InstructionD2_WriteRecord                    Instruction = 0xD2
)

Table 4.1 — Commands in the alphabetic order

const (
	EMVInstructionA8_GetProcessingOptions Instruction = 0xA8
	EMVInstructionAE_GenerateAC           Instruction = 0xAE
)

EMV instructions

type LowLevelCommands

type LowLevelCommands interface {
	SelectByName(dfname []byte) ([]byte, error)
	ReadRecord(sfi, recordNumber int) ([]byte, error)
	GetProcessingOptions(pdolData []byte) ([]byte, error)
	GenerateAC(cryptogramType ApplicationCryptogramType, transactionData []byte) ([]byte, error)
	VerifyPlaintextPIN(pinDigits []int) ([]byte, error)
}

type MockRawClient added in v0.0.3

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

MockRawClient is a mock of RawClient interface.

func NewMockRawClient added in v0.0.3

func NewMockRawClient(ctrl *gomock.Controller) *MockRawClient

NewMockRawClient creates a new mock instance.

func (*MockRawClient) EXPECT added in v0.0.3

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRawClient) SendCommand added in v0.0.3

func (m *MockRawClient) SendCommand(cmd Command) (Response, error)

SendCommand mocks base method.

type MockRawClientMockRecorder added in v0.0.3

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

MockRawClientMockRecorder is the mock recorder for MockRawClient.

func (*MockRawClientMockRecorder) SendCommand added in v0.0.3

func (mr *MockRawClientMockRecorder) SendCommand(cmd any) *gomock.Call

SendCommand indicates an expected call of SendCommand.

type PSEFile

type PSEFile struct {
	ADFName                      []byte  `tlv:"4F"`
	ApplicationLabel             *string `tlv:"50"`
	ApplicationPriorityIndicator *int    `tlv:"87"`
	ApplicationPreferredName     *string `tlv:"9F12"`
}

type Parameters

type Parameters struct {
	P1 byte
	P2 byte
}

type ProprietaryFCITemplate

type ProprietaryFCITemplate struct {
	ApplicationLabel                 *string           `tlv:"50"`
	ApplicationPriorityIndicator     *int              `tlv:"87"`
	ShortFileIdentifier              *int              `tlv:"88"`
	LanguagePreference               *string           `tlv:"5f2d"`
	ApplicationPreferredNameEncoding *int              `tlv:"9f11"`
	ApplicationPreferredName         *string           `tlv:"9f12"`
	PDOL                             tlv.TL            `tlv:"9f38"`
	IssuerDiscretionaryData          map[string][]byte `tlv:"bf0c"`
}

type RawClient

type RawClient interface {
	SendCommand(cmd Command) (Response, error)
}

func NewRawClient

func NewRawClient(driver Driver) RawClient

type RecordTemplate

type RecordTemplate struct {
	EMVProprietaryTemplates []EMVProprietaryTemplate `tlv:"70"`
}

type Response

type Response struct {
	Data    []byte
	Trailer Trailer
}

func ParseResponse

func ParseResponse(data []byte) (Response, error)

func (Response) HasMoreData

func (r Response) HasMoreData() bool

func (Response) HasWrongLength

func (r Response) HasWrongLength() bool

func (Response) String

func (r Response) String() string

type SecureMessagingIndication

type SecureMessagingIndication string

type Trailer

type Trailer uint16

func NewTrailer

func NewTrailer(sw1, sw2 byte) Trailer

func (Trailer) GetError

func (t Trailer) GetError() error

func (Trailer) SW1

func (t Trailer) SW1() byte

func (Trailer) SW2

func (t Trailer) SW2() byte

func (Trailer) String

func (t Trailer) String() string

type TrailerError

type TrailerError uint16
const (
	ErrNoInformationGiven                       TrailerError = 0x6A00
	ErrIncorrectParametersInTheCommandDataField TrailerError = 0x6A80
	ErrFunctionNotSupported                     TrailerError = 0x6A81
	ErrFileOrApplicationNotFound                TrailerError = 0x6A82
	ErrRecordNotFound                           TrailerError = 0x6A83
	ErrNotEnoughMemorySpaceInTheFile            TrailerError = 0x6A84
	ErrNcInconsistentWithTLVStructure           TrailerError = 0x6A85
	ErrIncorrectParametersP1P2                  TrailerError = 0x6A86
	ErrNcInconsistentWithParametersP1P2         TrailerError = 0x6A87
	ErrReferencedDataOrReferenceDataNotFound    TrailerError = 0x6A88
	ErrFileAlreadyExists                        TrailerError = 0x6A89
	ErrDFNameAlreadyExists                      TrailerError = 0x6A8A
)

func AsTrailerError

func AsTrailerError(err error) (TrailerError, bool)

func (TrailerError) Error

func (te TrailerError) Error() string

func (TrailerError) SW1

func (te TrailerError) SW1() byte

func (TrailerError) SW2

func (te TrailerError) SW2() byte

Directories

Path Synopsis
drivers
internal

Jump to

Keyboard shortcuts

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