Platforms to show: All Mac Windows Linux Cross-Platform

Back to SmartCardMBS class.

SmartCardMBS.BeginTransaction

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SmartCard MBS Tools Plugin 16.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Starts a transaction.

The function waits for the completion of all other transactions before it begins. After the transaction starts, all other applications are blocked from accessing the smart card while the transaction is in progress.

If a transaction is held on the card for more than five seconds with no operations happening on that card, then the card is reset. Calling any of the Smart Card and Reader Access Functions or Direct Card Access Functions on the card that is transacted results in the timer being reset to continue allowing the transaction to be used.
The BeginTransaction function is a smart card and reader access function. For more information about other access functions, see Smart Card and Reader Access Functions.

Lasterror is set.

SmartCardMBS.CancelTransaction

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SmartCard MBS Tools Plugin 16.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Cancels current transaction.

Lasterror is set.

SmartCardMBS.Constructor   Private

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SmartCard MBS Tools Plugin 16.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
The private constructor.

SmartCardMBS.Control(ControlCode as Integer, input as ptr, inputLength as UInt32, output as ptr, byref outputLength as UInt32)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SmartCard MBS Tools Plugin 16.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Direct control of the reader.

You can call it any time after a successful call to SmartCard.Connect and before a successful call to SmartCard.Disconnect. The effect on the state of the reader depends on the control code.

ControlCode: Control code for the operation. This value identifies the specific operation to be performed.
Input: Pointer to a buffer that contains the data required to perform the operation. This parameter can be nil if the ControlCode parameter specifies an operation that does not require input data.
inputLength: Size, in bytes, of the buffer pointed to by Input.
output: Pointer to a buffer that receives the operation's output data. This parameter can be nil if the ControlCode parameter specifies an operation that does not produce output data.
outputLength: On input the size, in bytes, of the buffer pointed to by output. On output the receives the size, in bytes, of the data stored into the buffer pointed to by output.

Lasterror is set.

SmartCardMBS.Disconnect(Disposition as Integer = 0)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SmartCard MBS Tools Plugin 16.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Terminates a connection previously opened between the calling application and a smart card in the target reader.

Disposition: Action to take on the card in the connected reader on close.
can be:
kUnpowerCardPower down the card and reset it (Cold Reset).
kResetCardReset the card (Warm Reset).
kLeaveCardDo not do anything special on reconnect.
kEjectCardEject card.
Lasterror is set.

SmartCardMBS.EndTransaction(Disposition as Integer = 0)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SmartCard MBS Tools Plugin 16.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Ends transaction.

Completes a previously declared transaction, allowing other applications to resume interactions with the card.

Disposition: Action to take on the card in the connected reader on close. Can be Eject, Leave, Reset or Unpower. See constants.

Lasterror is set.

SmartCardMBS.GetAttrib(AttrId as UInt32) as Memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SmartCard MBS Tools Plugin 16.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Retrieves the current reader attributes for the given handle.

It does not affect the state of the reader, driver, or card.
The plugin first queries for size of attribute and on success queries again to get the data and return it as a memoryblock.

AttrId: The attribute ID. See kAttribute* constants.

Lasterror is set.

SmartCardMBS.ReadFile(FileID as MemoryBlock) as MemoryBlock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SmartCard MBS Tools Plugin 18.5 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Read file from smart card with APDU protocol.

Returns data as MemoryBlock or error message.
The first two bytes are status code.

For Swiss health cards, the relevant IDs are 2F06 and 2F07.

For Belgian EID:

4031ID RN
4032SGN RN
4033ID Address
4034SGN Address
4035ID Photo

You find the IDs for files usually in documentation or your card!
For some cards you may first need to move down a hierarchy of folders to get an item via Transmit().

Some examples using this method:

SmartCardMBS.Reconnect(ShareMode as UInt32, PreferredProtocols as UInt32, Initialization as UInt32)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SmartCard MBS Tools Plugin 16.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
The Reconnect function reestablishes an existing connection between the calling application and a smart card.

This function moves a card handle from direct access to general access, or acknowledges and clears an error condition that is preventing further access to the card.

Initialization can be one of the following:
kUnpowerCardPower down the card and reset it (Cold Reset).
kResetCardReset the card (Warm Reset).
kLeaveCardDo not do anything special on reconnect.

ShareMode: A flag that indicates whether other applications may form connections to the card. Use one of SmartCardMBS.kShare* constants. e.g. kShareExclusive
PreferredProtocols: A bitmask of acceptable protocols for the connection. Possible values may be combined with the OR operation. Use SmartCardMBS.kProtocol* constants. e.g. kProtocolT1

