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

The DESFire commands class. More...

#include <desfirecommands.hpp>

Inheritance diagram for logicalaccess::DESFireCommands:
logicalaccess::Commands logicalaccess::ICommands logicalaccess::DESFireISO7816Commands logicalaccess::DESFireEV1ISO7816Commands

Classes

struct  DataFileSetting
 Describe setting for Data File type. More...
 
struct  DESFireCardVersion
 Card information about software and hardware version. More...
 
struct  FileSetting
 Describe file setting. More...
 
struct  RecordFileSetting
 Describe setting for Record File type. More...
 
struct  ValueFileSetting
 Describe setting for Value File type. More...
 

Public Member Functions

 DESFireCommands ()
 Constructor.
 
 DESFireCommands (std::string cmdtype)
 Constructor.
 
virtual ~DESFireCommands ()
 
virtual void erase ()=0
 Erase the card.
 
virtual void selectApplication (std::shared_ptr< DESFireLocation > location)
 Select an application.
 
virtual void createApplication (std::shared_ptr< DESFireLocation > location, DESFireKeySettings settings, unsigned char maxNbKeys)
 Create a new application.
 
virtual void createStdDataFile (std::shared_ptr< DESFireLocation > location, const DESFireAccessRights &accessRights, unsigned int fileSize)
 Create a new data file in the current application.
 
virtual EncryptionMode getEncryptionMode (unsigned char fileno, bool isReadMode, bool *needLoadKey=nullptr)
 Get the communication mode for a file.
 
virtual EncryptionMode getEncryptionMode (const FileSetting &fileSetting, bool isReadMode, bool *needLoadKey=nullptr)
 
virtual unsigned int getFileLength (unsigned char fileno)
 Get the length of a file.
 
virtual void selectApplication (unsigned int aid)=0
 Select an application.
 
virtual void createApplication (unsigned int aid, DESFireKeySettings settings, unsigned char maxNbKeys)=0
 Create a new application.
 
virtual void deleteApplication (unsigned int aid)=0
 Delete an application.
 
virtual std::vector< unsigned int > getApplicationIDs ()=0
 Get the current application list.
 
virtual void changeKey (unsigned char keyno, std::shared_ptr< DESFireKey > key)=0
 Change a key in the current application.
 
virtual void getKeySettings (DESFireKeySettings &settings, unsigned char &maxNbKeys)=0
 Get key settings on the current application.
 
virtual void changeKeySettings (DESFireKeySettings settings)=0
 Change key settings for the current application.
 
virtual ByteVector getFileIDs ()=0
 Get the File IDentifiers of all active files within the currently selected application.
 
virtual FileSetting getFileSettings (unsigned char fileno)=0
 Get settings of a specific file in the current application.
 
virtual void changeFileSettings (unsigned char fileno, EncryptionMode comSettings, const DESFireAccessRights &accessRights, bool plain)=0
 Change file settings of a specific file in the current application.
 
virtual void createStdDataFile (unsigned char fileno, EncryptionMode comSettings, const DESFireAccessRights &accessRights, unsigned int fileSize)=0
 Create a new data file in the current application.
 
virtual void createBackupFile (unsigned char fileno, EncryptionMode comSettings, const DESFireAccessRights &accessRights, unsigned int fileSize)=0
 Create a new backup file in the current application.
 
virtual void createValueFile (unsigned char fileno, EncryptionMode comSettings, const DESFireAccessRights &accessRights, int32_t lowerLimit, int32_t upperLimit, int32_t value, bool limitedCreditEnabled)=0
 Create a new value file in the current application.
 
virtual void createLinearRecordFile (unsigned char fileno, EncryptionMode comSettings, const DESFireAccessRights &accessRights, unsigned int fileSize, unsigned int maxNumberOfRecords)=0
 Create a new linear record file in the current application.
 
virtual void createCyclicRecordFile (unsigned char fileno, EncryptionMode comSettings, const DESFireAccessRights &accessRights, unsigned int fileSize, unsigned int maxNumberOfRecords)=0
 Create a new cyclic record file in the current application.
 
virtual void deleteFile (unsigned char fileno)=0
 Delete a file in the current application.
 
virtual ByteVector readData (unsigned char fileno, unsigned int offset, unsigned int length, EncryptionMode mode)=0
 Read data from a specific file.
 
virtual void writeData (unsigned char fileno, unsigned int offset, const ByteVector &data, EncryptionMode mode)=0
 Write data into a specific file.
 
virtual int32_t getValue (unsigned char fileno, EncryptionMode mode)=0
 Get value from a specific value file.
 
virtual void credit (unsigned char fileno, unsigned int value, EncryptionMode mode)=0
 Credit a specific value file.
 
virtual void debit (unsigned char fileno, unsigned int value, EncryptionMode mode)=0
 Debit a specific value file.
 
