rfid

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const (
	CtlCodePcToRdrEscape uint16 = 3500
	CtlCodeSetProtocol   uint16 = 12
)

Variables

View Source
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

View Source
var ErrorAttrs = func(err error) slog.Attr {
	return slog.String("error", err.Error())
}

Functions

func CRC16CCITTFalse added in v1.0.0

func CRC16CCITTFalse(in []byte) uint16

CRC16CCITTFalse returns a CRC-16 with CCITT-FALSE parameters

func Escapable added in v0.0.2

func Escapable[T any](ctx context.Context, fn func(context.Context) (T, error)) (_ T, err error)

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.

func LRC added in v1.0.0

func LRC(in []byte) byte

LRC is a Longitudinal Redundancy Check created by XORing all bytes together

func LogHex

func LogHex(key string, value []byte) slog.Attr

func Must

func Must[T any](val T, err error) T

Types

type APDUer added in v0.0.2

type APDUer interface {
	APDU(context.Context, apdu.Capdu) (apdu.Rapdu, error)
}

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

type APDUerFunc func(context.Context, apdu.Capdu) (apdu.Rapdu, error)

APDUerFunc implements the ExchangerAPDUer interface as an APDUer.APDU func

func (APDUerFunc) APDU added in v0.0.2

func (f APDUerFunc) APDU(ctx context.Context, capdu apdu.Capdu) (apdu.Rapdu, error)

func (APDUerFunc) Exchange added in v0.0.2

func (f APDUerFunc) Exchange(ctx context.Context, capdu []byte) (_ []byte, err error)

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

func (a *ATR) UnmarshalBinary(data []byte) error

type ATS added in v0.0.4

type ATS struct {
	HasT0          bool
	T0, TA, TB, TC byte
	Historical     []byte
}

func (*ATS) ClearTA added in v0.0.4

func (a *ATS) ClearTA()

func (*ATS) ClearTB added in v0.0.4

func (a *ATS) ClearTB()

func (*ATS) ClearTC added in v0.0.4

func (a *ATS) ClearTC()

func (ATS) FSC added in v0.0.4

func (a ATS) FSC() int

func (ATS) FSCI added in v0.0.4

func (a ATS) FSCI() int

func (ATS) FWI added in v0.0.4

func (a ATS) FWI() byte

func (ATS) FWT added in v0.0.4

func (a ATS) FWT() time.Duration

func (ATS) HasTA added in v0.0.4

func (a ATS) HasTA() bool

func (ATS) HasTB added in v0.0.4

func (a ATS) HasTB() bool

func (ATS) HasTC added in v0.0.4

func (a ATS) HasTC() bool

func (ATS) MarshalBinary added in v0.0.4

func (a ATS) MarshalBinary() ([]byte, error)

func (ATS) SFGI added in v0.0.4

func (a ATS) SFGI() byte

func (ATS) SFGT added in v0.0.4

func (a ATS) SFGT() time.Duration

func (*ATS) SetT0 added in v0.0.4

func (a *ATS) SetT0(t0 byte)

func (*ATS) SetTA added in v0.0.4

func (a *ATS) SetTA(ta byte)

func (*ATS) SetTB added in v0.0.4

func (a *ATS) SetTB(tb byte)

func (*ATS) SetTBParams added in v0.0.4

func (a *ATS) SetTBParams(fwi, sfgi byte)

func (*ATS) SetTC added in v0.0.4

func (a *ATS) SetTC(tc byte)

func (*ATS) UnmarshalBinary added in v0.0.4

func (a *ATS) UnmarshalBinary(data []byte) error

type Exchanger added in v0.0.2

type Exchanger interface {
	Exchange(ctx context.Context, capdu []byte) ([]byte, error)
}

Exchanger is a higher level version of RawSmartCard that takes a context for cancellation

type ExchangerAPDUer added in v0.0.2

type ExchangerAPDUer interface {
	Exchanger
	APDUer
}

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

type ExchangerFunc func(ctx context.Context, capdu []byte) ([]byte, error)

ExchangerFunc implements the ExchangerAPDUer interface as an Exchanger.Exchange func

func (ExchangerFunc) APDU added in v0.0.2

func (f ExchangerFunc) APDU(ctx context.Context, capdu apdu.Capdu) (_ apdu.Rapdu, err error)

func (ExchangerFunc) Exchange added in v0.0.2

func (f ExchangerFunc) Exchange(ctx context.Context, capdu []byte) ([]byte, error)

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

type RawSmartCard interface {
	Transmit(data []byte) ([]byte, error)
}

RawSmartCard is an interface that is implemented by *github.com/ebfe/go-scard.Card

type RawSmartCardControl added in v0.0.2

type RawSmartCardControl interface {
	Control(ioctl uint32, data []byte) ([]byte, error)
}

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

type SmartCardControlFunc func(ctx context.Context, code uint16, data []byte) ([]byte, error)

SmartCardControlFunc implements the SmartCardControl interface as an SmartCardControl.Control func

func (SmartCardControlFunc) Control added in v0.0.2

func (f SmartCardControlFunc) Control(ctx context.Context, code uint16, data []byte) ([]byte, error)

Directories

Path Synopsis
pm3

Jump to

Keyboard shortcuts

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