7#ifndef LOGICALACCESS_DESFIREISO7816CARDPROVIDER_HPP
8#define LOGICALACCESS_DESFIREISO7816CARDPROVIDER_HPP
15#include <logicalaccess/plugins/readers/iso7816/lla_readers_iso7816_api.hpp>
23#define DESFIRE_CLEAR_DATA_LENGTH_CHUNK 32
24#define CMD_DESFIREISO7816 "DESFireISO7816"
48 void setChip(std::shared_ptr<Chip> chip)
override;
53 void erase()
override;
59 void selectApplication(
unsigned int aid)
override;
68 unsigned char maxNbKeys)
override;
74 void deleteApplication(
unsigned int aid)
override;
80 std::vector<unsigned int> getApplicationIDs()
override;
87 void changeKey(
unsigned char keyno, std::shared_ptr<DESFireKey> key)
override;
100 virtual uint8_t getKeyVersion(uint8_t keyno);
120 FileSetting getFileSettings(
unsigned char fileno)
override;
129 void changeFileSettings(
unsigned char fileno,
EncryptionMode comSettings,
139 void createStdDataFile(
unsigned char fileno,
EncryptionMode comSettings,
141 unsigned int fileSize)
override;
150 void createBackupFile(
unsigned char fileno,
EncryptionMode comSettings,
152 unsigned int fileSize)
override;
164 void createValueFile(
unsigned char fileno,
EncryptionMode comSettings,
166 int32_t upperLimit, int32_t value,
167 bool limitedCreditEnabled)
override;
177 void createLinearRecordFile(
unsigned char fileno,
EncryptionMode comSettings,
179 unsigned int fileSize,
180 unsigned int maxNumberOfRecords)
override;
190 void createCyclicRecordFile(
unsigned char fileno,
EncryptionMode comSettings,
192 unsigned int fileSize,
193 unsigned int maxNumberOfRecords)
override;
199 void deleteFile(
unsigned char fileno)
override;
209 ByteVector readData(
unsigned char fileno,
unsigned int offset,
unsigned int length,
219 void writeData(
unsigned char fileno,
unsigned int offset,
const ByteVector &data,
229 int32_t getValue(
unsigned char fileno,
EncryptionMode mode)
override;
237 void credit(
unsigned char fileno,
unsigned int value,
EncryptionMode mode)
override;
245 void debit(
unsigned char fileno,
unsigned int value,
EncryptionMode mode)
override;
254 void limitedCredit(
unsigned char fileno, int32_t value,
265 void writeRecord(
unsigned char fileno,
unsigned int offset,
const ByteVector &data,
277 ByteVector readRecords(
unsigned char fileno,
unsigned int offset,
unsigned int length,
284 void clearRecordFile(
unsigned char fileno)
override;
289 void commitTransaction()
override;
294 void abortTransaction()
override;
300 void authenticate(
unsigned char keyno = 0)
override;
307 void authenticate(
unsigned char keyno, std::shared_ptr<DESFireKey> key)
override;
321 return std::dynamic_pointer_cast<ISO7816ReaderCardAdapter>(
322 getReaderCardAdapter());
345 void getKeyFromSAM(std::shared_ptr<DESFireKey> key,
ByteVector diversify)
const;
350 void sam_authenticate_p2(
unsigned char keyno,
ByteVector rndap)
const;
353 ByteVector getKeyInformations(std::shared_ptr<DESFireKey> key, uint8_t keyno)
const;
355 ByteVector getChangeKeySAMCryptogram(
unsigned char keyno,
356 std::shared_ptr<DESFireKey> key)
const;
358 ByteVector getChangeKeyIKSCryptogram(
unsigned char keyno,
359 std::shared_ptr<DESFireKey> key)
const;
379 virtual void handleWriteData(
unsigned char cmd,
const ByteVector ¶meters,
400 unsigned char lc = 0,
bool forceLc =
false);
402 bool checkChangeKeySAMKeyStorage(
unsigned char keyno,
403 std::shared_ptr<DESFireKey> oldkey,
404 std::shared_ptr<DESFireKey> key);
The DESFire commands class.
Definition: desfirecommands.hpp:130
The DESFire base commands class.
Definition: desfireiso7816commands.hpp:30
std::shared_ptr< SAMChip > d_SAM_chip
The SAMChip used for the SAM Commands.
Definition: desfireiso7816commands.hpp:409
void setSAMChip(std::shared_ptr< SAMChip > t)
Set the SAM Chip.
Definition: desfireiso7816commands.hpp:329
std::shared_ptr< SAMChip > getSAMChip() const
get the SAM Chip.
Definition: desfireiso7816commands.hpp:337
std::shared_ptr< ISO7816ReaderCardAdapter > getISO7816ReaderCardAdapter() const
Get the ISO7816 reader/card adapter.
Definition: desfireiso7816commands.hpp:319
A ISO7816 response message.
Definition: iso7816response.hpp:21
Default ISO7816 reader/card adapter.
std::vector< uint8_t > ByteVector
Definition: lla_fwd.hpp:80
EncryptionMode
The file communication mode (or encryption mode)
Definition: desfirelocation.hpp:18
DESFireKeySettings
The key settings.
Definition: desfirecommands.hpp:69
SAM key storage description.
Access rights on DESFire file.
Definition: desfirecommands.hpp:106
Card information about software and hardware version.
Definition: desfirecommands.hpp:212
Describe file setting.
Definition: desfirecommands.hpp:191