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_READ_BLOCK (0x30U)
12#define MF_CLASSIC_CMD_WRITE_BLOCK (0xA0U)
13#define MF_CLASSIC_CMD_VALUE_DEC (0xC0U)
14#define MF_CLASSIC_CMD_VALUE_INC (0xC1U)
15#define MF_CLASSIC_CMD_VALUE_RESTORE (0xC2U)
16#define MF_CLASSIC_CMD_VALUE_TRANSFER (0xB0U)
18#define MF_CLASSIC_CMD_HALT_MSB (0x50)
19#define MF_CLASSIC_CMD_HALT_LSB (0x00)
20#define MF_CLASSIC_CMD_ACK (0x0A)
21#define MF_CLASSIC_CMD_NACK (0x00)
22#define MF_CLASSIC_CMD_NACK_TRANSFER_INVALID (0x04)
23#define MF_CLASSIC_CMD_NACK_TRANSFER_CRC_ERROR (0x01)
25#define MF_CLASSIC_TOTAL_SECTORS_MAX (40)
26#define MF_CLASSIC_TOTAL_BLOCKS_MAX (256)
27#define MF_CLASSIC_READ_MASK_SIZE (MF_CLASSIC_TOTAL_BLOCKS_MAX / 32)
28#define MF_CLASSIC_BLOCK_SIZE (16)
29#define MF_CLASSIC_KEY_SIZE (6)
30#define MF_CLASSIC_ACCESS_BYTES_SIZE (4)
32#define MF_CLASSIC_NT_SIZE (4)
33#define MF_CLASSIC_NR_SIZE (4)
34#define MF_CLASSIC_AR_SIZE (4)
35#define MF_CLASSIC_AT_SIZE (4)
39 MfClassicErrorNotPresent,
40 MfClassicErrorProtocol,
42 MfClassicErrorPartialRead,
43 MfClassicErrorTimeout,
55 MfClassicActionDataRead,
56 MfClassicActionDataWrite,
57 MfClassicActionDataInc,
58 MfClassicActionDataDec,
60 MfClassicActionKeyARead,
61 MfClassicActionKeyAWrite,
62 MfClassicActionKeyBRead,
63 MfClassicActionKeyBWrite,
64 MfClassicActionACRead,
65 MfClassicActionACWrite,
69 MfClassicValueCommandIncrement,
70 MfClassicValueCommandDecrement,
71 MfClassicValueCommandRestore,
73 MfClassicValueCommandInvalid,
74} MfClassicValueCommand;
77 uint8_t data[MF_CLASSIC_BLOCK_SIZE];
86 uint8_t data[MF_CLASSIC_KEY_SIZE];
90 uint8_t data[MF_CLASSIC_ACCESS_BYTES_SIZE];
94 uint8_t data[MF_CLASSIC_NT_SIZE];
98 uint8_t data[MF_CLASSIC_AT_SIZE];
102 uint8_t data[MF_CLASSIC_NR_SIZE];
106 uint8_t data[MF_CLASSIC_AR_SIZE];
112 MfClassicKeyType key_type;
138 uint32_t block_read_mask[MF_CLASSIC_READ_MASK_SIZE];
164const uint8_t* mf_classic_get_uid(
const MfClassicData* data,
size_t* uid_len);
166bool mf_classic_set_uid(
MfClassicData* data,
const uint8_t* uid,
size_t uid_len);
170uint8_t mf_classic_get_total_sectors_num(MfClassicType type);
172uint16_t mf_classic_get_total_block_num(MfClassicType type);
174uint8_t mf_classic_get_first_block_num_of_sector(uint8_t sector);
176uint8_t mf_classic_get_blocks_num_in_sector(uint8_t sector);
178uint8_t mf_classic_get_sector_trailer_num_by_sector(uint8_t sector);
180uint8_t mf_classic_get_sector_trailer_num_by_block(uint8_t block);
183 mf_classic_get_sector_trailer_by_sector(
const MfClassicData* data, uint8_t sector_num);
185bool mf_classic_is_sector_trailer(uint8_t block);
187void mf_classic_set_sector_trailer_read(
192uint8_t mf_classic_get_sector_by_block(uint8_t block);
194bool mf_classic_block_to_value(
const MfClassicBlock* block, int32_t* value, uint8_t* addr);
196void mf_classic_value_to_block(int32_t value, uint8_t addr,
MfClassicBlock* block);
198bool mf_classic_is_key_found(
201 MfClassicKeyType key_type);
203void mf_classic_set_key_found(
206 MfClassicKeyType key_type,
209void mf_classic_set_key_not_found(
212 MfClassicKeyType key_type);
214bool mf_classic_is_block_read(
const MfClassicData* data, uint8_t block_num);
218bool mf_classic_is_sector_read(
const MfClassicData* data, uint8_t sector_num);
220void mf_classic_get_read_sectors_and_keys(
222 uint8_t* sectors_read,
223 uint8_t* keys_found);
229bool mf_classic_is_allowed_access_data_block(
232 MfClassicKeyType key_type,
233 MfClassicAction action);
235bool mf_classic_is_allowed_access(
238 MfClassicKeyType key_type,
239 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:89
Definition mf_classic.h:105
Definition mf_classic.h:97
Definition mf_classic.h:109
Definition mf_classic.h:76
Definition mf_classic.h:135
Definition mf_classic.h:128
Definition mf_classic.h:85
Definition mf_classic.h:101
Definition mf_classic.h:93
Generic NFC device interface.
Definition nfc_device_base_i.h:142
Definition mf_classic.h:119