NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
Classes | Public Member Functions | List of all members
BiometricEvaluation::Device::Smartcard Class Reference

Representation of a single ISO 7816 smartcard in the system. More...

#include <be_device_smartcard.h>

Classes

class  APDU
 
struct  APDUException
 Exception thrown when a command fails. More...
 
struct  APDUResponse
 The data and status words returned by the card in response to a command. More...
 

Public Member Functions

 Smartcard (unsigned int cardNum)
 Connect to the Nth card in the system independent of any application installed on the card. More...
 
 Smartcard (unsigned int cardNum, const Memory::uint8Array &appID)
 Connect to the Nth card in the system and activate the application with the given identifier. More...
 
Memory::uint8Array getDedicatedFileObject (const Memory::uint8Array &objectID)
 Read a data object from the application dedicated file. More...
 
APDUResponse sendAPDU (Device::Smartcard::APDU &apdu)
 Send an APDU to a card using the best transmission method available for the card. More...
 
Memory::uint8Array getLastAPDU () const
 Obtain a copy of the last APDU sent to the card. More...
 
Memory::uint8Array getLastResponseData () const
 Obtain a copy of the last response data returned from the card. More...
 
std::string getReaderID () const
 Obtain the identifier of the reader that the smartcard is plugged into. More...
 
void setDryrun (bool state)
 Set the 'dryrun' state. More...
 
 ~Smartcard ()
 Destructor. More...
 
 Smartcard (Smartcard &&other) noexcept
 Move constructor. More...
 
Smartcardoperator= (Smartcard &&other) noexcept
 Move assignment. More...
 

Detailed Description

Representation of a single ISO 7816 smartcard in the system.

A card can be associated with an application that is present on the card. Smartcards are accessed with a command/response protocol, and this class provides the capability to retrieve the response status and data whether the command succeeds or fails.

Definition at line 31 of file be_device_smartcard.h.

Constructor & Destructor Documentation

◆ Smartcard() [1/3]

BiometricEvaluation::Device::Smartcard::Smartcard ( unsigned int  cardNum)

Connect to the Nth card in the system independent of any application installed on the card.

Cards are numbered according to reader sequencing. Therefore, the first card (number 0) is expected to be in the first reader.

Parameters
[in]cardNumThe number of the card to attach to.
Exceptions
Error::ParameterErrorNo card exists for the given card number.
Error::StrategyErrorFailed to access at least one of the readers.

◆ Smartcard() [2/3]

BiometricEvaluation::Device::Smartcard::Smartcard ( unsigned int  cardNum,
const Memory::uint8Array appID 
)

Connect to the Nth card in the system and activate the application with the given identifier.

Cards are numbered according to reader sequencing. Therefore, the first card (number 0) is expected to be in the first reader. The response data from application activation can be retrieved with the getLastResponseData() method.

Parameters
[in]cardNumThe number of the card to attach to.
[in]appIDThe ID of the application to activate on the card.
Exceptions
APDUExceptionAn error occurred activating the application. The status word fields on the exception's response object should be read to determine the error.
Error::ParameterErrorNo card exists for the given card number with the given application ID.
Error::StrategyErrorFailed to access at least one of the readers.

◆ ~Smartcard()

BiometricEvaluation::Device::Smartcard::~Smartcard ( )

Destructor.

◆ Smartcard() [3/3]

BiometricEvaluation::Device::Smartcard::Smartcard ( Smartcard &&  other)
noexcept

Move constructor.

Smartcard objects are movable, maintaining the single instance of the access to the physical card. This allows the object to be placed in an STL container.

Member Function Documentation

◆ getDedicatedFileObject()

Memory::uint8Array BiometricEvaluation::Device::Smartcard::getDedicatedFileObject ( const Memory::uint8Array objectID)

Read a data object from the application dedicated file.

The objectID parameter must be a TLV octet string with the tag set to one of these values:

  • 0x5C - A tag list data object.
  • 0x5D - A header list data object.
  • 0x4D - An extended header list data object.
Parameters
[in]objectIDThe ID of the requested object.
Returns
The dedicated file object.
Exceptions
APDUExceptionAn error occurred activating the application. The status word fields on the exception's response object should be read to determine the error. The data field of the response may contain partial data from the card.
Error::StrategyErrorAn error occurred when communicating with the card.
Error::ParameterErrorThe object ID is too large.

◆ sendAPDU()

APDUResponse BiometricEvaluation::Device::Smartcard::sendAPDU ( Device::Smartcard::APDU apdu)

Send an APDU to a card using the best transmission method available for the card.

Parameters
[in,out]apduThe APDU to be sent. Fields may be modified by the function, specifically the length field(s).
Exceptions
APDUExceptionThe status words from the command response are something other than 0x9000. The status word fields on the exception's response object should read to determine the result of the command. The data field of the response may contain partial data from the card.
Error::StrategyErrorAn error occurred when communicating with the card.

◆ getLastAPDU()

Memory::uint8Array BiometricEvaluation::Device::Smartcard::getLastAPDU ( ) const

Obtain a copy of the last APDU sent to the card.

Returns
The last sent APDU as an array of octets.

◆ getLastResponseData()

Memory::uint8Array BiometricEvaluation::Device::Smartcard::getLastResponseData ( ) const

Obtain a copy of the last response data returned from the card.

Returns
The last response data as an array of octets. May be empty.

◆ getReaderID()

std::string BiometricEvaluation::Device::Smartcard::getReaderID ( ) const

Obtain the identifier of the reader that the smartcard is plugged into.

Returns
The string identifier of the reader.

◆ setDryrun()

void BiometricEvaluation::Device::Smartcard::setDryrun ( bool  state)

Set the 'dryrun' state.

Parameters
[in]stateTrue when the APDU should be created, but not sent to the card. @seealso getLastAPDU()

◆ operator=()

Smartcard & BiometricEvaluation::Device::Smartcard::operator= ( Smartcard &&  other)
noexcept

Move assignment.

Smartcard objects are movable, maintaining the single instance of the access to the physical card. This allows the object to be placed in an STL container.


The documentation for this class was generated from the following file: