pcsc

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Rendered for darwin/amd64

Overview

Package pcsc provides a fluent Go API over the macOS PCSC framework.

Construction

New… functions create objects; each With… method sets one property and returns its receiver, so configuration calls chain. A <Type>FromID constructor adopts an Objective-C object obtained elsewhere.

Lifecycle

A wrapper releases its Objective-C object automatically once the garbage collector finds it unreachable. Call Release to relinquish the reference deterministically (for objects holding scarce resources); Release is idempotent, and afterwards the wrapper's methods are no-ops returning zero values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func G_rgSCardRawPci

func G_rgSCardRawPci() uintptr

G_rgSCardRawPci returns the address of the symbol g_rgSCardRawPci.

func G_rgSCardT0Pci

func G_rgSCardT0Pci() uintptr

G_rgSCardT0Pci returns the address of the symbol g_rgSCardT0Pci.

func G_rgSCardT1Pci

func G_rgSCardT1Pci() uintptr

G_rgSCardT1Pci returns the address of the symbol g_rgSCardT1Pci.

func MSCBeginTransaction

func MSCBeginTransaction(pConnection unsafe.Pointer) uint32

MSCBeginTransaction calls the PCSC framework function MSCBeginTransaction.

func MSCCancelEventWait

func MSCCancelEventWait() uint32

MSCCancelEventWait calls the PCSC framework function MSCCancelEventWait.

func MSCChangePIN

func MSCChangePIN(pConnection unsafe.Pointer, pinNum uint8, oldPinCodeSize uint8, newPinCodeSize uint8) (result uint32, pOldPinCode uint8, pNewPinCode uint8)

MSCChangePIN calls the PCSC framework function MSCChangePIN.

func MSCClearReset

func MSCClearReset(pConnection unsafe.Pointer) uint8

MSCClearReset calls the PCSC framework function MSCClearReset.

func MSCComputeCrypt

func MSCComputeCrypt(pConnection unsafe.Pointer, cryptInit unsafe.Pointer, inputDataSize uint32) (result uint32, pInputData uint8, pOutputData uint8, outputDataSize uint32)

MSCComputeCrypt calls the PCSC framework function MSCComputeCrypt.

func MSCCreatePIN

func MSCCreatePIN(pConnection unsafe.Pointer, pinNum uint8, pinAttempts uint8, pinCodeSize uint32, unblockCodeSize uint8) (result uint32, pPinCode uint8, pUnblockCode uint8)

MSCCreatePIN calls the PCSC framework function MSCCreatePIN.

func MSCDeleteObject

func MSCDeleteObject(pConnection unsafe.Pointer, objectID string, zeroFlag uint8) uint32

MSCDeleteObject calls the PCSC framework function MSCDeleteObject.

func MSCEndTransaction

func MSCEndTransaction(pConnection unsafe.Pointer, endAction uint32) uint32

MSCEndTransaction calls the PCSC framework function MSCEndTransaction.

func MSCEstablishConnection

func MSCEstablishConnection(tokenStruct unsafe.Pointer, sharingMode uint32, nameSize uint32, pConnection unsafe.Pointer) (result uint32, applicationName uint8)

MSCEstablishConnection calls the PCSC framework function MSCEstablishConnection.

func MSCExportKey

func MSCExportKey(pConnection unsafe.Pointer, keyNum uint8, pAddParams unsafe.Pointer, addParamsSize uint8) (result uint32, pKeyBlob uint8, keyBlobSize uint32)

MSCExportKey calls the PCSC framework function MSCExportKey.

func MSCExtAuthenticate

func MSCExtAuthenticate(pConnection unsafe.Pointer, keyNum uint8, cipherMode uint8, cipherDirection uint8, dataSize uint32) (result uint32, pData uint8)

MSCExtAuthenticate calls the PCSC framework function MSCExtAuthenticate.

func MSCExtendedFeature

func MSCExtendedFeature(pConnection unsafe.Pointer, extFeature uint32, outLength uint32) (result uint32, outData uint8, inData uint8, inLength uint32)

