LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
samav2iso7816commands.hpp
Go to the documentation of this file.
1
7#ifndef LOGICALACCESS_SAMAV2ISO7816CARDPROVIDER_HPP
8#define LOGICALACCESS_SAMAV2ISO7816CARDPROVIDER_HPP
9
18#include <string>
19#include <vector>
20#include <iostream>
21
22namespace logicalaccess
23{
24#define AV2_HEADER_LENGTH 0x05
25#define AV2_HEADER_LENGTH_WITH_LE 0x06
26#define AV2_LC_POS 0x04
27#define CMD_SAMAV2ISO7816 "SAMAV2ISO7816"
28
29#ifdef SWIG
30%template(SAMISO7816KeyEntrySETAV2Commands)
31 SAMISO7816Commands<KeyEntryAV2Information, SETAV2>;
32#endif
33
37class LLA_READERS_ISO7816_API SAMAV2ISO7816Commands
39#ifndef SWIG
40 ,
42#endif
43{
44 public:
49
50 explicit SAMAV2ISO7816Commands(std::string);
51
55 virtual ~SAMAV2ISO7816Commands();
56
57 void authenticateHost(std::shared_ptr<DESFireKey> key, unsigned char keyno) override;
58
59 std::shared_ptr<SAMKeyEntry<KeyEntryAV2Information, SETAV2>>
60 getKeyEntry(unsigned char keyno) override;
61 std::shared_ptr<SAMKucEntry> getKUCEntry(unsigned char kucno) override;
62
63 void changeKUCEntry(unsigned char kucno, std::shared_ptr<SAMKucEntry> kucentry,
64 std::shared_ptr<DESFireKey> key) override;
65 void
66 changeKeyEntry(unsigned char keyno,
67 std::shared_ptr<SAMKeyEntry<KeyEntryAV2Information, SETAV2>> keyentry,
68 std::shared_ptr<DESFireKey> key) override;
69
70 ByteVector transmit(ByteVector cmd, bool first = true, bool last = true) override;
71
72 ByteVector dumpSecretKey(unsigned char keyno, unsigned char keyversion,
73 ByteVector divInpu) override;
74
75 void activateOfflineKey(unsigned char keyno, unsigned char keyversion,
76 ByteVector divInpu) override;
77
78 ByteVector decipherOfflineData(ByteVector data) override;
79
80 ByteVector encipherOfflineData(ByteVector data) override;
81
82 virtual ByteVector cmacOffline(const ByteVector &data);
83
84 std::shared_ptr<Chip> getChip() const override
85 {
87 }
88
89 std::shared_ptr<ReaderCardAdapter> getReaderCardAdapter() const override
90 {
92 }
93
94 protected:
95 void generateSessionKey(ByteVector rnd1, ByteVector rnd2);
96
97 ByteVector createfullProtectionCmd(ByteVector cmd);
98
99 ByteVector verifyAndDecryptResponse(ByteVector response);
100
101 static void getLcLe(ByteVector cmd, bool &lc, unsigned char &lcvalue, bool &le);
102
103 ByteVector generateEncIV(bool encrypt) const;
104
106
108
109 unsigned int d_cmdCtr;
110};
111}
112
113#endif /* LOGICALACCESS_SAMAV2ISO7816COMMANDS_HPP */
std::shared_ptr< ReaderCardAdapter > getReaderCardAdapter() const override
Get the reader/card adapter.
Definition: commands.hpp:52
std::shared_ptr< Chip > getChip() const override
Get the chip.
Definition: commands.hpp:34
Definition: samav2commands.hpp:18
The DESFire base commands class.
Definition: samav2iso7816commands.hpp:43
ByteVector d_macSessionKey
Definition: samav2iso7816commands.hpp:105
unsigned int d_cmdCtr
Definition: samav2iso7816commands.hpp:109
std::shared_ptr< Chip > getChip() const override
Get the chip.
Definition: samav2iso7816commands.hpp:84
std::shared_ptr< ReaderCardAdapter > getReaderCardAdapter() const override
Get the reader/card adapter.
Definition: samav2iso7816commands.hpp:89
ByteVector d_lastMacIV
Definition: samav2iso7816commands.hpp:107
The SAMISO7816 commands class.
Definition: samiso7816commands.hpp:52
A SAMKeyEntry class.
Definition: samkeyentry.hpp:90
Default ISO7816 reader/card adapter.
std::vector< uint8_t > ByteVector
Definition: lla_fwd.hpp:80
Definition: asn1.hpp:9
SAMDESfireCrypto header.
SAMKeyEntry source.