]>
Commit | Line | Data |
---|---|---|
f38a1528 | 1 | //----------------------------------------------------------------------------- |
2d3f8e5f | 2 | // Iceman, 2014 |
f38a1528 | 3 | // |
4 | // This code is licensed to you under the terms of the GNU GPL, version 2 or, | |
5 | // at your option, any later version. See the LICENSE.txt file for the text of | |
6 | // the license. | |
7 | //----------------------------------------------------------------------------- | |
8 | // High frequency MIFARE Desfire commands | |
9 | //----------------------------------------------------------------------------- | |
2d3f8e5f | 10 | #ifndef __MFDESFIRE_H |
11 | #define __MFDESFIRE_H | |
f38a1528 | 12 | |
13 | int CmdHFMFDes(const char *Cmd); | |
14 | int CmdHF14ADesAuth(const char* cmd); | |
15 | int CmdHF14ADesRb(const char* cmd); | |
16 | int CmdHF14ADesWb(const char* cmd); | |
17 | int CmdHF14ADesInfo(const char *Cmd); | |
18 | int CmdHF14ADesEnumApplications(const char *Cmd); | |
95e63594 | 19 | |
f38a1528 | 20 | char * GetCardSizeStr( uint8_t fsize ); |
288c6845 | 21 | char * GetProtocolStr( uint8_t id ); |
22 | char * GetVersionStr( uint8_t major, uint8_t minor ); | |
23 | void GetKeySettings( uint8_t * aid ); | |
313ee67e | 24 | |
75465377 | 25 | // Command options for Desfire behavior. |
26 | enum { | |
27 | NONE = 0x00, | |
28 | INIT = 0x01, | |
29 | DISCONNECT = 0x02, | |
f6c18637 | 30 | CLEARTRACE = 0x04, |
75465377 | 31 | BAR = 0x08, |
32 | } CmdOptions ; | |
313ee67e | 33 | |
34 | ||
2d3f8e5f | 35 | #define CREATE_APPLICATION 0xca |
36 | #define DELETE_APPLICATION 0xda | |
37 | #define GET_APPLICATION_IDS 0x6a | |
38 | #define SELECT_APPLICATION 0x5a | |
39 | #define FORMAT_PICC 0xfc | |
40 | #define GET_VERSION 0x60 | |
41 | #define READ_DATA 0xbd | |
42 | #define WRITE_DATA 0x3d | |
43 | #define GET_VALUE 0x6c | |
44 | #define CREDIT 0x0c | |
45 | #define DEBIT 0xdc | |
46 | #define LIMITED_CREDIT 0x1c | |
47 | #define WRITE_RECORD 0x3b | |
48 | #define READ_RECORDS 0xbb | |
49 | #define CLEAR_RECORD_FILE 0xeb | |
50 | #define COMMIT_TRANSACTION 0xc7 | |
51 | #define ABORT_TRANSACTION 0xa7 | |
52 | #define GET_FREE_MEMORY 0x6e | |
53 | #define GET_FILE_IDS 0x6f | |
54 | #define GET_ISOFILE_IDS 0x61 | |
55 | #define GET_FILE_SETTINGS 0xf5 | |
56 | #define CHANGE_FILE_SETTINGS 0x5f | |
57 | #define CREATE_STD_DATA_FILE 0xcd | |
58 | #define CREATE_BACKUP_DATA_FILE 0xcb | |
59 | #define CREATE_VALUE_FILE 0xcc | |
60 | #define CREATE_LINEAR_RECORD_FILE 0xc1 | |
61 | #define CREATE_CYCLIC_RECORD_FILE 0xc0 | |
62 | #define DELETE_FILE 0xdf | |
63 | #define AUTHENTICATE 0x0a // AUTHENTICATE_NATIVE | |
64 | #define AUTHENTICATE_ISO 0x1a // AUTHENTICATE_STANDARD | |
65 | #define AUTHENTICATE_AES 0xaa | |
66 | #define CHANGE_KEY_SETTINGS 0x54 | |
67 | #define GET_KEY_SETTINGS 0x45 | |
68 | #define CHANGE_KEY 0xc4 | |
69 | #define GET_KEY_VERSION 0x64 | |
70 | #define AUTHENTICATION_FRAME 0xAF | |
3d93d4f9 | 71 | |
f6c18637 | 72 | #define MAX_NUM_KEYS 0x0F |
3d93d4f9 | 73 | #define MAX_APPLICATION_COUNT 28 |
f6c18637 | 74 | #define MAX_FILE_COUNT 32 |
3d93d4f9 | 75 | #define MAX_FRAME_SIZE 60 |
76 | #define NOT_YET_AUTHENTICATED 255 | |
bc908d8f | 77 | #define FRAME_PAYLOAD_SIZE (MAX_FRAME_SIZE - 5) |
78 | ||
79 | ||
80 | // status- and error codes | | |
81 | #define OPERATION_OK 0x00 // Successful operation | |
82 | #define NO_CHANGES 0x0C // No changes done to backup files | |
83 | // ,CommitTransaction/ | |
84 | // AbortTransaction not necessary | |
85 | #define OUT_OF_EEPROM_ERROR 0x0E // Insufficient NV-Memory to | |
86 | // complete command | |
87 | #define ILLEGAL_COMMAND_CODE 0x1C // Command code not supported | |
88 | #define INTEGRITY_ERROR 0x1E // CRC or MAC does not match data | |
89 | // Padding bytes not valid | |
90 | #define NO_SUCH_KEY 0x40 // Invalid key number specified | |
91 | #define LENGTH_ERROR 0x7E // Length of command string invalid | |
92 | #define PERMISSION_DENIED 0x9D // Current configuration status | |
93 | // does not allow the requested | |
94 | // command | |
95 | #define PARAMETER_ERROR 0x9E // Value of the parameter(s) inval. | |
96 | #define APPLICATION_NOT_FOUND 0xA0 // Requested AID not present on PIC | |
97 | #define APPL_INTEGRITY_ERROR 0xA1 // [1] // Unrecoverable error within app- | |
98 | // lication, app will be disabled | |
99 | #define AUTHENTICATION_ERROR 0xAE // Current authentication status | |
100 | // does not allow the requested | |
101 | // command | |
102 | #define ADDITIONAL_FRAME 0xAF // Additional data frame is | |
103 | // expected to be sent | |
104 | #define BOUNDARY_ERROR 0xBE // Attempt to read/write data from/ | |
105 | // to beyond the file's/record's | |
106 | // limits. Attempt to exceed the | |
107 | // limits of a value file. | |
108 | #define PICC_INTEGRITY_ERROR 0xC1 // [1] // Unrecoverable error within PICC | |
109 | // ,PICC will be disabled | |
110 | #define COMMAND_ABORTED 0xCA // Previous Command was not fully | |
111 | // completed Not all Frames were | |
112 | // requested or provided by PCD | |
2d3f8e5f | 113 | #define PICC_DISABLED_ERROR 0xCD // [1] // PICC was disabled by an unrecoverable error |
bc908d8f | 114 | #define COUNT_ERROR 0xCE // Number of Applications limited |
115 | // to 28, no additional | |
116 | // CreateApplication possible | |
117 | #define DUPLICATE_ERROR 0xDE // Creation of file/application | |
118 | // failed because file/application | |
119 | // with same number already exists | |
120 | #define EEPROM_ERROR 0xEE // [1] // Could not complete NV-write | |
121 | // operation due to loss of power, | |
122 | // internal backup/rollback | |
123 | // mechanism activated | |
124 | #define FILE_NOT_FOUND_ERROR 0xF0 // Specified file number does not | |
125 | // exist | |
126 | #define FILE_INTEGRITY_ERROR 0xF1 // [1] // Unrecoverable error within file, | |
127 | // file will be disabled | |
128 | // | |
2d3f8e5f | 129 | // [1] These errors are not expected to appear during normal operation |
130 | ||
131 | #endif |