LibLogicalAccess  2.5.0
An Open Source RFID Library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
logicalaccess::ISO7816Commands Class Referenceabstract

The ISO7816 commands class. More...

#include <iso7816commands.hpp>

Inheritance diagram for logicalaccess::ISO7816Commands:
logicalaccess::Commands logicalaccess::ICommands logicalaccess::ISO7816ISO7816Commands logicalaccess::TwicISO7816Commands

Public Member Functions

 ISO7816Commands ()
 
 ISO7816Commands (std::string ct)
 
virtual ~ISO7816Commands ()
 
virtual ByteVector readBinary (size_t length, size_t offset, unsigned short efid=0)=0
 Read binary data.
 
virtual void writeBinary (const ByteVector &data, size_t offset, unsigned short efid=0)=0
 Write binary data.
 
virtual void updateBinary (const ByteVector &data, size_t offset, unsigned short efid=0)=0
 Update binary data.
 
virtual void eraseBinary (size_t offset, unsigned short efid=0)=0
 Erase binary data.
 
virtual ByteVector getData (unsigned short dataObject, size_t length=0)=0
 Get data.
 
virtual ByteVector getDataList (int64_t dataObject, unsigned short efid=ISO7816_DATA_OBJECT_SELECTED, unsigned char listtag=ISO7816_DATA_OBJECT_HEADERLIST, size_t length=0)
 Get data.
 
virtual ByteVector getDataList (TLVPtr tlv, size_t length=0, unsigned short efid=ISO7816_DATA_OBJECT_SELECTED)
 Get data.
 
virtual ByteVector getDataList (const ByteVector &data, size_t length=0, unsigned short efid=ISO7816_DATA_OBJECT_SELECTED)=0
 Get data.
 
virtual void putData (const ByteVector &data, unsigned short dataObject)=0
 Put data.
 
virtual ByteVector getResponse (unsigned char maxlength=0)=0
 Get response.
 
virtual void selectFile (ISOSelectFileP1 p1, ISOSelectFileP2 p2, unsigned short efid)
 Select a file under current DF by the file identifier.
 
virtual void selectFile (unsigned short efid)
 Select a file under current DF by the file identifier.
 
virtual void selectFile (const ByteVector &dfname)
 Select a file by the DF name.
 
virtual void selectFile (unsigned char p1, unsigned char p2, const ByteVector &data)=0
 Select a file.
 
virtual ByteVector readRecords (unsigned short fid=0, unsigned char start_record=0, ISORecords record_number=ISO_RECORD_ONERECORD)=0
 Read records.
 
virtual void appendrecord (const ByteVector &data=ByteVector(), unsigned short fid=0)=0
 Append a record to a file.
 
virtual ByteVector getChallenge (unsigned int length=8)=0
 Get the ISO challenge for authentication.
 
virtual void externalAuthenticate (unsigned char algorithm=0x00, bool globalReference=false, unsigned char keyno=0x00, const ByteVector &data=ByteVector())=0
 ISO external authenticate.
 
virtual ByteVector externalAuthenticate (unsigned char algorithm, bool globalReference, unsigned char keyno, const ByteVector &data, unsigned char le)=0
 ISO external authenticate.
 
virtual ByteVector internalAuthenticate (unsigned char algorithm=0x00, bool globalReference=false, unsigned char keyno=0x00, const ByteVector &RPCD2=ByteVector(), unsigned int length=16)=0
 ISO internal authenticate.
 
virtual ByteVector generalAuthenticate (unsigned char algorithm, bool globalReference, unsigned char keyno, const ByteVector &dataField, unsigned char le)=0
 ISO general authenticate.
 
virtual ByteVector generalAuthenticate_challenge (unsigned char algorithm, bool globalReference, unsigned char keyno)=0
 
virtual ByteVector generalAuthenticate_response (unsigned char algorithm, bool globalReference, unsigned char keyno, const ByteVector &data)=0
 
virtual void removeApplication (const ByteVector &data, ISORemoveApplicationP1 p1=P1_STATE_OPERATIONAL_OR_INITIALIZATION_TO_CREATION)=0
 
