LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
iso7816commands.hpp
Go to the documentation of this file.
1
8#ifndef LOGICALACCESS_ISO7816COMMANDS_HPP
9#define LOGICALACCESS_ISO7816COMMANDS_HPP
10
11#include <logicalaccess/key.hpp>
14#include <logicalaccess/tlv.hpp>
15
16namespace logicalaccess
17{
18#define CMD_ISO7816 "ISO7816"
19
23typedef enum
24{
33
37typedef enum
38{
43 // P2_RETURN_FCI = 0x00,
46 P2_RETURN_NO_FCI = 0x0C
48
52typedef enum
53{
61
65typedef enum
66{
74
78typedef enum
79{
83
84#define ISO7816_DATA_OBJECT_SELECTED 0x3FFF
85#define ISO7816_DATA_OBJECT_EXTENDED_HEADERLIST 0x4D
86#define ISO7816_DATA_OBJECT_HEADERLIST 0x5C
87#define ISO7816_DATA_OBJECT_TAGLIST 0x5D
88#define ISO7816_DATA_OBJECT_APPLICATION_TEMPLATE 0x61
89#define ISO7816_DATA_OBJECT_DYNAMIC_AUTHENTICATION_DATA 0x7C
90#define ISO7816_DATA_OBJECT_WITNESS 0x80
91#define ISO7816_DATA_OBJECT_CHALLENGE 0x81
92#define ISO7816_DATA_OBJECT_RESPONSE 0x82
93#define IS7816O_DATA_OBJECT_COMMITTED 0x83
94#define ISO7816_DATA_OBJECT_AUTHCODE 0x84
95#define ISO7816_DATA_OBJECT_CRYPTOGRAM 0x85
96#define ISO7816_DATA_OBJECT_CRYPTOGRAPHIC_CHECKSUM 0x8E
97#define ISO7816_DATA_OBJECT_PROTECTED_NE 0x97
98#define ISO7816_DATA_OBJECT_PROCESSING_STATUS 0x99
99#define ISO7816_DATA_OBJECT_IDENTIFICATION_DATA_TEMPLATE 0xA0
100
104class LLA_CARDS_ISO7816_API ISO7816Commands : public Commands
105{
106 public:
109 {
110 }
111
112 explicit ISO7816Commands(std::string ct)
113 : Commands(ct)
114 {
115 }
116
117 virtual ~ISO7816Commands();
118
127 virtual ByteVector readBinary(size_t length, size_t offset,
128 unsigned short efid = 0) = 0;
129
137 virtual void writeBinary(const ByteVector &data, size_t offset,
138 unsigned short efid = 0) = 0;
139
147 virtual void updateBinary(const ByteVector &data, size_t offset,
148 unsigned short efid = 0) = 0;
149
155 virtual void eraseBinary(size_t offset, unsigned short efid = 0) = 0;
156
157 // Don't implement record management yet.
158
165 virtual ByteVector getData(unsigned short dataObject, size_t length = 0) = 0;
166
174 virtual ByteVector getDataList(int64_t dataObject,
175 unsigned short efid = ISO7816_DATA_OBJECT_SELECTED,
176 unsigned char listtag = ISO7816_DATA_OBJECT_HEADERLIST,
177 size_t length = 0);
178
185 virtual ByteVector getDataList(TLVPtr tlv, size_t length = 0,
186 unsigned short efid = ISO7816_DATA_OBJECT_SELECTED);
187
194 virtual ByteVector getDataList(const ByteVector &data, size_t length = 0,
195 unsigned short efid = ISO7816_DATA_OBJECT_SELECTED) = 0;
196
203 virtual void putData(const ByteVector &data, unsigned short dataObject) = 0;
204
210 virtual ByteVector getResponse(unsigned char maxlength = 0) = 0;
211
218 virtual void selectFile(ISOSelectFileP1 p1, ISOSelectFileP2 p2, unsigned short efid);
219
224 virtual void selectFile(unsigned short efid);
225
230 virtual void selectFile(const ByteVector &dfname);
231
238 virtual void selectFile(unsigned char p1, unsigned char p2,
239 const ByteVector &data) = 0;
240
248 virtual ByteVector readRecords(unsigned short fid = 0, unsigned char start_record = 0,
249 ISORecords record_number = ISO_RECORD_ONERECORD) = 0;
250
256 virtual void appendrecord(const ByteVector &data = ByteVector(),
257 unsigned short fid = 0) = 0;
258
264 virtual ByteVector getChallenge(unsigned int length = 8) = 0;
265
273 virtual void externalAuthenticate(unsigned char algorithm = 0x00,
274 bool globalReference = false,
275 unsigned char keyno = 0x00,
276 const ByteVector &data = ByteVector()) = 0;
277
287 virtual ByteVector externalAuthenticate(unsigned char algorithm, bool globalReference,
288 unsigned char keyno, const ByteVector &data,
289 unsigned char le) = 0;
290
298 virtual ByteVector internalAuthenticate(unsigned char algorithm = 0x00,
299 bool globalReference = false,
300 unsigned char keyno = 0x00,
301 const ByteVector &RPCD2 = ByteVector(),
302 unsigned int length = 16) = 0;
303
314 virtual ByteVector generalAuthenticate(unsigned char algorithm, bool globalReference,
315 unsigned char keyno,
316 const ByteVector &dataField,
317 unsigned char le) = 0;
318
319 virtual ByteVector generalAuthenticate_challenge(unsigned char algorithm, bool globalReference,
320 unsigned char keyno) = 0;
321
322 virtual ByteVector generalAuthenticate_response(unsigned char algorithm,
323 bool globalReference, unsigned char keyno,
324 const ByteVector &data) = 0;
325
326 virtual void removeApplication(const ByteVector &data,
328 P1_STATE_OPERATIONAL_OR_INITIALIZATION_TO_CREATION) = 0;
329
330 virtual void removeApplication(TLVPtr tlv,
332 P1_STATE_OPERATIONAL_OR_INITIALIZATION_TO_CREATION);
333
335 const ByteVector &data,
336 ISOApplicationManagementRequestP1 p1 = P1_STATE_CREATION_TO_OPERATIONAL,
337 unsigned char p2 = 0x00) = 0;
338
339 virtual ByteVector applicationManagementRequest(
340 TLVPtr tlv,
341 ISOApplicationManagementRequestP1 p1 = P1_STATE_CREATION_TO_OPERATIONAL,
342 unsigned char p2 = 0x00);
343};
344} // namespace logicalaccess
345
346#endif
The base commands class for all card commands.
Definition: commands.hpp:21
The ISO7816 commands class.
Definition: iso7816commands.hpp:105
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 ByteVector externalAuthenticate(unsigned char algorithm, bool globalReference, unsigned char keyno, const ByteVector &data, unsigned char le)=0
ISO external authenticate.
virtual ByteVector applicationManagementRequest(const ByteVector &data, ISOApplicationManagementRequestP1 p1=P1_STATE_CREATION_TO_OPERATIONAL, unsigned char p2=0x00)=0
virtual ByteVector readRecords(unsigned short fid=0, unsigned char start_record=0, ISORecords record_number=ISO_RECORD_ONERECORD)=0
Read records.
virtual void selectFile(unsigned char p1, unsigned char p2, const ByteVector &data)=0
Select a file.
virtual ByteVector getDataList(const ByteVector &data, size_t length=0, unsigned short efid=ISO7816_DATA_OBJECT_SELECTED)=0
Get data.
ISO7816Commands(std::string ct)
Definition: iso7816commands.hpp:112
virtual ByteVector getChallenge(unsigned int length=8)=0
Get the ISO challenge for authentication.
virtual void appendrecord(const ByteVector &data=ByteVector(), unsigned short fid=0)=0
Append a record to a file.
virtual void eraseBinary(size_t offset, unsigned short efid=0)=0
Erase binary data.
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 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 ByteVector getData(unsigned short dataObject, size_t length=0)=0
Get data.
virtual ByteVector getResponse(unsigned char maxlength=0)=0
Get response.
virtual void removeApplication(const ByteVector &data, ISORemoveApplicationP1 p1=P1_STATE_OPERATIONAL_OR_INITIALIZATION_TO_CREATION)=0
virtual ByteVector readBinary(size_t length, size_t offset, unsigned short efid=0)=0
Read binary data.
virtual void externalAuthenticate(unsigned char algorithm=0x00, bool globalReference=false, unsigned char keyno=0x00, const ByteVector &data=ByteVector())=0
ISO external authenticate.
virtual ByteVector generalAuthenticate(unsigned char algorithm, bool globalReference, unsigned char keyno, const ByteVector &dataField, unsigned char le)=0
ISO general authenticate.
ISO7816Commands()
Definition: iso7816commands.hpp:107
virtual void putData(const ByteVector &data, unsigned short dataObject)=0
Put data.
Commands.
#define ISO7816_DATA_OBJECT_HEADERLIST
Definition: iso7816commands.hpp:86
#define CMD_ISO7816
Definition: iso7816commands.hpp:18
#define ISO7816_DATA_OBJECT_SELECTED
Definition: iso7816commands.hpp:84
ISO7816 location.
std::vector< uint8_t > ByteVector
Definition: lla_fwd.hpp:80
Definition: asn1.hpp:9
ISORemoveApplicationP1
The P1 of Remove Application command.
Definition: iso7816commands.hpp:53
@ P1_STATE_OPERATIONAL_TO_CREATION
Definition: iso7816commands.hpp:57
@ P1_STATE_OPERATIONAL_OR_INITIALIZATION_TO_CREATION
Definition: iso7816commands.hpp:58
@ P1_STATE_INITIALIZATION_TO_CREATION
Definition: iso7816commands.hpp:55
@ P1_STATE_CREATION_TO_APPLICATION_REMOVED
Definition: iso7816commands.hpp:54
@ P1_STATE_OPERATIONAL_TO_APPLICATION_REMOVED
Definition: iso7816commands.hpp:59
@ P1_STATE_INITIALIZATION_TO_APPLICATION_REMOVED
Definition: iso7816commands.hpp:56
ISORecords
The ISO record transmission mode.
Definition: iso7816commands.hpp:79
@ ISO_RECORD_ONERECORD
Definition: iso7816commands.hpp:80
@ ISO_RECORD_ALLRECORDS
Definition: iso7816commands.hpp:81
std::shared_ptr< TLV > TLVPtr
Definition: lla_fwd.hpp:77
ISOApplicationManagementRequestP1
The P1 of Application Management Request command.
Definition: iso7816commands.hpp:66
@ P1_STATE_INITIALIZATION_TO_OPERATIONAL
Definition: iso7816commands.hpp:70
@ P1_STATE_NONEXISTENT_TO_OPERATIONAL
Definition: iso7816commands.hpp:72
@ P1_STATE_NONEXISTENT_TO_CREATION
Definition: iso7816commands.hpp:67
@ P1_STATE_CREATION_TO_INITIALIZATION
Definition: iso7816commands.hpp:68
@ P1_STATE_CREATION_TO_OPERATIONAL
Definition: iso7816commands.hpp:71
@ P1_STATE_NONEXISTENT_TO_INITIALIZATION
Definition: iso7816commands.hpp:69
ISOSelectFileP1
The P1 of Select File command.
Definition: iso7816commands.hpp:24
@ P1_SELECT_MF_DF_EF
Definition: iso7816commands.hpp:25
@ P1_SELECT_PATH_FROM_MF
Definition: iso7816commands.hpp:30
@ P1_SELECT_PATH_FROM_CURRENT_DF
Definition: iso7816commands.hpp:31
@ P1_SELECT_EF_UNDER_CURRENT_DF
Definition: iso7816commands.hpp:27
@ P1_SELECT_BY_DFNAME
Definition: iso7816commands.hpp:29
@ P1_SELECT_PARENT_DF_OF_CURRENT_DF
Definition: iso7816commands.hpp:28
@ P1_SELECT_CHILD_DF
Definition: iso7816commands.hpp:26
ISOSelectFileP2
The P2 of Select File command.
Definition: iso7816commands.hpp:38
@ P2_FIRST_RECORD
Definition: iso7816commands.hpp:39
@ P2_LAST_RECORD
Definition: iso7816commands.hpp:40
@ P2_RETURN_NO_FCI
Definition: iso7816commands.hpp:46
@ P2_RETURN_FCP
Definition: iso7816commands.hpp:44
@ P2_PREVIOUS_RECORD
Definition: iso7816commands.hpp:42
@ P2_RETURN_FMD
Definition: iso7816commands.hpp:45
@ P2_NEXT_RECORD
Definition: iso7816commands.hpp:41