MSCExtendedFeature calls the PCSC framework function MSCExtendedFeature.

func MSCGenerateKeys

func MSCGenerateKeys(pConnection unsafe.Pointer, prvKeyNum uint8, pubKeyNum uint8, pParams unsafe.Pointer) uint32

MSCGenerateKeys calls the PCSC framework function MSCGenerateKeys.

func MSCGetCapabilities

func MSCGetCapabilities(pConnection unsafe.Pointer, tag uint32) (result uint32, value uint8, length uint32)

MSCGetCapabilities calls the PCSC framework function MSCGetCapabilities.

func MSCGetChallenge

func MSCGetChallenge(pConnection unsafe.Pointer, seedSize uint16, randomDataSize uint16) (result uint32, pSeed uint8, pRandomData uint8)

MSCGetChallenge calls the PCSC framework function MSCGetChallenge.

func MSCImportKey

func MSCImportKey(pConnection unsafe.Pointer, keyNum uint8, keyBlobSize uint32, pAddParams unsafe.Pointer, addParamsSize uint8) (result uint32, pKeyACL MSCKeyACL, pKeyBlob uint8, keyPolicy MSCKeyPolicy)

MSCImportKey calls the PCSC framework function MSCImportKey.

func MSCIsTokenChanged

func MSCIsTokenChanged(pConnection unsafe.Pointer) uint8

MSCIsTokenChanged calls the PCSC framework function MSCIsTokenChanged.

func MSCIsTokenKnown

func MSCIsTokenKnown(pConnection unsafe.Pointer) uint8

MSCIsTokenKnown calls the PCSC framework function MSCIsTokenKnown.

func MSCIsTokenMoved

func MSCIsTokenMoved(pConnection unsafe.Pointer) uint8

MSCIsTokenMoved calls the PCSC framework function MSCIsTokenMoved.

func MSCIsTokenReset

func MSCIsTokenReset(pConnection unsafe.Pointer) uint8

MSCIsTokenReset calls the PCSC framework function MSCIsTokenReset.

func MSCListPINs

func MSCListPINs(pConnection unsafe.Pointer) (result uint32, pPinBitMask uint16)

MSCListPINs calls the PCSC framework function MSCListPINs.

func MSCListTokens

func MSCListTokens(listScope uint32, tokenArray unsafe.Pointer) (result uint32, arrayLength uint32)

MSCListTokens calls the PCSC framework function MSCListTokens.

func MSCLogoutAll

func MSCLogoutAll(pConnection unsafe.Pointer) uint32

MSCLogoutAll calls the PCSC framework function MSCLogoutAll.

func MSCReadAllocateObject

func MSCReadAllocateObject(pConnection unsafe.Pointer, objectID string, pOutputData unsafe.Pointer, rwCallback unsafe.Pointer, addParams unsafe.Pointer) (result uint32, dataSize uint32)

MSCReadAllocateObject calls the PCSC framework function MSCReadAllocateObject.

func MSCReadObject

func MSCReadObject(pConnection unsafe.Pointer, objectID string, offset uint32, dataSize uint32, rwCallback unsafe.Pointer, addParams unsafe.Pointer) (result uint32, pOutputData uint8)

MSCReadObject calls the PCSC framework function MSCReadObject.

func MSCReleaseConnection

func MSCReleaseConnection(pConnection unsafe.Pointer, endAction uint32) uint32

MSCReleaseConnection calls the PCSC framework function MSCReleaseConnection.

func MSCUnblockPIN

func MSCUnblockPIN(pConnection unsafe.Pointer, pinNum uint8, unblockCodeSize uint32) (result uint32, pUnblockCode uint8)

MSCUnblockPIN calls the PCSC framework function MSCUnblockPIN.

func MSCVerifyPIN

func MSCVerifyPIN(pConnection unsafe.Pointer, pinNum uint8, pinCodeSize uint32) (result uint32, pPinCode uint8)