virtual void removeApplication (TLVPtr tlv, ISORemoveApplicationP1 p1=P1_STATE_OPERATIONAL_OR_INITIALIZATION_TO_CREATION)
 
virtual ByteVector applicationManagementRequest (const ByteVector &data, ISOApplicationManagementRequestP1 p1=P1_STATE_CREATION_TO_OPERATIONAL, unsigned char p2=0x00)=0
 
virtual ByteVector applicationManagementRequest (TLVPtr tlv, ISOApplicationManagementRequestP1 p1=P1_STATE_CREATION_TO_OPERATIONAL, unsigned char p2=0x00)
 
- Public Member Functions inherited from logicalaccess::Commands
 Commands ()=delete
 Constructor.
 
virtual ~Commands ()
 
std::shared_ptr< ChipgetChip () const override
 Get the chip.
 
virtual void setChip (std::shared_ptr< Chip > chip)
 Set the chip.
 
std::shared_ptr< ReaderCardAdaptergetReaderCardAdapter () const override
 Get the reader/card adapter.
 
virtual void setReaderCardAdapter (std::shared_ptr< ReaderCardAdapter > adapter)
 Set the reader/card adapter.
 
virtual const std::string & getCmdType () const
 Get the cmd name.
 
virtual void setCmdType (const std::string &command_type)
 Set the cmd name.
 
- Public Member Functions inherited from logicalaccess::ICommands
virtual ~ICommands ()=default
 
virtual std::shared_ptr< ChipgetChip () const =0
 Get the chip.
 
virtual std::shared_ptr< ReaderCardAdaptergetReaderCardAdapter () const =0
 Get the reader/card adapter.
 

Additional Inherited Members

- Protected Member Functions inherited from logicalaccess::Commands
 Commands (std::string commandtype)
 Constructor.
 
- Protected Attributes inherited from logicalaccess::Commands
std::shared_ptr< ReaderCardAdapterd_readerCardAdapter
 The reader/card adapter.
 
std::weak_ptr< Chipd_chip
 The chip.
 
std::string d_commandtype
 The command type.
 

Detailed Description

The ISO7816 commands class.

Constructor & Destructor Documentation

◆ ISO7816Commands() [1/2]

logicalaccess::ISO7816Commands::ISO7816Commands ( )
inline

◆ ISO7816Commands() [2/2]

logicalaccess::ISO7816Commands::ISO7816Commands ( std::string  ct)
inlineexplicit

◆ ~ISO7816Commands()

logicalaccess::ISO7816Commands::~ISO7816Commands ( )
virtual

Member Function Documentation

◆ appendrecord()

virtual void logicalaccess::ISO7816Commands::appendrecord ( const ByteVector data = ByteVector(),
unsigned short  fid = 0 
)
pure virtual

Append a record to a file.

Parameters
dataThe record data
fidThe FID

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ applicationManagementRequest() [1/2]

virtual ByteVector logicalaccess::ISO7816Commands::applicationManagementRequest ( const ByteVector data,
ISOApplicationManagementRequestP1  p1 = P1_STATE_CREATION_TO_OPERATIONAL,
unsigned char  p2 = 0x00 
)
pure virtual

◆ applicationManagementRequest() [2/2]

ByteVector logicalaccess::ISO7816Commands::applicationManagementRequest ( TLVPtr  tlv,
ISOApplicationManagementRequestP1  p1 = P1_STATE_CREATION_TO_OPERATIONAL,
unsigned char  p2 = 0x00 
)
virtual

◆ eraseBinary()

virtual void logicalaccess::ISO7816Commands::eraseBinary ( size_t  offset,
unsigned short  efid = 0 
)
pure virtual

Erase binary data.

Parameters
offsetThe erase offset.
efidThe EF identifier to set as current.

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ externalAuthenticate() [1/2]

virtual ByteVector logicalaccess::ISO7816Commands::externalAuthenticate ( unsigned char  algorithm,
bool  globalReference,
unsigned char  keyno,
const ByteVector data,
unsigned char  le 
)
pure virtual

ISO external authenticate.

