LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
logicalaccess::STidSTRReaderCardAdapter Class Reference

A default STidSTR reader/card adapter class. More...

#include <stidstrreadercardadapter.hpp>

Inheritance diagram for logicalaccess::STidSTRReaderCardAdapter:
logicalaccess::ISO7816ReaderCardAdapter logicalaccess::ReaderCardAdapter

Public Member Functions

 STidSTRReaderCardAdapter (STidCmdType adapterType=STID_CMD_READER, bool iso7816=false)
 Constructor.
 
virtual ~STidSTRReaderCardAdapter ()
 Destructor.
 
ByteVector adaptCommand (const ByteVector &command) override
 Adapt the command to send to the reader.
 
ByteVector adaptAnswer (const ByteVector &answer) override
 Adapt the asnwer received from the reader.
 
virtual ByteVector sendCommand (unsigned short commandCode, const ByteVector &command, long int timeout=-1)
 Send a command to the reader.
 
ByteVector sendCommand (const ByteVector &command, long timeout=-1) override
 Send a command to the reader.
 
ByteVector calculateHMAC (const ByteVector &buf) const
 Calculate the message HMAC.
 
- Public Member Functions inherited from logicalaccess::ISO7816ReaderCardAdapter
virtual ISO7816Response sendAPDUCommand (const ByteVector &data)
 Send an APDU command to the reader.
 
virtual ISO7816Response sendAPDUCommand (unsigned char cla, unsigned char ins, unsigned char p1, unsigned char p2, unsigned char lc, const ByteVector &data, unsigned char le)
 Send an APDU command to the reader.
 
virtual ISO7816Response sendAPDUCommand (unsigned char cla, unsigned char ins, unsigned char p1, unsigned char p2, unsigned char lc, const ByteVector &data)
 Send an APDU command to the reader.
 
virtual ISO7816Response sendAPDUCommand (unsigned char cla, unsigned char ins, unsigned char p1, unsigned char p2, const ByteVector &data)
 Send an APDU command to the reader.
 
virtual ISO7816Response sendAPDUCommand (unsigned char cla, unsigned char ins, unsigned char p1, unsigned char p2, unsigned char lc, unsigned char le)
 Send an APDU command to the reader without data.
 
virtual ISO7816Response sendAPDUCommand (unsigned char cla, unsigned char ins, unsigned char p1, unsigned char p2, unsigned char le)
 Send an APDU command to the reader without data.
 
virtual ISO7816Response sendAPDUCommand (unsigned char cla, unsigned char ins, unsigned char p1, unsigned char p2)
 Send an APDU command to the reader without data.
 
virtual ISO7816Response sendExtendedAPDUCommand (unsigned char cla, unsigned char ins, unsigned char p1, unsigned char p2, unsigned short lc, const ByteVector &data)
 Send an extended APDU command to the reader.
 
virtual ISO7816Response sendExtendedAPDUCommand (unsigned char cla, unsigned char ins, unsigned char p1, unsigned char p2, unsigned short lc, const ByteVector &data, unsigned short le)
 Send an extended APDU command to the reader.
 
ByteVector adaptCommand (const ByteVector &command) override
 Adapt the command to send to the reader.
 
ByteVector adaptAnswer (const ByteVector &answer) override
 Adapt the answer received from the reader.
 
void setCrypto (std::shared_ptr< ISO24727Crypto > crypto)
 
- Public Member Functions inherited from logicalaccess::ReaderCardAdapter
virtual ~ReaderCardAdapter ()
 
 ReaderCardAdapter ()
 
virtual ByteVector adaptCommand (const ByteVector &command)
 Adapt the command to send to the reader.
 
virtual ByteVector adaptAnswer (const ByteVector &answer)
 Adapt the answer received from the reader.
 
std::shared_ptr< DataTransportgetDataTransport () const
 Get the data transport.
 
void setDataTransport (std::shared_ptr< DataTransport > dataTransport)
 Set the data transport.
 
virtual ByteVector sendCommand (const ByteVector &command, long timeout=-1)
 Send a command to the reader.
 
virtual std::shared_ptr< ResultCheckergetResultChecker () const
 Get the result checker.
 
virtual void setResultChecker (std::shared_ptr< ResultChecker > checker)
 Set the result checker.
 

Static Public Attributes

static const unsigned char SOF = 0x02
 The start of message value.
 

Protected Member Functions

std::shared_ptr< STidSTRReaderUnitgetSTidSTRReaderUnit () const
 
ByteVector sendMessage (unsigned short commandCode, const ByteVector &command)
 Process message data to send.
 
ByteVector receiveMessage (const ByteVector &data, unsigned char &statusCode)
 Process message response to return plain message data and status code.
 
void CheckError (unsigned char statusCode) const
 Check status code and throw exception on error.
 
ByteVector getIV ()
 Get the initialization vector for encryption.
 