virtual void limitedCredit (unsigned char fileno, int32_t value, EncryptionMode mode)=0
 Limit credit on a specific value file.
 
virtual void writeRecord (unsigned char fileno, unsigned int offset, const ByteVector &data, EncryptionMode mode)=0
 Write record into a specific record file.
 
virtual ByteVector readRecords (unsigned char fileno, unsigned int offset, unsigned int length, EncryptionMode mode)=0
 Read record from a specific record file.
 
virtual void clearRecordFile (unsigned char fileno)=0
 Clear a specific record file.
 
virtual void commitTransaction ()=0
 Commit the transaction.
 
virtual void abortTransaction ()=0
 Abort the transaction.
 
virtual void authenticate (unsigned char keyno=0)=0
 Authenticate a block, given a key number.
 
virtual void authenticate (unsigned char keyno, std::shared_ptr< DESFireKey > key)=0
 Authenticate a block, given a key number.
 
virtual DESFireCardVersion getVersion ()=0
 Get the card version information.
 
virtual SignatureResult IKS_getLastReadSignature () const
 
- 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.
 

Protected Member Functions

std::shared_ptr< DESFireChipgetDESFireChip () const
 
- Protected Member Functions inherited from logicalaccess::Commands
 Commands (std::string commandtype)
 Constructor.
 

Additional Inherited Members

- 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 DESFire commands class.

Constructor & Destructor Documentation

◆ DESFireCommands() [1/2]

logicalaccess::DESFireCommands::DESFireCommands ( )
inline

Constructor.

◆ DESFireCommands() [2/2]

logicalaccess::DESFireCommands::DESFireCommands ( std::string  cmdtype)
inlineexplicit

Constructor.

Parameters
ctThe cmd type.

◆ ~DESFireCommands()

logicalaccess::DESFireCommands::~DESFireCommands ( )
virtual

Member Function Documentation

◆ abortTransaction()

virtual void logicalaccess::DESFireCommands::abortTransaction ( )
pure virtual

Abort the transaction.

Implemented in logicalaccess::DESFireISO7816Commands.

◆ authenticate() [1/2]

virtual void logicalaccess::DESFireCommands::authenticate ( unsigned char  keyno,
std::shared_ptr< DESFireKey key 
)
pure virtual

Authenticate a block, given a key number.

Parameters
keynoThe key number.
keyThe key.

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ authenticate() [2/2]

virtual void logicalaccess::DESFireCommands::authenticate ( unsigned char  keyno = 0)
pure virtual

Authenticate a block, given a key number.

Parameters
keynoThe key number, previously loaded on the profile.

Implemented in logicalaccess::DESFireISO7816Commands.

◆ changeFileSettings()

virtual void logicalaccess::DESFireCommands::changeFileSettings ( unsigned char  fileno,
EncryptionMode  comSettings,
const DESFireAccessRights accessRights,
bool  plain 
)
pure virtual

Change file settings of a specific file in the current application.

Parameters
filenoThe file number
comSettingsThe file communication setting
accessRightsThe file access rights
plainCommunication is currently in plain data.

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ changeKey()

virtual void logicalaccess::DESFireCommands::changeKey ( unsigned char  keyno,
std::shared_ptr< DESFireKey key 
)
pure virtual

Change a key in the current application.

Parameters
keynoThe key number to change
keyThe new key

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ changeKeySettings()

virtual void logicalaccess::DESFireCommands::changeKeySettings ( DESFireKeySettings  settings)
pure virtual

Change key settings for the current application.

Parameters
settingsThe new key settings
Returns

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ clearRecordFile()

virtual void logicalaccess::DESFireCommands::clearRecordFile ( unsigned char  fileno)
pure virtual

Clear a specific record file.

Parameters
filenoThe file number.

Implemented in logicalaccess::DESFireISO7816Commands.

◆ commitTransaction()

virtual void logicalaccess::DESFireCommands::commitTransaction ( )
pure virtual

Commit the transaction.

Implemented in logicalaccess::DESFireISO7816Commands.

◆ createApplication() [1/2]

void logicalaccess::DESFireCommands::createApplication ( std::shared_ptr< DESFireLocation location,
DESFireKeySettings  settings,
unsigned char  maxNbKeys 
)
virtual

Create a new application.

Parameters
locationThe DESFire location
settingsKey settings
maxNbKeysMaximum number of keys

◆ createApplication() [2/2]

virtual void logicalaccess::DESFireCommands::createApplication ( unsigned int  aid,
DESFireKeySettings  settings,
unsigned char  maxNbKeys 
)
pure virtual

Create a new application.

Parameters
aidThe Application ID to create
settingsKey settings
maxNbKeysMaximum number of keys
Returns
True on success, false otherwise.

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ createBackupFile()

