goscard

package module
v0.0.0-...-3aed127 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

README

goscard

Go Reference

goscard is a PCSC / SCard wrapper in pure Go, without any CGO bindings.

It implements all WinSCard functions on Windows, PCSCLite functions on Linux and PCSC framework functions on MacOSX.

Shoutout to the purego project, without which Linux / MacOSX support wouldn't have been possible!

Usage

See the pcsc example.

Documentation

Index

Constants

View Source
const (
	SCardAllReaders     = "SCard$AllReaders"
	SCardDefaultReaders = "SCard$DefaultReaders"
	SCardLocalReaders   = "SCard$LocalReaders"
	SCardSystemReaders  = "SCard$SystemReaders"
)

Variables

This section is empty.

Functions

func Finalize

func Finalize()

Finalize is the very last function that must be called on the library. It ensures that the previously loaded pcsc library and functions are unloaded.

func Initialize

func Initialize(customLogger Logger, scardLibPaths ...string) (errRet error)

Initialize is the very first function that must be called on goscard. It ensures that the underlying pcsc library and all its functions are loaded.

If customLogger is nil, the library will use its default logger which will print log messages to stderr using INFO log level. To disable logging, a NewDefaultLogger can be passed with LogLevel set to LogLevelNone.

If scardLibPaths is not set, the library will look for winscard in its usual places. Otherwise, the specified paths will be used.

func PcscStringifyError

func PcscStringifyError(ret uint64) string

Returns a human readable text for the given PC/SC error code.

Types

type Card

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

Card is a wrapper around a SCardHandle and its SCardProtocol.

func (*Card) ActiveProtocol

func (c *Card) ActiveProtocol() SCardProtocol

ActiveProtocol returns the underlying protocol.

func (*Card) BeginTransaction

func (c *Card) BeginTransaction() (ret uint64, err error)

BeginTransaction is a wrapper around SCardBeginTransaction.

This function establishes a temporary exclusive access mode for doing a series of commands in a transaction. You might want to use this when you are selecting a few files and then writing a large file so you can make sure that another application will not change the current file. If another application has a lock on this reader or this application is in SCardShareExclusive there will be no action taken.

func (*Card) Control

func (c *Card) Control(
	scardControlCode SCardCtlCode,
	inBuffer []byte,
) (outBuffer []byte, ret uint64, err error)

Control is a wrapper around SCardControl.

This function sends a command directly to the IFD Handler (reader driver) to be processed by the reader. This is useful for creating client side reader drivers for functions like PIN pads, biometrics, or other extensions to the normal smart card reader that are not normally handled by PC/SC.

N.B: This function implements handling of the case of SCARD_E_INSUFFICIENT_BUFFER (0x80100008) internally.

func (*Card) Disconnect

func (c *Card) Disconnect(
	scardDisposition SCardDisposition,
) (ret uint64, err error)

Disconnect is a wrapper around SCardDisconnect.

This function terminates a connection made through SCardConnect().

func (*Card) EndTransaction

func (c *Card) EndTransaction(
	scardDisposition SCardDisposition,
) (ret uint64, err error)

EndTransaction is a wrapper around SCardEndTransaction.

This function ends a previously begun transaction. The calling application must be the owner of the previously begun transaction or an error will occur.

func (*Card) GetAttrib

func (c *Card) GetAttrib(
	attrId SCardAttr,
) (attrBytes []byte, ret uint64, err error)

GetAttrib is a wrapper around SCardGetAttrib.

This function gets an attribute from the IFD Handler (reader driver).

func (*Card) Reconnect

func (c *Card) Reconnect(
	shareMode SCardShareMode,
	preferredProtocols SCardProtocol,
	initialization SCardDisposition,
) (ret uint64, err error)

Reconnect is a wrapper around SCardReconnect.

This function reestablishes a connection to a reader that was previously connected to using SCardConnect(). In a multi application environment, it is possible for an application to reset the card in shared mode. When this occurs, any other application trying to access certain commands will be returned the value SCARD_W_RESET_CARD. When this occurs, SCardReconnect() must be called in order to acknowledge that the card was reset and allow it to change its state accordingly.

func (*Card) SCardHandle