MSCVerifyPIN calls the PCSC framework function MSCVerifyPIN.

func MSCWaitForTokenEvent

func MSCWaitForTokenEvent(tokenArray unsafe.Pointer, arraySize uint32, timeoutValue uint32) uint32

MSCWaitForTokenEvent calls the PCSC framework function MSCWaitForTokenEvent.

func MSCWriteObject

func MSCWriteObject(pConnection unsafe.Pointer, objectID string, offset uint32, dataSize uint32, rwCallback unsafe.Pointer, addParams unsafe.Pointer) (result uint32, pInputData uint8)

MSCWriteObject calls the PCSC framework function MSCWriteObject.

func MscError

func MscError(errorCode int) string

MscError calls the PCSC framework function msc_error.

func SCardBeginTransaction

func SCardBeginTransaction(hCard int32) int32

SCardBeginTransaction calls the PCSC framework function SCardBeginTransaction.

func SCardCancel

func SCardCancel(hContext int32) int32

SCardCancel calls the PCSC framework function SCardCancel.

func SCardCancelTransaction

func SCardCancelTransaction(hCard int32) int32

SCardCancelTransaction calls the PCSC framework function SCardCancelTransaction.

func SCardConnect

func SCardConnect(hContext int32, szReader string, dwShareMode uint32, dwPreferredProtocols uint32) (result int32, phCard int32, pdwActiveProtocol uint32)

SCardConnect calls the PCSC framework function SCardConnect.

func SCardControl

func SCardControl(hCard int32, pbSendBuffer unsafe.Pointer, cbSendLength uint32, pbRecvBuffer unsafe.Pointer) (result int32, pcbRecvLength uint32)

SCardControl calls the PCSC framework function SCardControl.

func SCardControl132

func SCardControl132(hCard int32, dwControlCode uint32, pbSendBuffer unsafe.Pointer, cbSendLength uint32, pbRecvBuffer unsafe.Pointer, cbRecvLength uint32) (result int32, lpBytesReturned uint32)

SCardControl132 calls the PCSC framework function SCardControl132.

func SCardDisconnect

func SCardDisconnect(hCard int32, dwDisposition uint32) int32

SCardDisconnect calls the PCSC framework function SCardDisconnect.

func SCardEndTransaction

func SCardEndTransaction(hCard int32, dwDisposition uint32) int32

SCardEndTransaction calls the PCSC framework function SCardEndTransaction.

func SCardEstablishContext

func SCardEstablishContext(dwScope uint32, pvReserved1 unsafe.Pointer, pvReserved2 unsafe.Pointer) (result int32, phContext int32)

SCardEstablishContext calls the PCSC framework function SCardEstablishContext.

func SCardGetAttrib

func SCardGetAttrib(hCard int32, dwAttrId uint32) (result int32, pbAttr uint8, pcbAttrLen uint32)

SCardGetAttrib calls the PCSC framework function SCardGetAttrib.

func SCardGetStatusChange

func SCardGetStatusChange(hContext int32, dwTimeout uint32, rgReaderStates unsafe.Pointer, cReaders uint32) int32

SCardGetStatusChange calls the PCSC framework function SCardGetStatusChange.

func SCardIsValidContext

func SCardIsValidContext(hContext int32) int32

SCardIsValidContext calls the PCSC framework function SCardIsValidContext.

func SCardListReaderGroups

func SCardListReaderGroups(hContext int32, mszGroups string) (result int32, pcchGroups uint32)

SCardListReaderGroups calls the PCSC framework function SCardListReaderGroups.

func SCardListReaders

func SCardListReaders(hContext int32, mszGroups string, mszReaders string) (result int32, pcchReaders uint32)

SCardListReaders calls the PCSC framework function SCardListReaders.

func SCardReconnect

func SCardReconnect(hCard int32, dwShareMode uint32, dwPreferredProtocols uint32, dwInitialization uint32) (result int32, pdwActiveProtocol uint32)

