pcsc

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: Apache-2.0 Imports: 6 Imported by: 11

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
https://github.com/ebfe/scard

/*

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListReaders

func ListReaders(ctx *Context) ([]string, error)

List Readers in a Context

Types

type Card

type Card interface {
	smartcard.ICard
	ControlApdu(ioctl uint32, apdu []byte) ([]byte, error)
	ControlApduA(ioctl uint32, apdu []byte) ([]byte, error)
	EndTransaction() error
	EndTransactionResetCard() error
	// DisconnectResetCard() error
	// DisconnectUnpowerCard() error
	// DisconnectEjectCard() error
	TransparentSessionStart() ([]byte, error)
	TransparentSessionStartOnly() ([]byte, error)
	TransparentSessionResetRF() ([]byte, error)
	TransparentSessionEnd() ([]byte, error)
	Switch1444_4() ([]byte, error)
	Switch1444_3() ([]byte, error)
}

Card Interface

type Context

type Context struct {
	*scard.Context
}

func NewContext

func NewContext() (*Context, error)

Establish Context to Reader in pcscd

func (*Context) Release

func (c *Context) Release() error

Release Context in pcscd

type Reader

type Reader interface {
	smartcard.IReader
	Name() string
	ConnectDirect() (Card, error)
	ConnectCardPCSC() (Card, error)
	ConnectCardPCSC_T0() (Card, error)
	ConnectCardPCSC_Tany() (Card, error)
}

Interface to Reader device

func NewReader

func NewReader(ctx *Context, readerName string) Reader

Create New Reader interface

type Scard added in v0.1.5

type Scard struct {
	State State
	*scard.Card
	// contains filtered or unexported fields
}

func (*Scard) ATR added in v0.1.5

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

ATR Get ATR from Card

func (*Scard) ATS added in v0.1.5

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

ATS GetData with INS = 0x01

func (*Scard) Apdu added in v0.1.5

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

Apdu Primitive function (SCardTransmit) to send command to card

func (*Scard) ControlApdu added in v0.1.5

func (c *Scard) ControlApdu(ioctl uint32, apdu []byte) ([]byte, error)

ControlApdu Primitive function (SCardControl) to send command to card

func (*Scard) ControlApduA added in v0.1.6

func (c *Scard) ControlApduA(ioctl uint32, apdu []byte) ([]byte, error)

ControlApdu Primitive function (SCardControl) to send command to card

func (*Scard) DisconnectCard added in v0.1.5

func (c *Scard) DisconnectCard() error

DisconnectCard Disconnect card from context with card with disposition type LeaveCard

func (*Scard) DisconnectEjectCard added in v0.1.5

func (c *Scard) DisconnectEjectCard() error

DisconnectEjectCard Disconnect card from context with card with disposition type EjectCard

func (*Scard) DisconnectResetCard added in v0.1.5

func (c *Scard) DisconnectResetCard() error

DiconnectResetCard Disconnect card from context with card with disposition type ResetCard

func (*Scard) DisconnectUnpowerCard added in v0.1.5

func (c *Scard) DisconnectUnpowerCard() error

DisconnectUnpowerCard Disconnect card from context with card with disposition type UnpowerCard

func (*Scard) EndTransaction added in v0.1.5

func (c *Scard) EndTransaction() error

EndTransactionn End transaccion with card with disposition type LeaveCard

func (*Scard) EndTransactionResetCard added in v0.1.5

func (c *Scard) EndTransactionResetCard() error

EndTransactionResetCard End transaccion with card with disposition type ResetCard

func (*Scard) GetData added in v0.1.5

func (c *Scard) GetData(ins byte) ([]byte, error)

GetData GetData with param INS

func (*Scard) SAK added in v0.1.5

func (c *Scard) SAK() byte

func (*Scard) Switch1444_3 added in v0.1.5

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

Switch1444_4 switch channel reader to send ISO 1444-3 APDU

func (*Scard) Switch1444_4 added in v0.1.5

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

Switch1444_4 switch channel reader to send ISO 1444-4 APDU

func (*Scard) TransparentSessionEnd added in v0.1.5

func (c *Scard) TransparentSessionEnd() ([]byte, error)

TransparentSessionEnd finish transparent session

func (*Scard) TransparentSessionResetRF added in v0.1.5

func (c *Scard) TransparentSessionResetRF() ([]byte, error)

TransparentSessionResetRF start transparent session to send APDU

func (*Scard) TransparentSessionStart added in v0.1.5

func (c *Scard) TransparentSessionStart() ([]byte, error)

Transparent Session (PCSC)

func (*Scard) TransparentSessionStartOnly added in v0.1.5

func (c *Scard) TransparentSessionStartOnly() ([]byte, error)

TransparentSessionStartOnly start transparent session to send APDU

func (*Scard) UID added in v0.1.5

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

UID GetData with INS = 0x00

type State

type State int

Connect state

const (
	CONNECTED State = iota
	CONNECTEDDirect
	DISCONNECTED
)

Jump to

Keyboard shortcuts

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