func (c *Card) SCardHandle() SCardHandle

SCardHandle returns the underlying SCardContext.

func (*Card) SetAttrib

func (c *Card) SetAttrib(
	attrId SCardAttr,
	attr []byte,
) (ret uint64, err error)

SetAttrib is a wrapper around SCardSetAttrib.

This function sets an attribute of the IFD Handler. The list of attributes you can set is dependent on the IFD Handler you are using.

func (*Card) Status

func (c *Card) Status() (cardStatus CardStatus, ret uint64, err error)

Status is a wrapper around SCardStatus.

This function returns the current status of the reader connected to by scardHandle. Its friendly name will be returned.

N.B: The PCSCLite project defines SCardStatus as returning only one string. That being said, and to keep the same definition as on Windows, we're returning a string array that'll always include at most one element.

func (*Card) Transmit

func (c *Card) Transmit(
	ioSendPci *SCardIORequest,
	sendBuffer []byte,
	ioRecvPci *SCardIORequest,
) (recvBuffer []byte, ret uint64, err error)

Transmit is a wrapper around SCardTransmit.

This function sends an APDU to the smart card contained in the reader connected to by SCardConnect(). The card responds from the APDU and stores this response in recvBuffer.

N.B: This function implements handling of the case of SCARD_E_INSUFFICIENT_BUFFER (0x80100008) internally.

type CardStatus

type CardStatus struct {
	ReaderNames    []string
	State          ReaderState
	ActiveProtocol SCardProtocol
	Atr            string
}

CardStatus is a wrapper around the information that SCardStatus returns.

type Context

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

Context is a wrapper around a SCardContext.

func NewContext

func NewContext(
	scope SCardScope,
	reserved1 unsafe.Pointer,
	reserved2 unsafe.Pointer,
) (context Context, ret uint64, err error)

NewContext is a wrapper around SCardEstablichContext.

This function ccreates an Application Context to the PC/SC Resource Manager. This must be the first WinSCard function called in a PC/SC application. Each thread of an application shall use its own SCardContext, unless calling SCardCancel(), which MUST be called with the same context as the context used to call SCardGetStatusChange().

func (*Context) Cancel

func (c *Context) Cancel() (ret uint64, err error)

Cancel is a wrapper around SCardCancel.

This function cancels a specific blocking SCardGetStatusChange() function. MUST be called with the same scardContext as SCardGetStatusChange().

func (*Context) Connect

func (c *Context) Connect(
	readerName string,
	shareMode SCardShareMode,
	preferredProtocols SCardProtocol,
) (card Card, ret uint64, err error)

Connect is a wrapper around SCardConnect.

This function establishes a connection to the reader specified in readerName.

func (*Context) FreeMemory

func (c *Context) FreeMemory(
	mem unsafe.Pointer,
) (ret uint64, err error)

FreeMemory is a wrapper around SCardFreeMemory.

This function releases memory that has been returned from the resource manager using the scardAutoAllocate length designator.

func (*Context) GetStatusChange

func (c *Context) GetStatusChange(
	timeout Timeout,
	readerStates []SCardReaderState,
) (ret uint64, err error)

GetStatusChange is a wrapper around SCardGetStatusChange.

This function blocks execution until the current availability of the cards in a specific set of readers changes. This function receives a structure or list of structures containing reader names. It then blocks waiting for a change in state to occur for a maximum blocking time of timeout or forever if InfiniteTimeout is used. The new event state will be contained in EventState. A status change might be a card insertion or removal event, a change in ATR, etc. EventState also contains a number of events in the upper 16 bits (EventState & 0xFFFF0000). This number of events is incremented for each card insertion or removal in the specified reader. This can be used to detect a card removal/insertion between two calls to SCardGetStatusChange() To wait for a reader event (reader added or removed) you may use the special reader name "\\?PnP?\Notification". If a reader event occurs the state of this reader will change and the bit SCardStateChanged will be set. To cancel the ongoing call, use SCardCancel() with the same SCardContext.

N.B: The function will update the SCardStates inside of the passed SCardReaderState array.

func (*Context) IsValid

func (c *Context) IsValid() (isValid bool, ret uint64, err error)