SCardReconnect calls the PCSC framework function SCardReconnect.

func SCardReleaseContext

func SCardReleaseContext(hContext int32) int32

SCardReleaseContext calls the PCSC framework function SCardReleaseContext.

func SCardSetAttrib

func SCardSetAttrib(hCard int32, dwAttrId uint32, pbAttr unsafe.Pointer, cbAttrLen uint32) int32

SCardSetAttrib calls the PCSC framework function SCardSetAttrib.

func SCardSetTimeout

func SCardSetTimeout(hContext int32, dwTimeout uint32) int32

SCardSetTimeout calls the PCSC framework function SCardSetTimeout.

func SCardStatus

func SCardStatus(hCard int32, mszReaderNames string) (result int32, pcchReaderLen uint32, pdwState uint32, pdwProtocol uint32, pbAtr uint8, pcbAtrLen uint32)

SCardStatus calls the PCSC framework function SCardStatus.

func SCardUnload

func SCardUnload()

SCardUnload calls the PCSC framework function SCardUnload.

func StringifyError added in v0.17.0

func StringifyError(err int32) string

StringifyError calls the PCSC framework function pcsc_stringify_error.

Types

type CFDyLibPointers

type CFDyLibPointers struct {
	PvfWriteFramework   unsafe.Pointer
	PvfInitializePlugin unsafe.Pointer
	PvfIdentifyToken    unsafe.Pointer
	PvfFinalizePlugin   unsafe.Pointer
	PvfGetStatus        unsafe.Pointer
	PvfGetCapabilities  unsafe.Pointer
	PvfExtendedFeature  unsafe.Pointer
	PvfGenerateKeys     unsafe.Pointer
	PvfImportKey        unsafe.Pointer
	PvfExportKey        unsafe.Pointer
	PvfComputeCrypt     unsafe.Pointer
	PvfExtAuthenticate  unsafe.Pointer
	PvfListKeys         unsafe.Pointer
	PvfCreatePIN        unsafe.Pointer
	PvfVerifyPIN        unsafe.Pointer
	PvfChangePIN        unsafe.Pointer
	PvfUnblockPIN       unsafe.Pointer
	PvfListPINs         unsafe.Pointer
	PvfCreateObject     unsafe.Pointer
	PvfDeleteObject     unsafe.Pointer
	PvfWriteObject      unsafe.Pointer
	PvfReadObject       unsafe.Pointer
	PvfListObjects      unsafe.Pointer
	PvfLogoutAll        unsafe.Pointer
	PvfGetChallenge     unsafe.Pointer
}

type LPCFDyLibPointers

type LPCFDyLibPointers = *CFDyLibPointers

LPCFDyLibPointers is an alias for the CFDyLibPointers value type.

type LPSCARD_IO_REQUEST

type LPSCARD_IO_REQUEST = *SCARDIOREQUEST

LPSCARD_IO_REQUEST is an alias for the _SCARD_IO_REQUEST value type.

type MSCCertACL

type MSCCertACL = MSCObjectACL

MSCCertACL is an alias for the MSCObjectACL value type.

type MSCCryptInit

type MSCCryptInit struct {
	KeyNum          uint8
	CipherMode      uint8
	CipherDirection uint8
	OptParams       unsafe.Pointer
	OptParamsSize   uint16
}

type MSCEventWaitInfo

type MSCEventWaitInfo struct {
	ArraySize  uint32
	TokenArray unsafe.Pointer
	AppData    unsafe.Pointer
	CallBack   unsafe.Pointer
}

type MSCGenKeyParams

type MSCGenKeyParams struct {
	AlgoType         uint8
	KeySize          uint16
	PrivateKeyACL    MSCKeyACL
	PublicKeyACL     MSCKeyACL
	PrivateKeyPolicy MSCKeyPolicy
	PublicKeyPolicy  MSCKeyPolicy
	KeyGenOptions    uint8
	POptParams       unsafe.Pointer
	OptParamsSize    uint32
}

type MSCInitTokenParams

