LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
desfireev1stidstrcommands.hpp
Go to the documentation of this file.
1
8#ifndef LOGICALACCESS_DESFIREEV1STIDSTRCOMMANDS_HPP
9#define LOGICALACCESS_DESFIREEV1STIDSTRCOMMANDS_HPP
10
14
15#include <string>
16#include <vector>
17#include <iostream>
18
19namespace logicalaccess
20{
21#define CMD_DESFIREEV1STIDSTR "DESFireEV1STidSTR"
22
26typedef enum {
29 STID_DF_BR_424KBPS = 0x02
31
35typedef enum {
40
44class LLA_READERS_STIDSTR_API DESFireEV1STidSTRCommands : public Commands
45#ifndef SWIG
46 ,
48#endif
49{
50 public:
55
56 explicit DESFireEV1STidSTRCommands(std::string);
57
58
63
68 ByteVector scanDESFire() const;
69
73 void releaseRFIDField() const;
74
80 void changePPS(STidDESFireBaudrate readerToChipKbps,
81 STidDESFireBaudrate chipToReaderKbps) const;
82
87 unsigned int getFreeMem() override;
88
93 std::vector<DFName> getDFNames() override;
94
100 std::vector<unsigned short> getISOFileIDs() override;
101
105 virtual void erase();
106#ifndef SWIG
107 using DESFireEV1Commands::createApplication;
108#endif
109
116 virtual void createApplication(unsigned int aid, DESFireKeySettings settings,
117 unsigned char maxNbKeys);
118
125 void createApplication(unsigned int aid, DESFireKeySettings settings,
126 unsigned char maxNbKeys, DESFireKeyType cryptoMethod,
127 FidSupport fidSupported = FIDS_NO_ISO_FID,
128 unsigned short isoFID = 0x00,
129 ByteVector isoDFName = ByteVector()) override;
130
135 virtual void deleteApplication(unsigned int aid);
136
141 void selectApplication(unsigned int aid) override;
142
148 virtual void getKeySettings(DESFireKeySettings &settings, unsigned char &maxNbKeys);
149
156 void getKeySettings(DESFireKeySettings &settings, unsigned char &maxNbKeys,
157 DESFireKeyType &keyType) override;
158
163 ByteVector getCardUID() override;
164#ifndef SWIG
165 using DESFireEV1Commands::createStdDataFile;
166#endif
167
175 virtual void createStdDataFile(unsigned char fileno, EncryptionMode comSettings,
176 const DESFireAccessRights &accessRights,
177 unsigned int fileSize);
178
186 void createStdDataFile(unsigned char fileno, EncryptionMode comSettings,
187 const DESFireAccessRights &accessRights, unsigned int fileSize,
188 unsigned short isoFID) override;
189
193 virtual void commitTransaction();
194
198 virtual void abortTransaction();
199
207 virtual void createBackupFile(unsigned char fileno, EncryptionMode comSettings,
208 const DESFireAccessRights &accessRights,
209 unsigned int fileSize);
210
218 void createBackupFile(unsigned char fileno, EncryptionMode comSettings,
219 const DESFireAccessRights &accessRights, unsigned int fileSize,
220 unsigned short isoFID) override;
221
232 virtual void createValueFile(unsigned char fileno, EncryptionMode comSettings,
233 const DESFireAccessRights &accessRights,
234 int32_t lowerLimit, int32_t upperLimit,
235 int32_t value, bool limitedCreditEnabled);
236
245 virtual void createLinearRecordFile(unsigned char fileno, EncryptionMode comSettings,
246 const DESFireAccessRights &accessRights,
247 unsigned int fileSize,
248 unsigned int maxNumberOfRecords);
249
259 void createLinearRecordFile(unsigned char fileno, EncryptionMode comSettings,
260 const DESFireAccessRights &accessRights,
261 unsigned int fileSize, unsigned int maxNumberOfRecords,
262 unsigned short isoFID) override;
263
272 virtual void createCyclicRecordFile(unsigned char fileno, EncryptionMode comSettings,
273 const DESFireAccessRights &accessRights,
274 unsigned int fileSize,
275 unsigned int maxNumberOfRecords);
276
285 void createCyclicRecordFile(unsigned char fileno, EncryptionMode comSettings,
286 const DESFireAccessRights &accessRights,
287 unsigned int fileSize, unsigned int maxNumberOfRecords,
288 unsigned short isoFID) override;
289
294 virtual void loadKey(std::shared_ptr<DESFireKey> key);
295
302 virtual void loadKey(ByteVector key, bool diversify, bool isVolatile);
303
311 virtual void authenticate(STidKeyLocationType keylocation, unsigned char keyno,
312 DESFireKeyType cryptoMethod, unsigned char keyindex);
313
318 virtual void authenticate(unsigned char keyno);
319
325 virtual void authenticate(unsigned char keyno, std::shared_ptr<DESFireKey> key);
326
332 void authenticateISO(unsigned char keyno,
333 DESFireISOAlgorithm algorithm = DF_ALG_2K3DES) override;
334
339 void authenticateAES(unsigned char keyno) override;
340
349 virtual ByteVector readData(unsigned char fileno, unsigned int offset,
350 unsigned int length, EncryptionMode mode);
351
359 virtual void writeData(unsigned char fileno, unsigned int offset,
360 const ByteVector &data, EncryptionMode mode);
361
368 virtual void credit(unsigned char fileno, unsigned int value, EncryptionMode mode);
369
376 virtual void debit(unsigned char fileno, unsigned int value, EncryptionMode mode);
377
386 virtual void limitedCredit(unsigned char fileno, unsigned int value,
387 EncryptionMode mode);
388
397 virtual void writeRecord(unsigned char fileno, unsigned int offset,
398 const ByteVector &data, EncryptionMode mode);
399
409 virtual ByteVector readRecords(unsigned char fileno, unsigned int offset,
410 unsigned int length, EncryptionMode mode);
411
416 virtual void clearRecordFile(unsigned char fileno);
417
425 virtual void changeFileSettings(unsigned char fileno, EncryptionMode comSettings,
426 const DESFireAccessRights &accessRights, bool plain);
427
432 virtual void deleteFile(unsigned char fileno);
433
438 virtual void changeKeySettings(DESFireKeySettings settings);
439
445 virtual void changeKey(unsigned char keyno, std::shared_ptr<DESFireKey> key);
446
455 void changeKeyIndex(unsigned char keyno, DESFireKeyType cryptoMethod,
456 unsigned char keyversion, unsigned char newkeyindex,
457 unsigned char oldkeyindex) const;
458
464 unsigned char getKeyVersion(unsigned char keyno) const;
465
470 virtual void getVersion(DESFireCommands::DESFireCardVersion &dataVersion);
471
476 virtual std::vector<unsigned int> getApplicationIDs();
477
483 virtual ByteVector getFileIDs();
484
490 virtual void getFileSettings(unsigned char fileno,
491 DESFireCommands::FileSetting &fileSetting);
492
499 virtual void getValue(unsigned char fileno, EncryptionMode mode, unsigned int &value);
500
506 void setConfiguration(bool formatCardEnabled, bool randomIdEnabled) override;
507
512 void setConfiguration(std::shared_ptr<DESFireKey> defaultKey) override;
513
518 void setConfiguration(const ByteVector &ats) override;
519
524 std::shared_ptr<Chip> getChip() const override
525 {
526 return Commands::getChip();
527 }
528
533 std::shared_ptr<ReaderCardAdapter> getReaderCardAdapter() const override
534 {
535 return Commands::getReaderCardAdapter();
536 }
537
538
543 std::shared_ptr<STidSTRReaderCardAdapter> getSTidSTRReaderCardAdapter() const
544 {
545 return std::dynamic_pointer_cast<STidSTRReaderCardAdapter>(
546 getReaderCardAdapter());
547 }
548
553 static std::string STidKeyLocationTypeStr(STidKeyLocationType t);
554
555 protected:
556 unsigned int d_currentAid;
557};
558}
559
560#endif /* LOGICALACCESS_DESFIREEV1STIDSTRCOMMANDS_H */
The base commands class for all card commands.
Definition: commands.hpp:21
The DESFire EV1 base commands class.
Definition: desfireev1commands.hpp:76
The DESFire EV1 base commands class for STidSTR reader.
Definition: desfireev1stidstrcommands.hpp:49
std::shared_ptr< Chip > getChip() const override
Get the chip.
Definition: desfireev1stidstrcommands.hpp:524
unsigned int d_currentAid
Definition: desfireev1stidstrcommands.hpp:556
std::shared_ptr< ReaderCardAdapter > getReaderCardAdapter() const override
Get the reader/card adapter.
Definition: desfireev1stidstrcommands.hpp:533
std::shared_ptr< STidSTRReaderCardAdapter > getSTidSTRReaderCardAdapter() const
Get the STidSTR reader/card adapter.
Definition: desfireev1stidstrcommands.hpp:543
DESFire EV1 chip.
DESFire EV1 commands.
std::vector< uint8_t > ByteVector
Definition: lla_fwd.hpp:80
Definition: asn1.hpp:9
STidKeyLocationType
The STid DESFire baudrates.
Definition: desfireev1stidstrcommands.hpp:35
@ STID_DF_KEYLOC_INDEXED
Definition: desfireev1stidstrcommands.hpp:38
@ STID_DF_KEYLOC_EEPROM
Definition: desfireev1stidstrcommands.hpp:37
@ STID_DF_KEYLOC_RAM
Definition: desfireev1stidstrcommands.hpp:36
FidSupport
The FID Support for ISO 7816.
Definition: desfireev1commands.hpp:49
@ FIDS_NO_ISO_FID
Definition: desfireev1commands.hpp:49
EncryptionMode
The file communication mode (or encryption mode)
Definition: desfirelocation.hpp:18
DESFireKeySettings
The key settings.
Definition: desfirecommands.hpp:69
STidDESFireBaudrate
The STid DESFire baudrates.
Definition: desfireev1stidstrcommands.hpp:26
@ STID_DF_BR_106KBPS
Definition: desfireev1stidstrcommands.hpp:27
@ STID_DF_BR_424KBPS
Definition: desfireev1stidstrcommands.hpp:29
@ STID_DF_BR_212KBPS
Definition: desfireev1stidstrcommands.hpp:28
DESFireISOAlgorithm
The DESFire EV1 algorithm.
Definition: desfireev1commands.hpp:63
@ DF_ALG_2K3DES
Definition: desfireev1commands.hpp:65
DESFireKeyType
The DESFire key type.
Definition: desfirekey.hpp:33
Default STidSTR reader/card adapter.
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