IsValid is a wrapper around SCardIsValidContext.

This function checks if a SCardContext is valid. Call this function to determine whether a smart card context handle is still valid. After a smart card context handle has been returned by SCardEstablishContext(), it may become invalid if the resource manager service has been shut down.

func (*Context) ListReaderGroups

func (c *Context) ListReaderGroups() (groups []string, ret uint64, err error)

ListReaderGroups is a wrapper around SCardListReaderGroups.

This function returns a list of currently available reader groups on the system.

func (*Context) ListReaders

func (c *Context) ListReaders(
	groups []string,
) (readers []string, ret uint64, err error)

ListReaders is a wrapper around SCardListReaders.

This function returns a list of currently available readers on the system.

func (*Context) Release

func (c *Context) Release() (ret uint64, err error)

Release function is a wrapper around SCardReleaseContext.

This function destroys a communication context to the PC/SC Resource Manager. This must be the last function called in a PC/SC application.

func (*Context) SCardContext

func (c *Context) SCardContext() SCardContext

SCardContext returns the underlying SCardContext.

type DriverOption

type DriverOption dword
const (
	DriverOptionCcidExchangeAuthorized DriverOption = 1
	DriverOptionGempcTwinKeyApdu       DriverOption = 2
	DriverOptionUseBogusFirmware       DriverOption = 4
	DriverOptionDisablePinRetries      DriverOption = (1 << 6)
)

type Feature

type Feature dword
const (
	FeatureVerifyPinStart       Feature = 0x01
	FeatureVerifyPinFinish      Feature = 0x02
	FeatureModifyPinStart       Feature = 0x03
	FeatureModifyPinFinish      Feature = 0x04
	FeatureGetKeyPressed        Feature = 0x05
	FeatureVerifyPinDirect      Feature = 0x06
	FeatureModifyPinDirect      Feature = 0x07
	FeatureMctReaderDirect      Feature = 0x08
	FeatureMctUniversal         Feature = 0x09
	FeatureIfdPinProperties     Feature = 0x0A
	FeatureAbort                Feature = 0x0B
	FeatureSetSPEMessage        Feature = 0x0C
	FeatureVerifyPinDirectAppID Feature = 0x0D
	FeatureModifyPinDirectAppID Feature = 0x0E
	FeatureWriteDisplay         Feature = 0x0F
	FeatureGetKey               Feature = 0x10
	FeatureIfdDisplayProperties Feature = 0x11
	FeatureGetTlvProperties     Feature = 0x12
	FeatureCcidEscCommand       Feature = 0x13
)
const (
	FeatureExecutePACE Feature = 0x20
)

type LogLevel

type LogLevel int
const (
	LogLevelDebug LogLevel = iota
	LogLevelInfo
	LogLevelWarn
	LogLevelError
	LogLevelNone
)

type Logger

type Logger interface {
	Debugf(format string, v ...interface{})
	Debug(v ...interface{})
	Debugln(v ...interface{})
	Infof(format string, v ...interface{})
	Info(v ...interface{})
	Infoln(v ...interface{})
	Warnf(format string, v ...interface{})
	Warn(v ...interface{})
	Warnln(v ...interface{})
	Errorf(format string, v ...interface{})
	Error(v ...interface{})
	Errorln(v ...interface{})
}

func NewDefaultLogger

func NewDefaultLogger(level LogLevel) Logger

type PcscTlvStructure

type PcscTlvStructure struct {
	Tag    uint8
	Length uint8
	Value  uint32 // This value is always in BIG ENDIAN format as documented in PCSC v2 part 10 ch 2.2 page 2. You can use ntohl() for example
}

type PcscV2Part10Property

