Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

SmartCardMBS.BeginTransaction
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method SmartCard MBS Tools Plugin 16.3 Yes Yes Yes Yes No
Function: Starts a transaction.
Notes:
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.

Feedback, Comments & Corrections

SmartCardMBS.CancelTransaction
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method SmartCard MBS Tools Plugin 16.3 Yes Yes Yes Yes No
Function: Cancels current transaction.
Notes: Lasterror is set.

Feedback, Comments & Corrections

SmartCardMBS.Constructor
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method SmartCard MBS Tools Plugin 16.3 Yes Yes Yes Yes No
Function: The private constructor.

Feedback, Comments & Corrections

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 Console & Web iOS
method SmartCard MBS Tools Plugin 16.3 Yes Yes Yes Yes No
Function: Direct control of the reader.
Notes:
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.

Feedback, Comments & Corrections

SmartCardMBS.Disconnect(Disposition as Integer = 0)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method SmartCard MBS Tools Plugin 16.3 Yes Yes Yes Yes No
Function: Terminates a connection previously opened between the calling application and a smart card in the target reader.
Notes:
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.

Feedback, Comments & Corrections

SmartCardMBS.EndTransaction(Disposition as Integer = 0)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method SmartCard MBS Tools Plugin 16.3 Yes Yes Yes Yes No
Function: Ends transaction.
Notes:
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.

Feedback, Comments & Corrections

SmartCardMBS.GetAttrib(AttrId as UInt32) as Memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method SmartCard MBS Tools Plugin 16.3 Yes Yes Yes Yes No
Function: Retrieves the current reader attributes for the given handle.
Notes:
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.

Feedback, Comments & Corrections

SmartCardMBS.ReadFile(FileID as MemoryBlock) as MemoryBlock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method SmartCard MBS Tools Plugin 18.5 Yes Yes Yes Yes No
Function: Read file from smart card with APDU protocol.
Notes:
Returns data as MemoryBlock or error message.
The first two bytes are status code.

Feedback, Comments & Corrections

SmartCardMBS.Reconnect(ShareMode as UInt32, PreferredProtocols as UInt32, Initialization as UInt32)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method SmartCard MBS Tools Plugin 16.3 Yes Yes Yes Yes No
Function: The Reconnect function reestablishes an existing connection between the calling application and a smart card.
Notes:
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.

Feedback, Comments & Corrections

SmartCardMBS.SetAttrib(AttrId as UInt32, mem as Memoryblock)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method SmartCard MBS Tools Plugin 16.3 Yes Yes Yes Yes No
Function: Sets the given reader attribute.
Notes:
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.

Feedback, Comments & Corrections

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 Console & Web iOS
method SmartCard MBS Tools Plugin 16.3 Yes Yes Yes Yes No
Function: Provides the current status of a smart card in a reader.
Notes:
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:

Feedback, Comments & Corrections

SmartCardMBS.Status(byref State as Integer, byref Protocol as Integer, byref CardID as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method SmartCard MBS Tools Plugin 16.3 Yes Yes Yes Yes No
Function: Provides the current status of a smart card in a reader.
Notes:
Same as other Status function, but without querying the name.
Lasterror is set.

See also:

Feedback, Comments & Corrections

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 Console & Web iOS
method SmartCard MBS Tools Plugin 16.3 Yes Yes Yes Yes No
Function: 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"
Notes:
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 pbSendBuffer 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.

Feedback, Comments & Corrections

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




Links
MBS Xojo blog