Skip to content

Commit e668277

Browse files
committed
moved desfire keys to Secrets.h
1 parent 1e88fc6 commit e668277

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

src/Secrets.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// The PICC master key.
2+
// This 3K3DES or AES key is the "god key".
3+
// It allows to format the card and erase ALL it's content (except the PICC master key itself).
4+
// This key will be stored on your Desfire card when you execute the command "ADD {Username}" in the terminal.
5+
// To restore the master key to the factory default DES key use the command "RESTORE" in the terminal.
6+
// If you set the compiler switch USE_AES = true, only the first 16 bytes of this key will be used.
7+
// IMPORTANT: Before changing this key, please execute the RESTORE command on all personalized cards!
8+
// IMPORTANT: When you compile for DES, the least significant bit (bit 0) of all bytes in this key
9+
// will be modified, because it stores the key version.
10+
const byte SECRET_PICC_MASTER_KEY[24] = {0xAA, 0x08, 0x57, 0x92, 0x1C, 0x76, 0xFF, 0x65, 0xE7, 0xD2, 0x78, 0x44, 0xF8, 0x0F, 0x8D, 0x1B, 0xE7, 0xC2, 0xF0, 0x89, 0x04, 0xC0, 0xC3, 0xE3};
11+
12+
// This 3K3DES key is used to derive a 16 byte application master key from the UID of the card and the user name.
13+
// The purpose is that each card will have it's unique application master key that can be calculated from known values.
14+
const byte SECRET_APPLICATION_KEY[24] = {0x81, 0xDF, 0x6A, 0xD9, 0x89, 0xE9, 0xA2, 0xD1, 0xC5, 0xB3, 0xE3, 0x9D, 0xE9, 0x60, 0x43, 0xE3, 0x5B, 0x60, 0x85, 0x8B, 0x99, 0xD8, 0xD3, 0x5B};
15+
16+
// This 3K3DES key is used to derive the 16 byte store value from the UID of the card and the user name.
17+
// This value is stored in a standard data file on the card.
18+
// The purpose is that each card will have it's unique store value that can be calculated from known values.
19+
const byte SECRET_STORE_VALUE_KEY[24] = {0x1E, 0x5D, 0x78, 0x57, 0x68, 0xFC, 0xEE, 0xC9, 0x40, 0xEC, 0x30, 0xDE, 0xEC, 0xA9, 0x8B, 0x3C, 0x7F, 0x8A, 0xC9, 0xC3, 0xAA, 0xD7, 0x4F, 0x17};
20+
21+
// -----------------------------------------------------------------------------------------------------------
22+
23+
// The ID of the application to be created
24+
// This value must be between 0x000001 and 0xFFFFFF (NOT zero!)
25+
const uint32_t CARD_APPLICATION_ID = 0xAA401F;
26+
27+
// The ID of the file to be created in the above application
28+
// This value must be between 0 and 31
29+
const byte CARD_FILE_ID = 0;
30+
31+
// This 8 bit version number is uploaded to the card together with the key itself.
32+
// This version is irrelevant for encryption.
33+
// It is just a version number for the key that you can obtain with Desfire::GetKeyVersion().
34+
// The key version can always be obtained without authentication.
35+
// You can theoretically have multiple master keys and by obtaining the version you know which one to use for authentication.
36+
// This value must be between 1 and 255 (NOT zero!)
37+
const byte CARD_KEY_VERSION = 0x10;

src/main.cpp

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ IO2 io2 = IO2(); // set I2C address of MOD-IO2
4747
#include <AsyncMqttClient.h>
4848
#include <Bounce2.h>
4949
#include <Desfire.h>
50+
#include "Secrets.h"
5051
#include <PN532.h>
5152
// #include <esp_task_wdt.h>
5253
#include <Update.h>
@@ -78,44 +79,6 @@ bool activateRelay[MAX_NUM_RELAYS] = {false};
7879
bool deactivateRelay[MAX_NUM_RELAYS] = {false};
7980
#endif
8081

81-
// The PICC master key.
82-
// This 3K3DES or AES key is the "god key".
83-
// It allows to format the card and erase ALL it's content (except the PICC master key itself).
84-
// This key will be stored on your Desfire card when you execute the command "ADD {Username}" in the terminal.
85-
// To restore the master key to the factory default DES key use the command "RESTORE" in the terminal.
86-
// If you set the compiler switch USE_AES = true, only the first 16 bytes of this key will be used.
87-
// IMPORTANT: Before changing this key, please execute the RESTORE command on all personalized cards!
88-
// IMPORTANT: When you compile for DES, the least significant bit (bit 0) of all bytes in this key
89-
// will be modified, because it stores the key version.
90-
const byte SECRET_PICC_MASTER_KEY[24] = {0xAA, 0x08, 0x57, 0x92, 0x1C, 0x76, 0xFF, 0x65, 0xE7, 0xD2, 0x78, 0x44, 0xF8, 0x0F, 0x8D, 0x1B, 0xE7, 0xC2, 0xF0, 0x89, 0x04, 0xC0, 0xC3, 0xE3};
91-
92-
// This 3K3DES key is used to derive a 16 byte application master key from the UID of the card and the user name.
93-
// The purpose is that each card will have it's unique application master key that can be calculated from known values.
94-
const byte SECRET_APPLICATION_KEY[24] = {0x81, 0xDF, 0x6A, 0xD9, 0x89, 0xE9, 0xA2, 0xD1, 0xC5, 0xB3, 0xE3, 0x9D, 0xE9, 0x60, 0x43, 0xE3, 0x5B, 0x60, 0x85, 0x8B, 0x99, 0xD8, 0xD3, 0x5B};
95-
96-
// This 3K3DES key is used to derive the 16 byte store value from the UID of the card and the user name.
97-
// This value is stored in a standard data file on the card.
98-
// The purpose is that each card will have it's unique store value that can be calculated from known values.
99-
const byte SECRET_STORE_VALUE_KEY[24] = {0x1E, 0x5D, 0x78, 0x57, 0x68, 0xFC, 0xEE, 0xC9, 0x40, 0xEC, 0x30, 0xDE, 0xEC, 0xA9, 0x8B, 0x3C, 0x7F, 0x8A, 0xC9, 0xC3, 0xAA, 0xD7, 0x4F, 0x17};
100-
101-
// -----------------------------------------------------------------------------------------------------------
102-
103-
// The ID of the application to be created
104-
// This value must be between 0x000001 and 0xFFFFFF (NOT zero!)
105-
const uint32_t CARD_APPLICATION_ID = 0xAA401F;
106-
107-
// The ID of the file to be created in the above application
108-
// This value must be between 0 and 31
109-
const byte CARD_FILE_ID = 0;
110-
111-
// This 8 bit version number is uploaded to the card together with the key itself.
112-
// This version is irrelevant for encryption.
113-
// It is just a version number for the key that you can obtain with Desfire::GetKeyVersion().
114-
// The key version can always be obtained without authentication.
115-
// You can theoretically have multiple master keys and by obtaining the version you know which one to use for authentication.
116-
// This value must be between 1 and 255 (NOT zero!)
117-
const byte CARD_KEY_VERSION = 0x10;
118-
11982
// these are from vendors
12083
#include "webh/bootstrap-icons.woff2.gz.h"
12184
#include "webh/required.css.gz.h"

0 commit comments

Comments
 (0)