type PcscV2Part10Property dword
const (
	PcscV2Part10Property_wLcdLayout                PcscV2Part10Property = 1
	PcscV2Part10Property_bEntryValidationCondition PcscV2Part10Property = 2
	PcscV2Part10Property_bTimeOut2                 PcscV2Part10Property = 3
	PcscV2Part10Property_wLcdMaxCharacters         PcscV2Part10Property = 4
	PcscV2Part10Property_wLcdMaxLines              PcscV2Part10Property = 5
	PcscV2Part10Property_bMinPINSize               PcscV2Part10Property = 6
	PcscV2Part10Property_bMaxPINSize               PcscV2Part10Property = 7
	PcscV2Part10Property_sFirmwareID               PcscV2Part10Property = 8
	PcscV2Part10Property_bPPDUSupport              PcscV2Part10Property = 9
	PcscV2Part10Property_dwMaxAPDUDataSize         PcscV2Part10Property = 10
	PcscV2Part10Property_wIdVendor                 PcscV2Part10Property = 11
	PcscV2Part10Property_wIdProduct                PcscV2Part10Property = 12
)

Properties returned by FEATURE_GET_TLV_PROPERTIES

type PinModifyStructure

type PinModifyStructure struct {
	TimerOut                 uint8    // timeout is seconds (00 means use default timeout)
	TimerOut2                uint8    // timeout in seconds after first key stroke
	FormatString             uint8    // formatting options
	PINBlockString           uint8    // bits 7-4 bit size of PIN length in APDU, bits 3-0 PIN block size in bytes after justification and formatting
	PINLengthFormat          uint8    // bits 7-5 RFU, bit 4 set if system units are bytes, clear if system units are bits, bits 3-0 PIN length position in system units
	InsertionOffsetOld       uint8    // Insertion position offset in bytes for the current PIN
	InsertionOffsetNew       uint8    // Insertion position offset in bytes for the new PIN
	PINMaxExtraDigit         uint16   // 0xXXYY where XX is minimum PIN size in digits, and YY is maximum PIN size in digits
	ConfirmPIN               uint8    // Flags governing need for confirmation of new PIN
	EntryValidationCondition uint8    // Conditions under which PIN entry should be considered complete
	NumberMessage            uint8    // Number of messages to display for PIN verification*/
	LangId                   uint16   // Language for messages. https://docs.microsoft.com/en-us/windows/win32/intl/language-identifier-constants-and-strings
	MsgIndex1                uint8    // index of 1st prompting message
	MsgIndex2                uint8    // index of 2d prompting message
	MsgIndex3                uint8    // index of 3d prompting message
	TeoPrologue              [3]uint8 // T=1 block prologue field to use (fill with 00)
	DataLength               uint32   // length of Data to be sent to the ICC
	Data                     []uint8  // Data to send to the ICC
}

Structure used with FEATURE_MODIFY_PIN_DIRECT

type PinPropertiesStructure

type PinPropertiesStructure struct {
	LcdLayout                uint16 // display characteristics
	EntryValidationCondition uint8
	TimeOut2                 uint8
}

Structure used with FEATURE_IFD_PIN_PROPERTIES

type PinVerifyStructure

type PinVerifyStructure struct {
	TimerOut                 uint8    // timeout is seconds (00 means use default timeout)
	TimerOut2                uint8    // timeout in seconds after first key stroke
	FormatString             uint8    // formatting options
	PINBlockString           uint8    // bits 7-4 bit size of PIN length in APDU, bits 3-0 PIN block size in bytes after justification and formatting
	PINLengthFormat          uint8    // bits 7-5 RFU, bit 4 set if system units are bytes, clear if system units are bits, bits 3-0 PIN length position in system units
	PINMaxExtraDigit         uint16   // 0xXXYY where XX is minimum PIN size in digits, and YY is maximum PIN size in digits
	EntryValidationCondition uint8    // Conditions under which PIN entry should be considered complete
	NumberMessage            uint8    // Number of messages to display for PIN verification
	LangId                   uint16   // Language for messages. https://docs.microsoft.com/en-us/windows/win32/intl/language-identifier-constants-and-strings
	MsgIndex                 uint8    // Message index (should be 00)
	TeoPrologue              [3]uint8 // T=1 block prologue field to use (fill with 00)
	DataLength               uint32   // length of Data to be sent to the ICC
	Data                     []uint8  // Data to send to the ICC
}

Structure used with FEATURE_VERIFY_PIN_DIRECT

type ReaderState