type MSCInitTokenParams struct {
	TransportKey           [264]uint8
	TransportKeyLen        uint32
	TransportBehavior      uint8
	ObjectMemory           uint32
	NewTransportKey        [264]uint8
	NewTransportKeyLen     uint32
	DefaultCHV             [264]uint8
	DefaultCHVLen          uint32
	DefaultCHVTries        uint8
	DefaultCHVUnblock      [264]uint8
	DefaultCHVUnblockSize  uint32
	DefaultCHVUnblockTries uint8
	CreateObjectACL        uint16
	CreateKeysACL          uint16
	CreatePINsACL          uint16
	MaxNumberKeys          uint8
	MaxNumberPINs          uint8
	MaxNumberObjects       uint16
}

func MSCWriteFramework

func MSCWriteFramework(pConnection unsafe.Pointer) (result uint32, pInitParams MSCInitTokenParams)

MSCWriteFramework calls the PCSC framework function MSCWriteFramework.

type MSCKeyACL

type MSCKeyACL struct {
	ReadPermission  uint16
	WritePermission uint16
	UsePermission   uint16
}

type MSCKeyInfo

type MSCKeyInfo struct {
	KeyNum     uint8
	KeyType    uint8
	KeyPartner uint8
	KeyMapping uint8
	KeySize    uint16
	KeyPolicy  MSCKeyPolicy
	KeyACL     MSCKeyACL
}

func MSCGetKeyAttributes

func MSCGetKeyAttributes(pConnection unsafe.Pointer, keyNumber uint8) (result uint32, pKeyInfo MSCKeyInfo)

MSCGetKeyAttributes calls the PCSC framework function MSCGetKeyAttributes.

func MSCListKeys

func MSCListKeys(pConnection unsafe.Pointer, seqOption uint8) (result uint32, pKeyInfo MSCKeyInfo)

MSCListKeys calls the PCSC framework function MSCListKeys.

type MSCKeyPolicy

type MSCKeyPolicy struct {
	CipherMode      uint16
	CipherDirection uint16
}

type MSCLPCertACL

type MSCLPCertACL = *MSCObjectACL

MSCLPCertACL is an alias for the MSCObjectACL value type.

type MSCLPCryptInit

type MSCLPCryptInit = *MSCCryptInit

MSCLPCryptInit is an alias for the MSCCryptInit value type.

type MSCLPEventWaitInfo

type MSCLPEventWaitInfo = *MSCEventWaitInfo

MSCLPEventWaitInfo is an alias for the MSCEventWaitInfo value type.

type MSCLPGenKeyParams

type MSCLPGenKeyParams = *MSCGenKeyParams

MSCLPGenKeyParams is an alias for the MSCGenKeyParams value type.

type MSCLPInitTokenParams

type MSCLPInitTokenParams = *MSCInitTokenParams

MSCLPInitTokenParams is an alias for the MSCInitTokenParams value type.

type MSCLPKeyACL

type MSCLPKeyACL = *MSCKeyACL

MSCLPKeyACL is an alias for the MSCKeyACL value type.

type MSCLPKeyInfo

type MSCLPKeyInfo = *MSCKeyInfo

MSCLPKeyInfo is an alias for the MSCKeyInfo value type.

type MSCLPKeyPolicy

type MSCLPKeyPolicy = *MSCKeyPolicy

MSCLPKeyPolicy is an alias for the MSCKeyPolicy value type.

type MSCLPObjectACL

type MSCLPObjectACL = *MSCObjectACL

MSCLPObjectACL is an alias for the MSCObjectACL value type.

type MSCLPObjectInfo

type MSCLPObjectInfo = *MSCObjectInfo

MSCLPObjectInfo is an alias for the MSCObjectInfo value type.

type MSCLPStatusInfo

type MSCLPStatusInfo = *MSCStatusInfo

MSCLPStatusInfo is an alias for the MSCStatusInfo value type.

type MSCLPTokenConnection