Protected Attributes

STidCmdType d_adapterType
 The adapter type.
 
bool d_iso7816
 Use iso7816 / transparent mode.
 
unsigned short d_lastCommandCode
 The last command code sent.
 
ByteVector d_lastIV
 The last IV to use.
 
- Protected Attributes inherited from logicalaccess::ReaderCardAdapter
std::shared_ptr< DataTransportd_dataTransport
 The data transport.
 
std::shared_ptr< ResultCheckerd_ResultChecker
 The result checker.
 

Detailed Description

A default STidSTR reader/card adapter class.

Constructor & Destructor Documentation

◆ STidSTRReaderCardAdapter()

logicalaccess::STidSTRReaderCardAdapter::STidSTRReaderCardAdapter ( STidCmdType  adapterType = STID_CMD_READER,
bool  iso7816 = false 
)
explicit

Constructor.

Parameters
adapterTypeThe adapter type.
iso7816ISO7816 communication type (transparent mode)

◆ ~STidSTRReaderCardAdapter()

logicalaccess::STidSTRReaderCardAdapter::~STidSTRReaderCardAdapter ( )
virtual

Destructor.

Member Function Documentation

◆ adaptAnswer()

ByteVector logicalaccess::STidSTRReaderCardAdapter::adaptAnswer ( const ByteVector answer)
overridevirtual

Adapt the asnwer received from the reader.

Parameters
answerThe answer received.
Returns
The adapted answer received.

Reimplemented from logicalaccess::ISO7816ReaderCardAdapter.

◆ adaptCommand()

ByteVector logicalaccess::STidSTRReaderCardAdapter::adaptCommand ( const ByteVector command)
overridevirtual

Adapt the command to send to the reader.

Parameters
commandThe command to send.
Returns
The adapted command to send.

Reimplemented from logicalaccess::ISO7816ReaderCardAdapter.

◆ calculateHMAC()

ByteVector logicalaccess::STidSTRReaderCardAdapter::calculateHMAC ( const ByteVector buf) const

Calculate the message HMAC.

Parameters
bufThe message buffer.
Returns
The HMAC.

◆ CheckError()

void logicalaccess::STidSTRReaderCardAdapter::CheckError ( unsigned char  statusCode) const
protected

Check status code and throw exception on error.

Parameters
statusCodeThe status code.

◆ getIV()

ByteVector logicalaccess::STidSTRReaderCardAdapter::getIV ( )
protected

Get the initialization vector for encryption.

Returns
The IV.
Remarks
This behavior is a security threat into STid communication protocol !

◆ getSTidSTRReaderUnit()

std::shared_ptr< STidSTRReaderUnit > logicalaccess::STidSTRReaderCardAdapter::getSTidSTRReaderUnit ( ) const
protected

◆ receiveMessage()

ByteVector logicalaccess::STidSTRReaderCardAdapter::receiveMessage ( const ByteVector data,
unsigned char &  statusCode 
)
protected

Process message response to return plain message data and status code.

Parameters
dataThe raw data from reader.
statusCodeWill contains the response status code.
Returns
The plain message data.

◆ sendCommand() [1/2]

ByteVector logicalaccess::STidSTRReaderCardAdapter::sendCommand ( const ByteVector command,
long  timeout = -1 
)
overridevirtual

Send a command to the reader.

Parameters
commandThe command buffer.
timeoutThe command timeout.
Returns
the result of the command.

Reimplemented from logicalaccess::ReaderCardAdapter.

◆ sendCommand() [2/2]

ByteVector logicalaccess::STidSTRReaderCardAdapter::sendCommand ( unsigned short  commandCode,
const ByteVector command,
long int  timeout = -1 
)
virtual

Send a command to the reader.

Parameters
commandCodeThe command code.
commandThe command buffer.
timeoutThe command timeout.
Returns
The result of the command.

◆ sendMessage()

ByteVector logicalaccess::STidSTRReaderCardAdapter::sendMessage ( unsigned short  commandCode,
const ByteVector command 
)
protected

Process message data to send.

Parameters
commandCodeThe command code.
commandThe command message data.
Returns
The processed message (signed/ciphered).

Member Data Documentation

◆ d_adapterType

STidCmdType logicalaccess::STidSTRReaderCardAdapter::d_adapterType
protected

The adapter type.

◆ d_iso7816

bool logicalaccess::STidSTRReaderCardAdapter::d_iso7816
protected

Use iso7816 / transparent mode.

◆ d_lastCommandCode

unsigned short logicalaccess::STidSTRReaderCardAdapter::d_lastCommandCode
protected

The last command code sent.

◆ d_lastIV

ByteVector logicalaccess::STidSTRReaderCardAdapter::d_lastIV
protected

The last IV to use.

◆ SOF

const unsigned char logicalaccess::STidSTRReaderCardAdapter::SOF = 0x02
static

The start of message value.


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