type ReaderState dword
const (
	SCardUnknown    ReaderState = 0x0001 // Unknown state
	SCardAbsent     ReaderState = 0x0002 // Card is absent
	SCardPresent    ReaderState = 0x0004 // Card is present
	SCardSwallowed  ReaderState = 0x0008 // Card not powered
	SCardPowered    ReaderState = 0x0010 // Card is powered
	SCardNegotiable ReaderState = 0x0020 // Ready for PTS
	SCardSpecific   ReaderState = 0x0040 // PTS has been set
)

func (*ReaderState) String

func (s *ReaderState) String() string

type SCardAttr

type SCardAttr dword
var (
	SCardAttrVendorName           SCardAttr = scardAttrValue(SCardClassVendorInfo, 0x0100)
	SCardAttrVendorIFDType        SCardAttr = scardAttrValue(SCardClassVendorInfo, 0x0101)
	SCardAttrVendorIFDVersion     SCardAttr = scardAttrValue(SCardClassVendorInfo, 0x0102)
	SCardAttrVendorIFDSerialNo    SCardAttr = scardAttrValue(SCardClassVendorInfo, 0x0103)
	SCardAttrChannelID            SCardAttr = scardAttrValue(SCardClassCommunications, 0x0110)
	SCardAttrAsyncProtocolTypes   SCardAttr = scardAttrValue(SCardClassProtocol, 0x0120)
	SCardAttrDefaultClk           SCardAttr = scardAttrValue(SCardClassProtocol, 0x0121)
	SCardAttrMaxClk               SCardAttr = scardAttrValue(SCardClassProtocol, 0x0122)
	SCardAttrDefaultDataRate      SCardAttr = scardAttrValue(SCardClassProtocol, 0x0123)
	SCardAttrMaxDataRate          SCardAttr = scardAttrValue(SCardClassProtocol, 0x0124)
	SCardAttrMaxIFSD              SCardAttr = scardAttrValue(SCardClassProtocol, 0x0125)
	SCardAttrSyncProtocolTypes    SCardAttr = scardAttrValue(SCardClassProtocol, 0x0126)
	SCardAttrPowerMgmtSupport     SCardAttr = scardAttrValue(SCardClassPowerMgmt, 0x0131)
	SCardAttrUserToCardAuthDevice SCardAttr = scardAttrValue(SCardClassSecurity, 0x0140)
	SCardAttrUserAuthInputDevice  SCardAttr = scardAttrValue(SCardClassSecurity, 0x0142)
	SCardAttrCharacteristics      SCardAttr = scardAttrValue(SCardClassMechanical, 0x0150)

	SCardAttrCurrentProtocolType SCardAttr = scardAttrValue(SCardClassIFDProtocol, 0x0201)
	SCardAttrCurrentClk          SCardAttr = scardAttrValue(SCardClassIFDProtocol, 0x0202)
	SCardAttrCurrentF            SCardAttr = scardAttrValue(SCardClassIFDProtocol, 0x0203)
	SCardAttrCurrentD            SCardAttr = scardAttrValue(SCardClassIFDProtocol, 0x0204)
	SCardAttrCurrentN            SCardAttr = scardAttrValue(SCardClassIFDProtocol, 0x0205)
	SCardAttrCurrentW            SCardAttr = scardAttrValue(SCardClassIFDProtocol, 0x0206)
	SCardAttrCurrentIFSC         SCardAttr = scardAttrValue(SCardClassIFDProtocol, 0x0207)
	SCardAttrCurrentIFSD         SCardAttr = scardAttrValue(SCardClassIFDProtocol, 0x0208)
	SCardAttrCurrentBWT          SCardAttr = scardAttrValue(SCardClassIFDProtocol, 0x0209)
	SCardAttrCurrentCWT          SCardAttr = scardAttrValue(SCardClassIFDProtocol, 0x020a)
	SCardAttrCurrentEBCEncoding  SCardAttr = scardAttrValue(SCardClassIFDProtocol, 0x020b)
	SCardAttrExtendedBWT         SCardAttr = scardAttrValue(SCardClassIFDProtocol, 0x020c)

	SCardAttrICCPresence        SCardAttr = scardAttrValue(SCardClassICCState, 0x0300)
	SCardAttrICCInterfaceStatus SCardAttr = scardAttrValue(SCardClassICCState, 0x0301)
	SCardAttrCurrentIOState     SCardAttr = scardAttrValue(SCardClassICCState, 0x0302)
	SCardAttrATRString          SCardAttr = scardAttrValue(SCardClassICCState, 0x0303)
	SCardAttrICCTYPEPerATR      SCardAttr = scardAttrValue(SCardClassICCState, 0x0304)

	SCardAttrESCReset       SCardAttr = scardAttrValue(SCardClassVendorDefined, 0xA000)
	SCardAttrESCCancel      SCardAttr = scardAttrValue(SCardClassVendorDefined, 0xA003)
	SCardAttrESCAuthRequest SCardAttr = scardAttrValue(SCardClassVendorDefined, 0xA005)
	SCardAttrMaxInput       SCardAttr = scardAttrValue(SCardClassVendorDefined, 0xA007)

	SCardAttrDeviceUnit           SCardAttr = scardAttrValue(SCardClassSystem, 0x0001)
	SCardAttrDeviceInUse          SCardAttr = scardAttrValue(SCardClassSystem, 0x0002)
	SCardAttrDeviceFriendlyNameA  SCardAttr = scardAttrValue(SCardClassSystem, 0x0003)
	SCardAttrDeviceSystemNameA    SCardAttr = scardAttrValue(SCardClassSystem, 0x0004)
	SCardAttrDeviceFriendlyNameW  SCardAttr = scardAttrValue(SCardClassSystem, 0x0005)
	SCardAttrDeviceSystemNameW    SCardAttr = scardAttrValue(SCardClassSystem, 0x0006)
	SCardAttrSuppressT1IFSRequest SCardAttr = scardAttrValue(SCardClassSystem, 0x0007)

	SCardAttrDeviceFriendlyName SCardAttr = SCardAttrDeviceFriendlyNameA
	SCardAttrDeviceSystemName   SCardAttr = SCardAttrDeviceSystemNameA
)