virtual void logicalaccess::DESFireCommands::createBackupFile ( unsigned char  fileno,
EncryptionMode  comSettings,
const DESFireAccessRights accessRights,
unsigned int  fileSize 
)
pure virtual

Create a new backup file in the current application.

Parameters
filenoThe new file number
comSettingsThe file communication setting
accessRightsThe file access rights
fileSizeThe file size.

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ createCyclicRecordFile()

virtual void logicalaccess::DESFireCommands::createCyclicRecordFile ( unsigned char  fileno,
EncryptionMode  comSettings,
const DESFireAccessRights accessRights,
unsigned int  fileSize,
unsigned int  maxNumberOfRecords 
)
pure virtual

Create a new cyclic record file in the current application.

Parameters
filenoThe new file number
comSettingsThe file communication setting
accessRightsThe file access rights
fileSizeThe file size.
maxNumberOfRecordsMax number of records in the file.

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ createLinearRecordFile()

virtual void logicalaccess::DESFireCommands::createLinearRecordFile ( unsigned char  fileno,
EncryptionMode  comSettings,
const DESFireAccessRights accessRights,
unsigned int  fileSize,
unsigned int  maxNumberOfRecords 
)
pure virtual

Create a new linear record file in the current application.

Parameters
filenoThe new file number
comSettingsThe file communication setting
accessRightsThe file access rights
fileSizeThe file size.
maxNumberOfRecordsMax number of records in the file.

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ createStdDataFile() [1/2]

void logicalaccess::DESFireCommands::createStdDataFile ( std::shared_ptr< DESFireLocation location,
const DESFireAccessRights accessRights,
unsigned int  fileSize 
)
virtual

Create a new data file in the current application.

Parameters
locationThe DESFire location
accessRightsThe file access rights
fileSizeThe file size.

◆ createStdDataFile() [2/2]

virtual void logicalaccess::DESFireCommands::createStdDataFile ( unsigned char  fileno,
EncryptionMode  comSettings,
const DESFireAccessRights accessRights,
unsigned int  fileSize 
)
pure virtual

Create a new data file in the current application.

Parameters
filenoThe new file number
comSettingsThe file communication setting
accessRightsThe file access rights
fileSizeThe file size.

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ createValueFile()

virtual void logicalaccess::DESFireCommands::createValueFile ( unsigned char  fileno,
EncryptionMode  comSettings,
const DESFireAccessRights accessRights,
int32_t  lowerLimit,
int32_t  upperLimit,
int32_t  value,
bool  limitedCreditEnabled 
)
pure virtual

Create a new value file in the current application.

Parameters
filenoThe new file number
comSettingsThe file communication setting
accessRightsThe file access rights
lowerLimitThe file size (in bytes)
upperLimitThe file size (in bytes)
valueThe default value
limitedCreditEnabledSet if the limited credit is enabled

Implemented in logicalaccess::DESFireISO7816Commands.

◆ credit()

virtual void logicalaccess::DESFireCommands::credit ( unsigned char  fileno,
unsigned int  value,
EncryptionMode  mode 
)
pure virtual

Credit a specific value file.

Parameters
filenoThe file number
valueThe value to credit
modeThe communication mode

Implemented in logicalaccess::DESFireISO7816Commands.

◆ debit()

virtual void logicalaccess::DESFireCommands::debit ( unsigned char  fileno,
unsigned int  value,
EncryptionMode  mode 
)
pure virtual

Debit a specific value file.

Parameters
filenoThe file number
valueThe value to debit
modeThe communication mode

Implemented in logicalaccess::DESFireISO7816Commands.

◆ deleteApplication()

virtual void logicalaccess::DESFireCommands::deleteApplication ( unsigned int  aid)
pure virtual

Delete an application.

Parameters
aidThe Application ID to delete

Implemented in logicalaccess::DESFireISO7816Commands.

◆ deleteFile()

virtual void logicalaccess::DESFireCommands::deleteFile ( unsigned char  fileno)
pure virtual

Delete a file in the current application.

Parameters
filenoThe file number to delete

Implemented in logicalaccess::DESFireISO7816Commands.

◆ erase()

virtual void logicalaccess::DESFireCommands::erase ( )
pure virtual

Erase the card.

Implemented in logicalaccess::DESFireISO7816Commands.

◆ getApplicationIDs()

virtual std::vector< unsigned int > logicalaccess::DESFireCommands::getApplicationIDs ( )
pure virtual

Get the current application list.

Returns
The application list.

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ getDESFireChip()

std::shared_ptr< DESFireChip > logicalaccess::DESFireCommands::getDESFireChip ( ) const
protected

◆ getEncryptionMode() [1/2]

EncryptionMode logicalaccess::DESFireCommands::getEncryptionMode ( const FileSetting fileSetting,
bool  isReadMode,
bool *  needLoadKey = nullptr 
)
virtual