Lasterror and ActiveProtocol are set.

SmartCardMBS.SetAttrib(AttrId as UInt32, mem as Memoryblock)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SmartCard MBS Tools Plugin 16.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Sets the given reader attribute.

It does not affect the state of the reader, reader driver, or smart card. Not all attributes are supported by all readers (nor can they be set at all times) as many of the attributes are under direct control of the transport protocol.

AttrId: The attribute ID. See kAttribute* constants.
Mem: The data to store.

Lasterror is set.

SmartCardMBS.Status(byref Reader as string, byref State as Integer, byref Protocol as Integer, byref CardID as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SmartCard MBS Tools Plugin 16.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Provides the current status of a smart card in a reader.

You can call it any time after a successful call to SCardConnect and before a successful call to SCardDisconnect. It does not affect the state of the reader or reader driver.

Provides reader name, state of card (see kState constants), Protocol (see kProtocol constants) and CardID.

State: Current state of the smart card in the reader. Upon success, it receives one of the following state indicators.
Protocol: Current protocol, if any. The returned value is meaningful only if the returned value of pdwState is kCardStateSpecific.
CardID: 32-byte buffer that receives the ATR string from the currently inserted card, if available.

Lasterror is set.

See also:

SmartCardMBS.Status(byref State as Integer, byref Protocol as Integer, byref CardID as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SmartCard MBS Tools Plugin 16.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Provides the current status of a smart card in a reader.

Same as other Status function, but without querying the name.
Lasterror is set.

See also:

SmartCardMBS.Transmit(ioSendPci as Ptr, SendBuffer as ptr, SendLength as UInt32, ioRecvPci as ptr, RecvBuffer as Ptr, byref RecvLength as UInt32)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SmartCard MBS Tools Plugin 16.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Sends a service request to the smart card and expects to receive data back from the card.
Example
dim card as SmartCardMBS // your card

dim header as new memoryBlock(8)

header.Int32Value(0) = 2 // T1
header.Int32Value(4) = 8 // size of this block

dim command as new MemoryBlock(5)
command.Int8Value(0) = 0
command.Int8Value(1) = &hCA
command.Int8Value(2) = 1
command.Int8Value(3) = &h82
command.Int8Value(4) = 2

dim buffer as new MemoryBlock(512)
dim ReceiveHeader as new MemoryBlock(8)

dim RecvLength as UInt32
card.Transmit(header, command, command.Size, ReceiveHeader, buffer, RecvLength)

MsgBox "Received "+str(RecvLength)+" bytes"

ioSendPci:
A pointer to the protocol header structure for the instruction. This buffer is in the format of an SCARD_IO_REQUEST structure, followed by the specific protocol control information (PCI).
For the T=0, T=1, and Raw protocols, the PCI structure is constant. The smart card subsystem supplies a global T=0, T=1, or Raw PCI structure, which you can reference by using the symbols SCARD_PCI_T0, SCARD_PCI_T1, and SCARD_PCI_RAW respectively.

SendBuffer:
A pointer to the actual data to be written to the card.
For T=0, the data parameters are placed into the address pointed to by SendBuffer according to the following structure:

TypenameDescription
ByteClaThe instruction class
ByteInsThe instruction code
ByteP1Parameter to the instruction
ByteP2Parameter to the instruction
ByteP3Size of I/O transfer

The data sent to the card should immediately follow the send buffer. In the special case where no data is sent to the card and no data is expected in return, P3 is not sent.

SendLength:
The length, in bytes, of the SendBuffer parameter.
For T=0, in the special case where no data is sent to the card and no data expected in return, this length must reflect that the P3 member is not being sent; the length should be 4.

ioRecvPci:
Pointer to the protocol header structure for the instruction, followed by a buffer in which to receive any returned protocol control information (PCI) specific to the protocol in use. This parameter can be nil if no PCI is returned.

RecvBuffer:
Pointer to any data returned from the card.
For T=0, the data is immediately followed by the SW1 and SW2 status bytes. If no data is returned from the card, then this buffer will only contain the SW1 and SW2 status bytes.

RecvLength:
Supplies the length, in bytes, of the RecvBuffer parameter and receives the actual number of bytes received from the smart card. This value cannot be SCARD_AUTOALLOCATE because Transmit does not support SCARD_AUTOALLOCATE.
For T=0, the receive buffer must be at least two bytes long to receive the SW1 and SW2 status bytes.

see also
https://msdn.microsoft.com/en-us/library/windows/desktop/aa379804(v=vs.85).aspx

Lasterror is set.

The items on this page are in the following plugins: MBS Tools Plugin.


The biggest plugin in space...