func (*SCardAttr) String

func (a *SCardAttr) String() string

type SCardClass

type SCardClass dword
const (
	SCardClassVendorInfo     SCardClass = 1      // Vendor information definitions
	SCardClassCommunications SCardClass = 2      // Communication definitions
	SCardClassProtocol       SCardClass = 3      // Protocol definitions
	SCardClassPowerMgmt      SCardClass = 4      // Power Management definitions
	SCardClassSecurity       SCardClass = 5      // Security Assurance definitions
	SCardClassMechanical     SCardClass = 6      // Mechanical characteristic definitions
	SCardClassVendorDefined  SCardClass = 7      // Vendor specific definitions
	SCardClassIFDProtocol    SCardClass = 8      // Interface Device Protocol options
	SCardClassICCState       SCardClass = 9      // ICC State specific definitions
	SCardClassSystem         SCardClass = 0x7fff // System-specific definitions
)

func (*SCardClass) String

func (c *SCardClass) String() string

type SCardContext

type SCardContext hnd

type SCardCtlCode

type SCardCtlCode dword
var (
	IoctlSmartCardVendorIfdExchange SCardCtlCode = scardCtlCodeFunc(1)
	IoctlFeatureVerifyPinDirect     SCardCtlCode = scardCtlCodeFunc(dword(FeatureVerifyPinDirect) + class2IoctlMagic)
	IoctlFeatureModifyPinDirect     SCardCtlCode = scardCtlCodeFunc(dword(FeatureModifyPinDirect) + class2IoctlMagic)
	IoctlFeatureMctReaderDirect     SCardCtlCode = scardCtlCodeFunc(dword(FeatureMctReaderDirect) + class2IoctlMagic)
	IoctlFeatureIfdPinProperties    SCardCtlCode = scardCtlCodeFunc(dword(FeatureIfdPinProperties) + class2IoctlMagic)
	IoctlFeatureGetTlvProperties    SCardCtlCode = scardCtlCodeFunc(dword(FeatureGetTlvProperties) + class2IoctlMagic)
)

type SCardDisposition

type SCardDisposition dword
const (
	// Do nothing on close
	SCardLeaveCard SCardDisposition = 0x0000
	// Reset on close
	SCardResetCard SCardDisposition = 0x0001
	// Power down on close
	SCardUnpowerCard SCardDisposition = 0x0002
	// Eject on close
	SCardEjectCard SCardDisposition = 0x0003
)