type MSCLPTokenConnection = *MSCTokenConnection

MSCLPTokenConnection is an alias for the MSCTokenConnection value type.

type MSCLPTokenInfo

type MSCLPTokenInfo = *MSCTokenInfo

MSCLPTokenInfo is an alias for the MSCTokenInfo value type.

type MSCObjectACL

type MSCObjectACL struct {
	ReadPermission   uint16
	WritePermission  uint16
	DeletePermission uint16
}

func MSCCreateObject

func MSCCreateObject(pConnection unsafe.Pointer, objectID string, objectSize uint32) (result uint32, pObjectACL MSCObjectACL)

MSCCreateObject calls the PCSC framework function MSCCreateObject.

type MSCObjectInfo

type MSCObjectInfo struct {
	ObjectID   [16]int8
	ObjectSize uint32
	ObjectACL  MSCObjectACL
}

func MSCGetObjectAttributes

func MSCGetObjectAttributes(pConnection unsafe.Pointer, objectID string) (result uint32, pObjectInfo MSCObjectInfo)

MSCGetObjectAttributes calls the PCSC framework function MSCGetObjectAttributes.

func MSCListObjects

func MSCListObjects(pConnection unsafe.Pointer, seqOption uint8) (result uint32, pObjectInfo MSCObjectInfo)

MSCListObjects calls the PCSC framework function MSCListObjects.

type MSCStatusInfo

type MSCStatusInfo struct {
	AppVersion  uint16
	SwVersion   uint16
	FreeMemory  uint32
	TotalMemory uint32
	UsedPINs    uint8
	UsedKeys    uint8
	LoggedID    uint16
}

func MSCGetStatus

func MSCGetStatus(pConnection unsafe.Pointer) (result uint32, pStatusInfo MSCStatusInfo)

MSCGetStatus calls the PCSC framework function MSCGetStatus.

type MSCTokenConnection

type MSCTokenConnection struct {
	HContext       int32
	HCard          int32
	IOType         unsafe.Pointer
	PMAC           [128]uint8
	MACSize        uint32
	TokenLibHandle unsafe.Pointer
	LibPointers    CFDyLibPointers
	TokenInfo      MSCTokenInfo
	LoggedIDs      uint8
	ShareMode      uint32
	RwCallback     unsafe.Pointer
}

type MSCTokenInfo

type MSCTokenInfo struct {
	TokenName     [150]int8
	SlotName      [52]int8
	SvProvider    [200]int8
	TokenID       [33]uint8
	TokenApp      [64]uint8
	TokenAppLen   uint32
	TokenIDLength uint32
	TokenState    uint32
	TokenType     uint32
	AddParams     unsafe.Pointer
	AddParamsSize uint32
}

type PSCARD_IO_REQUEST

type PSCARD_IO_REQUEST = *SCARDIOREQUEST

PSCARD_IO_REQUEST is an alias for the _SCARD_IO_REQUEST value type.

type SCARDIOREQUEST

type SCARDIOREQUEST struct {
	DwProtocol  uint32
	CbPCILength uint32
}

Protocol Control Information (PCI)

func SCardTransmit

func SCardTransmit(hCard int32, pioSendPci unsafe.Pointer, pbSendBuffer unsafe.Pointer, cbSendLength uint32) (result int32, pioRecvPci SCARDIOREQUEST, pbRecvBuffer uint8, pcbRecvLength uint32)

SCardTransmit calls the PCSC framework function SCardTransmit.

type SCARD_IO_REQUEST

type SCARD_IO_REQUEST = SCARDIOREQUEST

SCARD_IO_REQUEST is an alias for the _SCARD_IO_REQUEST value type.

type SCARD_READERSTATE_A

type SCARD_READERSTATE_A struct {
	SzReader       unsafe.Pointer
	PvUserData     unsafe.Pointer
	DwCurrentState uint32
	DwEventState   uint32
	CbAtr          uint32
	RgbAtr         [33]uint8
}

Jump to

Keyboard shortcuts

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