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

The ISO7816 commands base class. More...

#include <iso7816iso7816commands.hpp>

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

Public Member Functions

 ISO7816ISO7816Commands ()
 Constructor.
 
 ISO7816ISO7816Commands (std::string)
 
virtual ~ISO7816ISO7816Commands ()
 Destructor.
 
ByteVector readBinary (size_t length, size_t offset, unsigned short efid=0) override
 Read binary data.
 
void writeBinary (const ByteVector &data, size_t offset, unsigned short efid=0) override
 Write binary data.
 
void updateBinary (const ByteVector &data, size_t offset, unsigned short efid=0) override
 Update binary data.
 
void eraseBinary (size_t offset, unsigned short efid=0) override
 Erase binary data.
 
ByteVector getData (unsigned short dataObject, size_t length) override
 Get data.
 
ByteVector getDataList (const ByteVector &data, size_t length, unsigned short efid=ISO7816_DATA_OBJECT_SELECTED) override
 Get data.
 
void putData (const ByteVector &data, unsigned short dataObject) override
 Put data.
 
ByteVector getResponse (unsigned char maxlength=0) override
 Get response.
 
void selectFile (unsigned char p1, unsigned char p2, const ByteVector &data) override
 Select a file.
 
ByteVector readRecords (unsigned short fid=0, unsigned char start_record=0, ISORecords record_number=ISO_RECORD_ONERECORD) override
 Read records.
 
void appendrecord (const ByteVector &data=ByteVector(), unsigned short fid=0) override
 Append a record to a file.
 
ByteVector getChallenge (unsigned int length=8) override
 Get the ISO challenge for authentication.
 
void externalAuthenticate (unsigned char algorithm=0x00, bool globalReference=false, unsigned char keyno=0x00, const ByteVector &data=ByteVector()) override
 ISO external authenticate.
 
ByteVector externalAuthenticate (unsigned char algorithm, bool globalReference, unsigned char keyno, const ByteVector &data, unsigned char le) override
 ISO external authenticate.
 
ByteVector internalAuthenticate (unsigned char algorithm=0x00, bool globalReference=false, unsigned char keyno=0x00, const ByteVector &RPCD2=ByteVector(), unsigned int length=16) override
 ISO internal authenticate.
 
ByteVector generalAuthenticate (unsigned char algorithm, bool globalReference, unsigned char keyno, const ByteVector &dataField, unsigned char le) override
 ISO general authenticate.
 
ByteVector generalAuthenticate_challenge (unsigned char algorithm, bool globalReference, unsigned char keyno) override
 
ByteVector generalAuthenticate_response (unsigned char algorithm, bool globalReference, unsigned char keyno, const ByteVector &data) override
 
void removeApplication (const ByteVector &data, ISORemoveApplicationP1 p1=P1_STATE_OPERATIONAL_OR_INITIALIZATION_TO_CREATION) override
 
ByteVector applicationManagementRequest (const ByteVector &data, ISOApplicationManagementRequestP1 p1=P1_STATE_CREATION_TO_OPERATIONAL, unsigned char p2=0x00) override
 
std::shared_ptr< ISO7816ReaderCardAdaptergetISO7816ReaderCardAdapter () const
 Get the ISO7816 reader/card adapter.
 
- Public Member Functions inherited from logicalaccess::ISO7816Commands
 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.
 

Static Protected Member Functions

static void setP1P2 (size_t offset, unsigned short efid, unsigned char &p1, unsigned char &p2)
 Set P1 and P2 parameters.
 

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 base class.

Constructor & Destructor Documentation

◆ ISO7816ISO7816Commands() [1/2]

logicalaccess::ISO7816ISO7816Commands::ISO7816ISO7816Commands ( )

Constructor.

◆ ISO7816ISO7816Commands() [2/2]

logicalaccess::ISO7816ISO7816Commands::ISO7816ISO7816Commands ( std::string  ct)
explicit

◆ ~ISO7816ISO7816Commands()

logicalaccess::ISO7816ISO7816Commands::~ISO7816ISO7816Commands ( )
virtual

Destructor.

Member Function Documentation

◆ appendrecord()

void logicalaccess::ISO7816ISO7816Commands::appendrecord ( const ByteVector data = ByteVector(),
unsigned short  fid = 0 
)
overridevirtual

Append a record to a file.

Parameters
dataThe record data
fidThe FID

Implements logicalaccess::ISO7816Commands.

◆ applicationManagementRequest()

ByteVector logicalaccess::ISO7816ISO7816Commands::applicationManagementRequest ( const ByteVector data,
ISOApplicationManagementRequestP1  p1 = P1_STATE_CREATION_TO_OPERATIONAL,
unsigned char  p2 = 0x00 
)
overridevirtual

◆ eraseBinary()

void logicalaccess::ISO7816ISO7816Commands::eraseBinary ( size_t  offset,
unsigned short  efid = 0 
)
overridevirtual

Erase binary data.

Parameters
offsetThe erase offset.
efidThe EF identifier to set as current.
Returns
True on success, false otherwise.

Implements logicalaccess::ISO7816Commands.

◆ externalAuthenticate() [1/2]