◆ getEncryptionMode() [2/2]

EncryptionMode logicalaccess::DESFireCommands::getEncryptionMode ( unsigned char  fileno,
bool  isReadMode,
bool *  needLoadKey = nullptr 
)
virtual

Get the communication mode for a file.

Parameters
filenoThe file number
isReadModeIs read or write mode
needLoadKeySet if it's necessary to be authenticate for the access.
Returns
The communication mode.

◆ getFileIDs()

virtual ByteVector logicalaccess::DESFireCommands::getFileIDs ( )
pure virtual

Get the File IDentifiers of all active files within the currently selected application.

Returns
The file ID list.

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ getFileLength()

unsigned int logicalaccess::DESFireCommands::getFileLength ( unsigned char  fileno)
virtual

Get the length of a file.

Parameters
filenoThe file number
Returns
The length.

◆ getFileSettings()

virtual FileSetting logicalaccess::DESFireCommands::getFileSettings ( unsigned char  fileno)
pure virtual

Get settings of a specific file in the current application.

Parameters
filenoThe file number
fileSettingThe file setting

Implemented in logicalaccess::DESFireISO7816Commands.

◆ getKeySettings()

virtual void logicalaccess::DESFireCommands::getKeySettings ( DESFireKeySettings settings,
unsigned char &  maxNbKeys 
)
pure virtual

Get key settings on the current application.

Parameters
settingsKey settings
maxNbKeysMaximum number of keys

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ getValue()

virtual int32_t logicalaccess::DESFireCommands::getValue ( unsigned char  fileno,
EncryptionMode  mode 
)
pure virtual

Get value from a specific value file.

Parameters
filenoThe file number
modeThe communicatio mode
valueThe value stored in the card

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ getVersion()

virtual DESFireCardVersion logicalaccess::DESFireCommands::getVersion ( )
pure virtual

Get the card version information.

Parameters
dataVersionThe card version information structure that will be filled

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ IKS_getLastReadSignature()

virtual SignatureResult logicalaccess::DESFireCommands::IKS_getLastReadSignature ( ) const
inlinevirtual

Get the IKS signature corresponding to the last readData() call.

This will return the empty SignatureResult and will only work if both: 1) DESFireEV1ISO7816 is used. 2) An IKS backend is used.

Reimplemented in logicalaccess::DESFireEV1ISO7816Commands.

◆ limitedCredit()

virtual void logicalaccess::DESFireCommands::limitedCredit ( unsigned char  fileno,
int32_t  value,
EncryptionMode  mode 
)
pure virtual

Limit credit on a specific value file.

Parameters
filenoThe file number
valueThe value to limit credit
modeThe communication mode

Implemented in logicalaccess::DESFireISO7816Commands.

◆ readData()

virtual ByteVector logicalaccess::DESFireCommands::readData ( unsigned char  fileno,
unsigned int  offset,
unsigned int  length,
EncryptionMode  mode 
)
pure virtual

Read data from a specific file.

Parameters
filenoThe file number
offsetThe byte offset
lengthThe data length to read
modeThe communication mode
Returns
The bytes readed.

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ readRecords()

virtual ByteVector logicalaccess::DESFireCommands::readRecords ( unsigned char  fileno,
unsigned int  offset,
unsigned int  length,
EncryptionMode  mode 
)
pure virtual

Read record from a specific record file.

Parameters
filenoThe file number
offsetThe byte offset
lengthThe length to read
modeThe communication mode
Returns
The number of bytes read.

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ selectApplication() [1/2]

void logicalaccess::DESFireCommands::selectApplication ( std::shared_ptr< DESFireLocation location)
virtual

Select an application.

Parameters
locationThe DESFire location

◆ selectApplication() [2/2]

virtual void logicalaccess::DESFireCommands::selectApplication ( unsigned int  aid)
pure virtual

Select an application.

Parameters
aidThe Application ID

Implemented in logicalaccess::DESFireEV1ISO7816Commands, and logicalaccess::DESFireISO7816Commands.

◆ writeData()

virtual void logicalaccess::DESFireCommands::writeData ( unsigned char  fileno,
unsigned int  offset,
const ByteVector data,
EncryptionMode  mode 
)
pure virtual

Write data into a specific file.

Parameters
filenoThe file number
offsetThe byte offset
dataThe data buffer
modeThe communication mode

Implemented in logicalaccess::DESFireISO7816Commands.

◆ writeRecord()

virtual void logicalaccess::DESFireCommands::writeRecord ( unsigned char  fileno,
unsigned int  offset,
const ByteVector data,
EncryptionMode  mode 
)
pure virtual

Write record into a specific record file.

Parameters
filenoThe file number
offsetThe byte offset
dataThe data buffer
modeThe communication mode

Implemented in logicalaccess::DESFireISO7816Commands.


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