10#ifndef M5_UNIT_UNIFIED_NFC_NFC_APDU_APDU_HPP
11#define M5_UNIT_UNIFIED_NFC_NFC_APDU_APDU_HPP
71enum class INS : uint8_t {
93 INTERNAL_AUTHENTICATE = 0x88,
94 EXTERNAL_AUTHENTICATE = 0x82,
104 ERASE_ALL_RECORDS = 0x06,
108 DF_CREATE_APPLICATION = 0xCA,
109 DF_DELETE_APPLICATION = 0xDA,
110 DF_SELECT_APPLICATION = 0x5A,
111 DF_GET_APPLICATION_IDS = 0x6A,
112 DF_CREATE_STD_DATA_FILE = 0xCD,
113 DF_GET_FREE_MEMORY = 0x6E,
114 DF_GET_FILE_IDS = 0x6F,
115 DF_GET_ISO_FILE_IDS = 0x61,
116 DF_GET_KEY_SETTINGS = 0x45,
117 DF_SET_CONFIGURATION = 0x5C,
118 DF_CHANGE_FILE_SETTINGS = 0x5F,
119 DF_AUTHENTICATE = 0x0A,
120 DF_AUTHENTICATE_ISO = 0x1A,
121 DF_AUTHENTICATE_AES = 0xAA,
122 DF_AUTHENTICATE_EV2 = 0x71,
123 DF_FORMAT_PICC = 0xFC,
125 DF_WRITE_DATA = 0x3D,
126 DF_GET_FILE_SETTINGS = 0xF5,
127 DF_DELETE_TRANSACTION_MAC_FILE = 0xDF,
128 DF_CREATE_TRANSACTION_MAC_FILE = 0xCE,
179 return (param2 & 0x0C) != 0x0C;
198 return (
tag & 0x20) != 0;
216std::vector<TLV> parse_tlv(
const uint8_t* ptr,
const uint32_t len);
222void dump_tlv(
const std::vector<TLV>& tlvs,
const uint8_t depth = 0);
235std::vector<uint8_t> make_apdu_command(
const uint8_t cla,
const uint8_t ins,
const uint8_t param1 = 0x00,
236 const uint8_t param2 = 0x00,
const uint8_t* data =
nullptr,
237 const uint16_t data_len = 0,
const uint16_t rx_len = 0);
247inline std::vector<uint8_t>
make_apdu_case1(
const uint8_t cla,
const uint8_t ins,
const uint8_t p1,
const uint8_t p2)
261inline std::vector<uint8_t>
make_apdu_case2(
const uint8_t cla,
const uint8_t ins,
const uint8_t p1,
const uint8_t p2,
277inline std::vector<uint8_t>
make_apdu_case3(
const uint8_t cla,
const uint8_t ins,
const uint8_t p1,
const uint8_t p2,
278 const uint8_t* data,
const uint16_t data_len)
294inline std::vector<uint8_t>
make_apdu_case4(
const uint8_t cla,
const uint8_t ins,
const uint8_t p1,
const uint8_t p2,
295 const uint8_t* data,
const uint16_t data_len,
const uint16_t le)
std::vector< uint8_t > make_apdu_command(const uint8_t cla, const uint8_t ins, const uint8_t param1, const uint8_t param2, const uint8_t *data, const uint16_t data_len, const uint16_t rx_len)
Make APDU command.
Definition apdu.cpp:22
SelectBy
Select control for SELECT_FILE.
Definition apdu.hpp:137
@ EfUnderCurrentDf
Select EF under current DF (FID in data)
@ FileId
Select MF/DF/EF by file ID.
@ DfName
Select by DF name (AID)
@ ChildDf
Select child DF (FID in data)
@ PathFromMf
Select by path from MF.
@ PathFromCurrentDf
Select by path from current DF.
@ ParentDf
Select parent DF.
constexpr uint16_t RESPONSE_OK
Command successfully executed (OK)
Definition apdu.hpp:27
constexpr uint16_t SUCCESSFULLY_2
Command successfully executed; xx bytes of data are available and can be requested using GET RESPONSE...
Definition apdu.hpp:31
std::vector< uint8_t > make_apdu_case1(const uint8_t cla, const uint8_t ins, const uint8_t p1, const uint8_t p2)
Make APDU case1 command [CLA | INS | P1 | P2].
Definition apdu.hpp:247
SelectResponse
Response for SELECT_FILE.
Definition apdu.hpp:163
constexpr uint8_t WRONG_LENGTH_LE
Wrong length Le.
Definition apdu.hpp:34
std::vector< uint8_t > make_apdu_case2(const uint8_t cla, const uint8_t ins, const uint8_t p1, const uint8_t p2, const uint16_t le)
Make APDU case2 command [CLA | INS | P1 | P2 | Le].
Definition apdu.hpp:261
INS
APDU instruction code.
Definition apdu.hpp:71
bool need_select_file_le(const uint8_t param2)
Check whether SELECT FILE expects Le.
Definition apdu.hpp:177
constexpr uint8_t RESPONSE_BYTES_STILL_AVAILABLE
Response bytes still available.
Definition apdu.hpp:33
constexpr uint16_t SUCCESSFULLY_1
Command successfully executed; xx bytes of data are available and can be requested using GET RESPONSE...
Definition apdu.hpp:29
SelectOccurrence
Select occurrence for SELECT_FILE.
Definition apdu.hpp:152
@ Next
Select the next match.
@ FirstOrOnly
Select the first (or only) match.
@ Last
Select the last match.
@ Previous
Select the previous match.
constexpr uint16_t master_file_id
Master file ID.
Definition apdu.hpp:170
bool is_response_OK(const uint16_t sw12)
Is response successfully?
Definition apdu.hpp:42
std::vector< uint8_t > make_apdu_case4(const uint8_t cla, const uint8_t ins, const uint8_t p1, const uint8_t p2, const uint8_t *data, const uint16_t data_len, const uint16_t le)
Make APDU case4 command [CLA | INS | P1 | P2 | Lc | C-Data | Le].
Definition apdu.hpp:294
std::vector< uint8_t > make_apdu_case3(const uint8_t cla, const uint8_t ins, const uint8_t p1, const uint8_t p2, const uint8_t *data, const uint16_t data_len)
Make APDU case3 command [CLA | INS | P1 | P2 | Lc | C-Data].
Definition apdu.hpp:277
Top level namespace of M5Stack.
File Control Parameters.
Definition file_system.hpp:26
TLV element.
Definition apdu.hpp:186
bool is_constructed() const
Is constructed TLV?
Definition apdu.hpp:196
bool is_primitive() const
Is primitive TLV?
Definition apdu.hpp:204
uint32_t len
L (length)
Definition apdu.hpp:188
uint8_t tag_len
Tag length.
Definition apdu.hpp:190
uint32_t tag
T (Tag)
Definition apdu.hpp:187