ByteVector logicalaccess::ISO7816ISO7816Commands::externalAuthenticate ( unsigned char  algorithm,
bool  globalReference,
unsigned char  keyno,
const ByteVector data,
unsigned char  le 
)
overridevirtual

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.

Implements logicalaccess::ISO7816Commands.

◆ externalAuthenticate() [2/2]

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

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.

Implements logicalaccess::ISO7816Commands.

◆ generalAuthenticate()

ByteVector logicalaccess::ISO7816ISO7816Commands::generalAuthenticate ( unsigned char  algorithm,
bool  globalReference,
unsigned char  keyno,
const ByteVector dataField,
unsigned char  le 
)
overridevirtual

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.

Implements logicalaccess::ISO7816Commands.

◆ generalAuthenticate_challenge()

ByteVector logicalaccess::ISO7816ISO7816Commands::generalAuthenticate_challenge ( unsigned char  algorithm,
bool  globalReference,
unsigned char  keyno 
)
overridevirtual

◆ generalAuthenticate_response()

ByteVector logicalaccess::ISO7816ISO7816Commands::generalAuthenticate_response ( unsigned char  algorithm,
bool  globalReference,
unsigned char  keyno,
const ByteVector data 
)
overridevirtual

◆ getChallenge()

ByteVector logicalaccess::ISO7816ISO7816Commands::getChallenge ( unsigned int  length = 8)
overridevirtual

Get the ISO challenge for authentication.

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

Implements logicalaccess::ISO7816Commands.

◆ getData()

ByteVector logicalaccess::ISO7816ISO7816Commands::getData ( unsigned short  dataObject,
size_t  length 
)
overridevirtual

Get data.

Parameters
dataThe buffer that will contains data.
dataObjectThe data object to get.
lengthThe buffer length.
Returns
True on success, false otherwise.

Implements logicalaccess::ISO7816Commands.

◆ getDataList()

ByteVector logicalaccess::ISO7816ISO7816Commands::getDataList ( const ByteVector data,
size_t  length,
unsigned short  efid = ISO7816_DATA_OBJECT_SELECTED 
)
overridevirtual

Get data.

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

Implements logicalaccess::ISO7816Commands.

◆ getISO7816ReaderCardAdapter()

std::shared_ptr< ISO7816ReaderCardAdapter > logicalaccess::ISO7816ISO7816Commands::getISO7816ReaderCardAdapter ( ) const
inline

Get the ISO7816 reader/card adapter.

Returns
The ISO7816 reader/card adapter.

◆ getResponse()

ByteVector logicalaccess::ISO7816ISO7816Commands::getResponse ( unsigned char  maxlength = 0)
overridevirtual

Get response.

Parameters
maxlengthThe maximum expected length.
Returns
The response data.

Implements logicalaccess::ISO7816Commands.

◆ internalAuthenticate()

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

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.

Implements logicalaccess::ISO7816Commands.

◆ putData()

void logicalaccess::ISO7816ISO7816Commands::putData ( const ByteVector data,
unsigned short  dataObject 
)
overridevirtual

Put data.

Parameters
dataThe buffer that contains data.
dataLengthThe buffer length.
dataObjectThe data object to get.
Returns
True on success, false otherwise.

Implements logicalaccess::ISO7816Commands.

◆ readBinary()

ByteVector logicalaccess::ISO7816ISO7816Commands::readBinary ( size_t  length,
size_t  offset,
unsigned short  efid = 0 
)
overridevirtual

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.

Implements logicalaccess::ISO7816Commands.

◆ readRecords()

ByteVector logicalaccess::ISO7816ISO7816Commands::readRecords ( unsigned short  fid = 0,
unsigned char  start_record = 0,
ISORecords  record_number = ISO_RECORD_ONERECORD 
)
overridevirtual

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

Implements logicalaccess::ISO7816Commands.

◆ removeApplication()

void logicalaccess::ISO7816ISO7816Commands::removeApplication ( const ByteVector data,
ISORemoveApplicationP1  p1 = P1_STATE_OPERATIONAL_OR_INITIALIZATION_TO_CREATION 
)
overridevirtual

◆ selectFile()

void logicalaccess::ISO7816ISO7816Commands::selectFile ( unsigned char  p1,
unsigned char  p2,
const ByteVector data 
)
overridevirtual

Select a file.

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

Implements logicalaccess::ISO7816Commands.

◆ setP1P2()

void logicalaccess::ISO7816ISO7816Commands::setP1P2 ( size_t  offset,
unsigned short  efid,
unsigned char &  p1,
unsigned char &  p2 
)
staticprotected

Set P1 and P2 parameters.

Parameters
offsetThe starting offset.
efidThe EF identifier.
p1The parameter 1.
p2The parameter 2.

◆ updateBinary()

void logicalaccess::ISO7816ISO7816Commands::updateBinary ( const ByteVector data,
size_t  offset,
unsigned short  efid = 0 
)
overridevirtual

Update binary data.

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

Implements logicalaccess::ISO7816Commands.

◆ writeBinary()

void logicalaccess::ISO7816ISO7816Commands::writeBinary ( const ByteVector data,
size_t  offset,
unsigned short  efid = 0 
)
overridevirtual

Write binary data.

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

Implements logicalaccess::ISO7816Commands.


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