3#include <lib/nfc/protocols/iso14443_3a/iso14443_3a.h>
9#define MF_CLASSIC_CMD_AUTH_KEY_A (0x60U)
10#define MF_CLASSIC_CMD_AUTH_KEY_B (0x61U)
11#define MF_CLASSIC_CMD_BACKDOOR_AUTH_KEY_A (0x64U)
12#define MF_CLASSIC_CMD_BACKDOOR_AUTH_KEY_B (0x65U)
13#define MF_CLASSIC_CMD_READ_BLOCK (0x30U)
14#define MF_CLASSIC_CMD_WRITE_BLOCK (0xA0U)
15#define MF_CLASSIC_CMD_VALUE_DEC (0xC0U)
16#define MF_CLASSIC_CMD_VALUE_INC (0xC1U)
17#define MF_CLASSIC_CMD_VALUE_RESTORE (0xC2U)
18#define MF_CLASSIC_CMD_VALUE_TRANSFER (0xB0U)
20#define MF_CLASSIC_CMD_HALT_MSB (0x50)
21#define MF_CLASSIC_CMD_HALT_LSB (0x00)
22#define MF_CLASSIC_CMD_ACK (0x0A)
23#define MF_CLASSIC_CMD_NACK (0x00)
24#define MF_CLASSIC_CMD_NACK_TRANSFER_INVALID (0x04)
25#define MF_CLASSIC_CMD_NACK_TRANSFER_CRC_ERROR (0x01)
27#define MF_CLASSIC_TOTAL_SECTORS_MAX (40)
28#define MF_CLASSIC_TOTAL_BLOCKS_MAX (256)
29#define MF_CLASSIC_READ_MASK_SIZE (MF_CLASSIC_TOTAL_BLOCKS_MAX / 32)
30#define MF_CLASSIC_BLOCK_SIZE (16)
31#define MF_CLASSIC_KEY_SIZE (6)
32#define MF_CLASSIC_ACCESS_BYTES_SIZE (4)
34#define MF_CLASSIC_NT_SIZE (4)
35#define MF_CLASSIC_NR_SIZE (4)
36#define MF_CLASSIC_AR_SIZE (4)
37#define MF_CLASSIC_AT_SIZE (4)
41 MfClassicErrorNotPresent,
42 MfClassicErrorProtocol,
44 MfClassicErrorPartialRead,
45 MfClassicErrorTimeout,
57 MfClassicActionDataRead,
58 MfClassicActionDataWrite,
59 MfClassicActionDataInc,
60 MfClassicActionDataDec,
62 MfClassicActionKeyARead,
63 MfClassicActionKeyAWrite,
64 MfClassicActionKeyBRead,
65 MfClassicActionKeyBWrite,
66 MfClassicActionACRead,
67 MfClassicActionACWrite,
71 MfClassicValueCommandIncrement,
72 MfClassicValueCommandDecrement,
73 MfClassicValueCommandRestore,
75 MfClassicValueCommandInvalid,
76} MfClassicValueCommand;
79 uint8_t data[MF_CLASSIC_BLOCK_SIZE];
88 uint8_t data[MF_CLASSIC_KEY_SIZE];
92 uint8_t data[MF_CLASSIC_ACCESS_BYTES_SIZE];
96 uint8_t data[MF_CLASSIC_NT_SIZE];
100 uint8_t data[MF_CLASSIC_AT_SIZE];
104 uint8_t data[MF_CLASSIC_NR_SIZE];
108 uint8_t data[MF_CLASSIC_AR_SIZE];
114 MfClassicKeyType key_type;
140 uint32_t block_read_mask[MF_CLASSIC_READ_MASK_SIZE];
166const uint8_t* mf_classic_get_uid(
const MfClassicData* data,
size_t* uid_len);
168bool mf_classic_set_uid(
MfClassicData* data,
const uint8_t* uid,
size_t uid_len);
172uint8_t mf_classic_get_total_sectors_num(MfClassicType type);
174uint16_t mf_classic_get_total_block_num(MfClassicType type);
176uint8_t mf_classic_get_first_block_num_of_sector(uint8_t sector);
178uint8_t mf_classic_get_blocks_num_in_sector(uint8_t sector);
180uint8_t mf_classic_get_sector_trailer_num_by_sector(uint8_t sector);
182uint8_t mf_classic_get_sector_trailer_num_by_block(uint8_t block);
185 mf_classic_get_sector_trailer_by_sector(
const MfClassicData* data, uint8_t sector_num);
187bool mf_classic_is_sector_trailer(uint8_t block);
189void mf_classic_set_sector_trailer_read(
194uint8_t mf_classic_get_sector_by_block(uint8_t block);
196bool mf_classic_block_to_value(
const MfClassicBlock* block, int32_t* value, uint8_t* addr);
198void mf_classic_value_to_block(int32_t value, uint8_t addr,
MfClassicBlock* block);
200bool mf_classic_is_key_found(
203 MfClassicKeyType key_type);
205void mf_classic_set_key_found(
208 MfClassicKeyType key_type,
211void mf_classic_set_key_not_found(
214 MfClassicKeyType key_type);
217 mf_classic_get_key(
const MfClassicData* data, uint8_t sector_num, MfClassicKeyType key_type);
219bool mf_classic_is_block_read(
const MfClassicData* data, uint8_t block_num);
223bool mf_classic_is_sector_read(
const MfClassicData* data, uint8_t sector_num);
225void mf_classic_get_read_sectors_and_keys(
227 uint8_t* sectors_read,
228 uint8_t* keys_found);
234bool mf_classic_is_allowed_access_data_block(
237 MfClassicKeyType key_type,
238 MfClassicAction action);
240bool mf_classic_is_allowed_access(
243 MfClassicKeyType key_type,
244 MfClassicAction action);
NfcDeviceNameType
Verbosity level of the displayed NFC device name.
Definition nfc_device_base.h:14
Definition iso14443_3a.h:58
Definition mf_classic.h:91
Definition mf_classic.h:107
Definition mf_classic.h:99
Definition mf_classic.h:111
Definition mf_classic.h:78
Definition mf_classic.h:137
Definition mf_classic.h:130
Definition mf_classic.h:87
Definition mf_classic.h:103
Definition mf_classic.h:95
Generic NFC device interface.
Definition nfc_device_base_i.h:142
Definition mf_classic.h:121