The SmartcardT0Request function copies data from the user buffer to the send buffer that the driver uses to transmit data to the reader.
NTSTATUS
SmartcardT0Request(
PSMARTCARD_EXTENSION SmartcardExtension
);
SmartcardT0Request returns an NTSTATUS value. Possible values are the following.
Value | Meaning |
---|---|
STATUS_SUCCESS | Buffer successfully set up. |
STATUS_BUFFER_OVERFLOW | The internal buffer is too small to hold the data to send to the smart card. To fix this error, allocate a larger send buffer. See SmartcardInitialize for details. |
This function copies data from the user buffer to SmartcardExtension->SmartcardRequest.Buffer and adjusts SmartcardExtension->SmartcardRequest.BufferLength to the number of bytes to be transmitted to the smart card. The driver then simply writes this buffer to the card and reads the bytes coming from the card into SmartcardExtension->SmartcardReply.Buffer, as described in SmartcardT0Reply (VxD).
If your driver needs to send header data to the reader before the actual T=0 data, set SmartcardExtension->SmartcardRequest.BufferLength to the number of bytes you need for your header before you call this function. The packet will look like this:
You can copy your header data to the buffer either before or after a call to SmartcardT0Request, depending on which is easier to do in your driver.
A usual T=0 transmission can be done in the following way:
// Copy data from user buffer to SmartcardExtension->SmartcardRequest.Buffer
status = SmartcardT0Request(
SmartcardExtension
);
if (status != STATUS_SUCCESS)
return status;
// Transmit SmartcardExtension->SmartcardRequest.Buffer to smart card
status = DriverSendDataToSmartcard(…);
if (status != STATUS_SUCCESS)
return status;
// Receive data from smart card into SmartcardExtension->SmartcardReply.Buffer
status = DriverReceiveDataFromSmartcard(…);
if (status != STATUS_SUCCESS)
return status;
// Copy data from SmartcardExtension->SmartcardReply.Buffer back to user buffer
// and return to caller
return SmartcardT0Reply(
SmartcardExtension
);
SmartcardT0Reply does not handle the T=0 protocol data exchange for VxD drivers. Refer to the driver example scrcp8t.c, which is part of the Microsoft® Windows NT® DDK, or refer to ISO 7816 part 3, section 8.
For information on the SmartcardT0Request function for WDM drivers, see SmartcardT0Request (WDM).