Flipper Zero Firmware
Loading...
Searching...
No Matches
mf_desfire_i.h
1#pragma once
2
3#include "mf_desfire.h"
4
5#define MF_DESFIRE_FFF_PICC_PREFIX "PICC"
6#define MF_DESFIRE_FFF_APP_PREFIX "Application"
7
8// Successful operation
9#define MF_DESFIRE_STATUS_OPERATION_OK (0x00)
10// No changes done to backup files, CommitTransaction / AbortTransaction not necessary
11#define MF_DESFIRE_STATUS_NO_CHANGES (0x0C)
12// Insufficient NV-Memory to complete command
13#define MF_DESFIRE_STATUS_OUT_OF_EEPROM_ERROR (0x0E)
14// Command code not supported
15#define MF_DESFIRE_STATUS_ILLEGAL_COMMAND_CODE (0x1C)
16// CRC or MAC does not match data Padding bytes not valid
17#define MF_DESFIRE_STATUS_INTEGRITY_ERROR (0x1E)
18// Invalid key number specified
19#define MF_DESFIRE_STATUS_NO_SUCH_KEY (0x40)
20// Length of command string invalid
21#define MF_DESFIRE_STATUS_LENGTH_ERROR (0x7E)
22// Current configuration / status does not allow the requested command
23#define MF_DESFIRE_STATUS_PERMISSION_DENIED (0x9D)
24// Value of the parameter(s) invalid
25#define MF_DESFIRE_STATUS_PARAMETER_ERROR (0x9E)
26// Requested AID not present on PICC
27#define MF_DESFIRE_STATUS_APPLICATION_NOT_FOUND (0xA0)
28// Unrecoverable error within application, application will be disabled
29#define MF_DESFIRE_STATUS_APPL_INTEGRITY_ERROR (0xA1)
30// Current authentication status does not allow the requested command
31#define MF_DESFIRE_STATUS_AUTHENTICATION_ERROR (0xAE)
32// Additional data frame is expected to be sent
33#define MF_DESFIRE_STATUS_ADDITIONAL_FRAME (0xAF)
34// Attempt to read/write data from/to beyond the file's/record's limits
35// Attempt to exceed the limits of a value file.
36#define MF_DESFIRE_STATUS_BOUNDARY_ERROR (0xBE)
37// Unrecoverable error within PICC, PICC will be disabled
38#define MF_DESFIRE_STATUS_PICC_INTEGRITY_ERROR (0xC1)
39// Previous Command was not fully completed. Not all Frames were requested or provided by the PCD
40#define MF_DESFIRE_STATUS_COMMAND_ABORTED (0xCA)
41// PICC was disabled by an unrecoverable error
42#define MF_DESFIRE_STATUS_PICC_DISABLED_ERROR (0xCD)
43// Number of Applications limited to 28, no additional CreateApplication possible
44#define MF_DESFIRE_STATUS_COUNT_ERROR (0xCE)
45// Creation of file/application failed because file/application with same number already exists
46#define MF_DESFIRE_STATUS_DUBLICATE_ERROR (0xDE)
47// Could not complete NV-write operation due to loss of power, internal backup/rollback mechanism activated
48#define MF_DESFIRE_STATUS_EEPROM_ERROR (0xEE)
49// Specified file number does not exist
50#define MF_DESFIRE_STATUS_FILE_NOT_FOUND (0xF0)
51// Unrecoverable error within file, file will be disabled
52#define MF_DESFIRE_STATUS_FILE_INTEGRITY_ERROR (0xF1)
53
54// SimpleArray configurations
55
56extern const SimpleArrayConfig mf_desfire_key_version_array_config;
57extern const SimpleArrayConfig mf_desfire_app_id_array_config;
58extern const SimpleArrayConfig mf_desfire_file_id_array_config;
59extern const SimpleArrayConfig mf_desfire_file_settings_array_config;
60extern const SimpleArrayConfig mf_desfire_file_data_array_config;
61extern const SimpleArrayConfig mf_desfire_application_array_config;
62
63// Parse internal MfDesfire structures
64
65bool mf_desfire_version_parse(MfDesfireVersion* data, const BitBuffer* buf);
66
67bool mf_desfire_free_memory_parse(MfDesfireFreeMemory* data, const BitBuffer* buf);
68
69bool mf_desfire_key_settings_parse(MfDesfireKeySettings* data, const BitBuffer* buf);
70
71bool mf_desfire_key_version_parse(MfDesfireKeyVersion* data, const BitBuffer* buf);
72
73bool mf_desfire_application_id_parse(
75 uint32_t index,
76 const BitBuffer* buf);
77
78bool mf_desfire_file_id_parse(MfDesfireFileId* data, uint32_t index, const BitBuffer* buf);
79
80bool mf_desfire_file_settings_parse(MfDesfireFileSettings* data, const BitBuffer* buf);
81
82bool mf_desfire_file_data_parse(MfDesfireFileData* data, const BitBuffer* buf);
83
84// Init internal MfDesfire structures
85
86void mf_desfire_file_data_init(MfDesfireFileData* data);
87
88void mf_desfire_application_init(MfDesfireApplication* data);
89
90// Reset internal MfDesfire structures
91
92void mf_desfire_file_data_reset(MfDesfireFileData* data);
93
94void mf_desfire_application_reset(MfDesfireApplication* data);
95
96// Copy internal MfDesfire structures
97
98void mf_desfire_file_data_copy(MfDesfireFileData* data, const MfDesfireFileData* other);
99
100void mf_desfire_application_copy(MfDesfireApplication* data, const MfDesfireApplication* other);
101
102// Load internal MfDesfire structures
103
104bool mf_desfire_version_load(MfDesfireVersion* data, FlipperFormat* ff);
105
106bool mf_desfire_free_memory_load(MfDesfireFreeMemory* data, FlipperFormat* ff);
107
108bool mf_desfire_key_settings_load(
110 const char* prefix,
111 FlipperFormat* ff);
112
113bool mf_desfire_key_version_load(
114 MfDesfireKeyVersion* data,
115 const char* prefix,
116 uint32_t index,
117 FlipperFormat* ff);
118
119bool mf_desfire_file_count_load(uint32_t* data, const char* prefix, FlipperFormat* ff);
120
121bool mf_desfire_file_ids_load(
122 MfDesfireFileId* data,
123 uint32_t count,
124 const char* prefix,
125 FlipperFormat* ff);
126
127bool mf_desfire_file_settings_load(
129 const char* prefix,
130 FlipperFormat* ff);
131
132bool mf_desfire_file_data_load(MfDesfireFileData* data, const char* prefix, FlipperFormat* ff);
133
134bool mf_desfire_application_count_load(uint32_t* data, FlipperFormat* ff);
135
136bool mf_desfire_application_ids_load(
138 uint32_t count,
139 FlipperFormat* ff);
140
141bool mf_desfire_application_load(MfDesfireApplication* data, const char* prefix, FlipperFormat* ff);
142
143// Save internal MFDesfire structures
144
145bool mf_desfire_version_save(const MfDesfireVersion* data, FlipperFormat* ff);
146
147bool mf_desfire_free_memory_save(const MfDesfireFreeMemory* data, FlipperFormat* ff);
148
149bool mf_desfire_key_settings_save(
150 const MfDesfireKeySettings* data,
151 const char* prefix,
152 FlipperFormat* ff);
153
154bool mf_desfire_key_version_save(
155 const MfDesfireKeyVersion* data,
156 const char* prefix,
157 uint32_t index,
158 FlipperFormat* ff);
159
160bool mf_desfire_file_ids_save(
161 const MfDesfireFileId* data,
162 uint32_t count,
163 const char* prefix,
164 FlipperFormat* ff);
165
166bool mf_desfire_file_settings_save(
167 const MfDesfireFileSettings* data,
168 const char* prefix,
169 FlipperFormat* ff);
170
171bool mf_desfire_file_data_save(
172 const MfDesfireFileData* data,
173 const char* prefix,
174 FlipperFormat* ff);
175
176bool mf_desfire_application_count_save(const uint32_t* data, FlipperFormat* ff);
177
178bool mf_desfire_application_ids_save(
179 const MfDesfireApplicationId* data,
180 uint32_t count,
181 FlipperFormat* ff);
182
183bool mf_desfire_application_save(
184 const MfDesfireApplication* data,
185 const char* prefix,
186 FlipperFormat* ff);
Definition bit_buffer.c:7
Definition flipper_format.c:12
Definition mf_desfire.h:120
Definition mf_desfire.h:116
Definition mf_desfire.h:112
Definition mf_desfire.h:89
Definition mf_desfire.h:55
Definition mf_desfire.h:60
Definition mf_desfire.h:32
Simple Array configuration structure.
Definition simple_array.h:37