func (*SCardDisposition) String

func (d *SCardDisposition) String() string

type SCardHandle

type SCardHandle hnd

type SCardIORequest

type SCardIORequest struct {
	Protocol  dword // Protocol identifier
	PciLength dword // Protocol Control Information Length
}

Protocol Control Information (PCI)

var (
	SCardIoRequestT0  SCardIORequest
	SCardIoRequestT1  SCardIORequest
	SCardIoRequestRaw SCardIORequest
)

type SCardProtocol

type SCardProtocol dword
const (
	SCardProtocolUndefined SCardProtocol = 0x0000                            // protocol not set
	SCardProtocolUnset     SCardProtocol = SCardProtocolUndefined            // backward compat
	SCardProtocolT0        SCardProtocol = 0x0001                            // T=0 active protocol.
	SCardProtocolT1        SCardProtocol = 0x0002                            // T=1 active protocol.
	SCardProtocolRaw       SCardProtocol = 0x0004                            // Raw active protocol.
	SCardProtocolT15       SCardProtocol = 0x0008                            // T=15 protocol.
	SCardProtocolAny       SCardProtocol = SCardProtocolT0 | SCardProtocolT1 // IFD determines prot.
)

func (SCardProtocol) String

func (s SCardProtocol) String() string

type SCardReaderState

type SCardReaderState struct {
	Reader       string         // reader name
	UserData     unsafe.Pointer // user defined data
	CurrentState SCardState     // current state of reader at time of call
	EventState   SCardState     // state of reader after state change
	Atr          string         // Atr of inserted card
}

type SCardScope

type SCardScope dword
const (
	// Scope in user space
	SCardScopeUser SCardScope = 0x0000
	// Scope in terminal
	SCardScopeTerminal SCardScope = 0x0001
	// Scope in system
	SCardScopeSystem SCardScope = 0x0002
	// Scope is global
	SCardScopeGlobal SCardScope = 0x0003
)

func (*SCardScope) String

func (s *SCardScope) String() string

type SCardShareMode

type SCardShareMode dword
const (
	// Exclusive mode only
	SCardShareExclusive SCardShareMode = 0x0001
	// Shared mode only
	SCardShareShared SCardShareMode = 0x0002
	// Raw mode only
	SCardShareDirect SCardShareMode = 0x0003
)

func (*SCardShareMode) String

func (m *SCardShareMode) String() string

type SCardState

type SCardState dword
const (
	// App wants status
	SCardStateUnaware SCardState = 0x0000
	// Ignore this reader
	SCardStateIgnore SCardState = 0x0001
	// State has changed
	SCardStateChanged SCardState = 0x0002
	// Reader unknown
	SCardStateUnknown SCardState = 0x0004
	// Status unavailable
	SCardStateUnavailable SCardState = 0x0008
	// Card removed
	SCardStateEmpty SCardState = 0x0010
	// Card inserted
	SCardStatePresent SCardState = 0x0020
	// ATR matches card
	SCardStateAtrmatch SCardState = 0x0040
	// Exclusive Mode
	SCardStateExclusive SCardState = 0x0080
	// Shared Mode
	SCardStateInuse SCardState = 0x0100
	// Unresponsive card
	SCardStateMute SCardState = 0x0200
	// Unpowered card
	SCardStateUnpowered SCardState = 0x0400
)

func (*SCardState) String

func (s *SCardState) String() string

type Timeout

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

Timeout represents the timeout to be used with SCard related function.

func NewInfiniteTimeout

func NewInfiniteTimeout() Timeout

NewInfiniteTimeout creates a new Timeout with the InifiniteTimeout duration.

func NewTimeout

func NewTimeout(timeout time.Duration) Timeout

NewTimeout creates a new Timeout from the passed time.Duration.

If the passed duration is negative, the function returns a null timeout. If the passed duration exceeds InfiniteTimeout, the functions returns InfiniteTimeout.

func (*Timeout) Milliseconds

func (t *Timeout) Milliseconds() dword

Milliseconds returns the timeout duration as an integer millisecond count.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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