multiiso

package
v0.0.0-...-89eb2bc Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

* package to handle the communication of smartCard devices under the PCSC implementation

projects on which it is based:

https://github.com/LudovicRousseau/PCSC
github.com/ebfe/sCard

/*

* package to handle the communication of "omnikey/multi-iso" reader

projects on which it is based:

https://github.com/dumacp/smartcard

/*

Index

Constants

View Source
const (
	Loginsucess          byte = 'L'
	Authenticationfailed byte = 'X'
	Generalfailure       byte = 'F'
	Notaginfield         byte = 'N'
	Operationmodefailure byte = 'O'
	Outofrange           byte = 'R'
)

response

View Source
const (
	//BinaryMode protocol binary mode
	BinaryMode int = iota
	//AsciiMode protocol acsii mode
	AsciiMode
)
View Source
const (
	ProtocolConf1   byte = 0x0B
	ProtocolConf2   byte = 0x13
	ProtocolConf3   byte = 0x1B
	OpMode          byte = 0x0E
	BaudRate        byte = 0x0C
	TMRhigh         byte = 0x11
	TMRlow          byte = 0x10
	ResetOffTime    byte = 0x14
	ResetCoveryTime byte = 0x015
)

Variables

View Source
var ErrDisconnectCard = errors.New("don't Connect to Card")

Functions

func MifareClassic

func MifareClassic(c *Card) (mifare.Classic, error)

MifareClassic Create Mifare Plus Interface

Types

type BadChecsum

type BadChecsum []byte

func (BadChecsum) Error

func (e BadChecsum) Error() string

type BadResponse

type BadResponse []byte

func (BadResponse) Error

func (e BadResponse) Error() string

type Card

type Card struct {
	State
	Reader *Reader
	// contains filtered or unexported fields
}

func (*Card) ATR

func (c *Card) ATR() ([]byte, error)

Get ATR of Card

func (*Card) ATS

func (c *Card) ATS() ([]byte, error)

Get Data 0x01

func (*Card) Apdu

func (c *Card) Apdu(apdu []byte) ([]byte, error)

Primitive channel to send command

func (*Card) DisconnectCard

func (c *Card) DisconnectCard() error

func (*Card) DisconnectResetCard

func (c *Card) DisconnectResetCard() error

func (*Card) EndTransactionResetCard

func (c *Card) EndTransactionResetCard() error

func (*Card) GetData

func (c *Card) GetData(data byte) ([]byte, error)

Get Data 0x00

func (*Card) SAK

func (c *Card) SAK() byte

func (*Card) Switch1444_3

func (c *Card) Switch1444_3() ([]byte, error)

func (*Card) Switch1444_4

func (c *Card) Switch1444_4() ([]byte, error)

func (*Card) UID

func (c *Card) UID() ([]byte, error)

Get Data 0x00

type Device

type Device struct {
	Ok bool
	// contains filtered or unexported fields
}

Device struct

func NewDevice

func NewDevice(portName string, baudRate int, timeout time.Duration) (*Device, error)

NewDevice create new serial device

func (*Device) Close

func (dev *Device) Close() bool

Close close serial device

func (*Device) Recv

func (dev *Device) Recv() ([]byte, error)

Recv read data bytes in serial device

func (*Device) Send

func (dev *Device) Send(data []byte) (int, error)

Send write data bytes in serial device

func (*Device) SendRecv

func (dev *Device) SendRecv(data []byte) ([]byte, error)

SendRecv write daa bytes in serial device and wait by response

type ErrorCode

type ErrorCode byte

func (ErrorCode) Code

func (e ErrorCode) Code() byte

func (ErrorCode) Error

func (e ErrorCode) Error() string

type ICard

type ICard interface {
	smartcard.ICard
	Switch1444_4() ([]byte, error)
	Switch1444_3() ([]byte, error)
}

Card Interface

type NilResponse

type NilResponse int

func (NilResponse) Error

func (e NilResponse) Error() string

type Reader

type Reader struct {
	ModeProtocol int
	// contains filtered or unexported fields
}

func NewMifareClassicReader

func NewMifareClassicReader(dev *Device, readerName string, idx int) *Reader

NewMifareClassicReader Create mifare classic reader

func NewReader

func NewReader(dev *Device, readerName string, idx int) *Reader

NewReader Create New Reader interface

func (*Reader) ConnectCard

func (r *Reader) ConnectCard() (smartcard.ICard, error)

Create New Card interface

func (*Reader) ConnectLegacyCard

func (r *Reader) ConnectLegacyCard() (*Card, error)

Create New Card interface

func (*Reader) ConnectMifareClassic

func (r *Reader) ConnectMifareClassic() (mifare.Classic, error)

NewMClassic Create Mifare Plus Interface

func (*Reader) ConnectSamCard

func (r *Reader) ConnectSamCard() (smartcard.ICard, error)

Create New Card interface

func (*Reader) ConnectSamCard_T0

func (r *Reader) ConnectSamCard_T0() (smartcard.ICard, error)

Create New Card interface

func (*Reader) ConnectSamCard_Tany

func (r *Reader) ConnectSamCard_Tany() (smartcard.ICard, error)

Create New Card interface

func (*Reader) GetRegister

func (r *Reader) GetRegister(register byte) ([]byte, error)

GetRegister send in format Data Frame Transfer

func (*Reader) SendAPDU1443_4

func (r *Reader) SendAPDU1443_4(data []byte) ([]byte, error)

SendAPDU1443_4 send in format Data Frame Transfer

func (*Reader) SendDataFrameTransfer

func (r *Reader) SendDataFrameTransfer(data []byte) ([]byte, error)

SendDataFrameTransfer send in format Data Frame Transfer

func (*Reader) SendSAMDataFrameTransfer

func (r *Reader) SendSAMDataFrameTransfer(data []byte) ([]byte, error)

SendSAMDataFrameTransfer send APDU to SAM device in special socket ("e" command)

func (*Reader) SetChainning

func (r *Reader) SetChainning(chainning bool)

func (*Reader) SetModeProtocol

func (r *Reader) SetModeProtocol(mode int)

SetModeProtocol set mode protocol to communication (0: binary, 1: ascii)

func (*Reader) SetRegister

func (r *Reader) SetRegister(register byte, data []byte) error

SetRegister send in format Data Frame Transfer

func (*Reader) T1TransactionV2

func (r *Reader) T1TransactionV2(data []byte) ([]byte, error)

T1TransactionV2 function to send wrapped frames T1 to SAM device through "e" command

func (*Reader) Transmit

func (r *Reader) Transmit(cmd, data []byte) ([]byte, error)

Transmit send data byte to reader in actual mode

func (*Reader) TransmitAscii

func (r *Reader) TransmitAscii(cmd, data []byte) ([]byte, error)

TransmitAscii send in ascii protocol mode

func (*Reader) TransmitBinary

func (r *Reader) TransmitBinary(cmd, data []byte) ([]byte, error)

TransmitBinary send in binary protocol mode

type SendMode

type SendMode int
const (
	APDU1443_4      SendMode = 0
	T1TransactionV2 SendMode = 1
	NA              SendMode = 2
)

type State

type State int
const (
	CONNECTED State = iota
	DISCONNECTED
)

type TransmitProto

type TransmitProto int
const (
	T0 TransmitProto = iota
	T1
)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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