Parameters
algorithmThe ISO algorithm to use for authentication.
globalReferenceTrue if the referenced key to authenticate is global (e.g. an MF secific key), false otherwise (e.g. DF specific key). false otherwise.
keynoThe key number.
dataThe data.
leExpected response length.
Returns
The authentication response.

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ externalAuthenticate() [2/2]

virtual void logicalaccess::ISO7816Commands::externalAuthenticate ( unsigned char  algorithm = 0x00,
bool  globalReference = false,
unsigned char  keyno = 0x00,
const ByteVector data = ByteVector() 
)
pure virtual

ISO external authenticate.

Parameters
algorithmThe ISO algorithm to use for authentication.
globalReferenceTrue if the referenced key to authenticate is global (e.g. an MF secific key), false otherwise (e.g. DF specific key).
keynoThe key number.
dataThe data.

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ generalAuthenticate()

virtual ByteVector logicalaccess::ISO7816Commands::generalAuthenticate ( unsigned char  algorithm,
bool  globalReference,
unsigned char  keyno,
const ByteVector dataField,
unsigned char  le 
)
pure virtual

ISO general authenticate.

Parameters
algorithmThe ISO algorithm to use for authentication.
globalReferenceTrue if the referenced key to authenticate is global (e.g. an MF secific key), false otherwise (e.g. DF specific key). false otherwise.
keynoThe key number.
dataFieldThe data.
leExpected response length.
Returns
The authentication response.

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ generalAuthenticate_challenge()

virtual ByteVector logicalaccess::ISO7816Commands::generalAuthenticate_challenge ( unsigned char  algorithm,
bool  globalReference,
unsigned char  keyno 
)
pure virtual

◆ generalAuthenticate_response()

virtual ByteVector logicalaccess::ISO7816Commands::generalAuthenticate_response ( unsigned char  algorithm,
bool  globalReference,
unsigned char  keyno,
const ByteVector data 
)
pure virtual

◆ getChallenge()

virtual ByteVector logicalaccess::ISO7816Commands::getChallenge ( unsigned int  length = 8)
pure virtual

Get the ISO challenge for authentication.

Parameters
lengthThe challenge length (8 = 2K3DES, 16 = 3K3DES and AES)
Returns
The ISO challenge.

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ getData()

virtual ByteVector logicalaccess::ISO7816Commands::getData ( unsigned short  dataObject,
size_t  length = 0 
)
pure virtual

Get data.

Parameters
dataObjectThe data object to get.
lengthThe expected object length.
Returns
The data of the object.

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ getDataList() [1/3]

virtual ByteVector logicalaccess::ISO7816Commands::getDataList ( const ByteVector data,
size_t  length = 0,
unsigned short  efid = ISO7816_DATA_OBJECT_SELECTED 
)
pure virtual

Get data.

Parameters
dataThe data object list to get.
lengthThe expected object length.
Returns
The data of the object.

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ getDataList() [2/3]

ByteVector logicalaccess::ISO7816Commands::getDataList ( int64_t  dataObject,
unsigned short  efid = ISO7816_DATA_OBJECT_SELECTED,
unsigned char  listtag = ISO7816_DATA_OBJECT_HEADERLIST,
size_t  length = 0 
)
virtual

Get data.

Parameters
dataObjectThe data object to get.
listtagThe list tag.
lengthThe expected object length.
Returns
The data of the object.

◆ getDataList() [3/3]

ByteVector logicalaccess::ISO7816Commands::getDataList ( TLVPtr  tlv,
size_t  length = 0,
unsigned short  efid = ISO7816_DATA_OBJECT_SELECTED 
)
virtual

Get data.

Parameters
tlvThe tlv with data object list to get.
lengthThe expected object length.
Returns
The data of the object.

◆ getResponse()

virtual ByteVector logicalaccess::ISO7816Commands::getResponse ( unsigned char  maxlength = 0)
pure virtual

Get response.

Parameters
maxlengthThe maximum expected length.
Returns
The response data.

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ internalAuthenticate()

