Documentation
¶
Index ¶
- Constants
- Variables
- func CRC16CCITTFalse(in []byte) uint16
- func Escapable[T any](ctx context.Context, fn func(context.Context) (T, error)) (_ T, err error)
- func LRC(in []byte) byte
- func LogHex(key string, value []byte) slog.Attr
- func Must[T any](val T, err error) T
- type APDUer
- type APDUerFunc
- type ATR
- type ATS
- func (a *ATS) ClearTA()
- func (a *ATS) ClearTB()
- func (a *ATS) ClearTC()
- func (a ATS) FSC() int
- func (a ATS) FSCI() int
- func (a ATS) FWI() byte
- func (a ATS) FWT() time.Duration
- func (a ATS) HasTA() bool
- func (a ATS) HasTB() bool
- func (a ATS) HasTC() bool
- func (a ATS) MarshalBinary() ([]byte, error)
- func (a ATS) SFGI() byte
- func (a ATS) SFGT() time.Duration
- func (a *ATS) SetT0(t0 byte)
- func (a *ATS) SetTA(ta byte)
- func (a *ATS) SetTB(tb byte)
- func (a *ATS) SetTBParams(fwi, sfgi byte)
- func (a *ATS) SetTC(tc byte)
- func (a *ATS) UnmarshalBinary(data []byte) error
- type Exchanger
- type ExchangerAPDUer
- type ExchangerFunc
- type PCSC
- type RawSmartCard
- type RawSmartCardControl
- type SmartCardControl
- type SmartCardControlFunc
Constants ¶
const ( CtlCodePcToRdrEscape uint16 = 3500 CtlCodeSetProtocol uint16 = 12 )
Variables ¶
var DeferWrap = func(ctx context.Context, err *error) {}
DeferWrap is called by library functions when returning errors to enrich them with stack trace information. By default, this is a no-op but exists so consumers of the library can BYO their own library If context is not available in a given function context.Background() will be used
Functions ¶
func CRC16CCITTFalse ¶ added in v1.0.0
CRC16CCITTFalse returns a CRC-16 with CCITT-FALSE parameters
func Escapable ¶ added in v0.0.2
Escapable runs the given func in a goroutine and waits for the response. This is useful to convert non-context aware blocking functions to be context aware with the caveat that cancellation will not abort the non-context aware function but does enabling returning early. If the context is cancelled it returns immediately with the context.Cause abandoning the goroutine If the context is already cancelled it returns immediately without invoking the func.
Types ¶
type APDUer ¶ added in v0.0.2
APDUer is a higher level version of Exchanger that operates on parsed ISO7816 APDUs instead of raw byte slices
type APDUerFunc ¶ added in v0.0.2
APDUerFunc implements the ExchangerAPDUer interface as an APDUer.APDU func
type ATR ¶ added in v1.0.0
type ATR struct {
Inverse bool
FiDi byte
GuardTime byte
StopClock byte
T0WI byte
T1IFSC byte
T1Waiting byte
T1CRC bool
Protocols []byte
Historical []byte
}
func (*ATR) UnmarshalBinary ¶ added in v1.0.0
type ATS ¶ added in v0.0.4
func (ATS) MarshalBinary ¶ added in v0.0.4
func (*ATS) SetTBParams ¶ added in v0.0.4
func (*ATS) UnmarshalBinary ¶ added in v0.0.4
type Exchanger ¶ added in v0.0.2
Exchanger is a higher level version of RawSmartCard that takes a context for cancellation
type ExchangerAPDUer ¶ added in v0.0.2
ExchangerAPDUer is a composite interface of Exchanger and APDUer
func RawSmartCardAPDUer ¶ added in v0.0.2
func RawSmartCardAPDUer(sc RawSmartCard) ExchangerAPDUer
RawSmartCardAPDUer transforms RawSmartCard into an ExchangerAPDUer with the ability to abandon waiting for a response if the context is cancelled
func RawSmartCardControlAPDUer ¶ added in v0.0.2
func RawSmartCardControlAPDUer(sc RawSmartCardControl, ioctl uint32) ExchangerAPDUer
RawSmartCardControlAPDUer transforms RawSmartCard into an ExchangerAPDUer by performing escape functions with the given ioctl. It also provides the ability to abandon waiting for a response if the context is cancelled
func SmartCardControlAPDUer ¶ added in v0.0.2
func SmartCardControlAPDUer(sc SmartCardControl, code uint16) ExchangerAPDUer
SmartCardControlAPDUer transforms SmartCardControl into an ExchangerAPDUer by performing control functions with the given code.
type ExchangerFunc ¶ added in v0.0.2
ExchangerFunc implements the ExchangerAPDUer interface as an Exchanger.Exchange func
type PCSC ¶ added in v1.0.0
type PCSC interface {
Exchanger
SmartCardControl
DeviceName() string
ATR() ([]byte, error)
Reconnect(context.Context) error
io.Closer
}
PCSC represents a connection to a SmartCard in a PCSC-like reader
type RawSmartCard ¶ added in v0.0.2
RawSmartCard is an interface that is implemented by *github.com/ebfe/go-scard.Card
type RawSmartCardControl ¶ added in v0.0.2
RawSmartCardControl is an interface that is implemented by *github.com/ebfe/go-scard.Card
type SmartCardControl ¶ added in v0.0.2
type SmartCardControl interface {
Control(ctx context.Context, code uint16, data []byte) ([]byte, error)
}
SmartCardControl is a higher level version of RawSmartCardControl that takes control codes instead of ioctls for platform portability and accepts a context for cancellation
func RawSmartCardControlToSmartCardControl ¶ added in v0.0.2
func RawSmartCardControlToSmartCardControl(sc RawSmartCardControl, controlCodeToIoctl func(code uint16) uint32) SmartCardControl
RawSmartCardControlToSmartCardControl transforms RawSmartCardControl into an SmartCardControl with the ability to abandon waiting for a response if the context is cancelled
type SmartCardControlFunc ¶ added in v0.0.2
SmartCardControlFunc implements the SmartCardControl interface as an SmartCardControl.Control func