virtual ByteVector logicalaccess::ISO7816Commands::internalAuthenticate ( unsigned char  algorithm = 0x00,
bool  globalReference = false,
unsigned char  keyno = 0x00,
const ByteVector RPCD2 = ByteVector(),
unsigned int  length = 16 
)
pure virtual

ISO internal authenticate.

Parameters
algorithmThe ISO algorithm to use for authentication.
globalReferenceTrue if the referenced key to authenticate is global (e.g. an MF secific key), false otherwise (e.g. DF specific key).
keynoThe key number.
RPCD2The RPCD2.
lengthThe length.
Returns
The cryptogram.

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ putData()

virtual void logicalaccess::ISO7816Commands::putData ( const ByteVector data,
unsigned short  dataObject 
)
pure virtual

Put data.

Parameters
dataThe buffer that contains data.
dataLengthThe buffer length.
dataObjectThe data object to get.

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ readBinary()

virtual ByteVector logicalaccess::ISO7816Commands::readBinary ( size_t  length,
size_t  offset,
unsigned short  efid = 0 
)
pure virtual

Read binary data.

Parameters
dataThe buffer that will contains data.
dataLengthThe buffer length.
offsetThe read offset.
efidThe EF identifier to set as current.
Returns
True on success, false otherwise.

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ readRecords()

virtual ByteVector logicalaccess::ISO7816Commands::readRecords ( unsigned short  fid = 0,
unsigned char  start_record = 0,
ISORecords  record_number = ISO_RECORD_ONERECORD 
)
pure virtual

Read records.

Parameters
fidThe FID
start_recordThe start record (0 = read last written record)
record_numberThe number of records to read
Returns
The record(s) data

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ removeApplication() [1/2]

virtual void logicalaccess::ISO7816Commands::removeApplication ( const ByteVector data,
ISORemoveApplicationP1  p1 = P1_STATE_OPERATIONAL_OR_INITIALIZATION_TO_CREATION 
)
pure virtual

◆ removeApplication() [2/2]

void logicalaccess::ISO7816Commands::removeApplication ( TLVPtr  tlv,
ISORemoveApplicationP1  p1 = P1_STATE_OPERATIONAL_OR_INITIALIZATION_TO_CREATION 
)
virtual

◆ selectFile() [1/4]

void logicalaccess::ISO7816Commands::selectFile ( const ByteVector dfname)
virtual

Select a file by the DF name.

Parameters
dfnameThe DF name.

◆ selectFile() [2/4]

void logicalaccess::ISO7816Commands::selectFile ( ISOSelectFileP1  p1,
ISOSelectFileP2  p2,
unsigned short  efid 
)
virtual

Select a file under current DF by the file identifier.

Parameters
p1The P1 parameter.
p2The P2 parameter.
efidThe file identifier.

◆ selectFile() [3/4]

virtual void logicalaccess::ISO7816Commands::selectFile ( unsigned char  p1,
unsigned char  p2,
const ByteVector data 
)
pure virtual

Select a file.

Parameters
p1The parameter 1.
p2The parameter 2.
dataThe data buffer.

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ selectFile() [4/4]

void logicalaccess::ISO7816Commands::selectFile ( unsigned short  efid)
virtual

Select a file under current DF by the file identifier.

Parameters
efidThe file identifier.

◆ updateBinary()

virtual void logicalaccess::ISO7816Commands::updateBinary ( const ByteVector data,
size_t  offset,
unsigned short  efid = 0 
)
pure virtual

Update binary data.

Parameters
dataThe buffer that contains data to update.
dataLengthThe buffer length.
offsetThe update offset.
efidThe EF identifier to set as current.

Implemented in logicalaccess::ISO7816ISO7816Commands.

◆ writeBinary()

virtual void logicalaccess::ISO7816Commands::writeBinary ( const ByteVector data,
size_t  offset,
unsigned short  efid = 0 
)
pure virtual

Write binary data.

Parameters
dataThe buffer that contains data to write.
dataLengthThe buffer length.
offsetThe write offset.
efidThe EF identifier to set as current.

Implemented in logicalaccess::ISO7816ISO7816Commands.


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