Add support for Mifare DESFire EV1 with AES encryption.
This commit is contained in:
parent
1070d9bfde
commit
42f9457d9f
19 changed files with 2238 additions and 268 deletions
|
|
@ -26,6 +26,9 @@
|
|||
uint8_t key_data_null[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
uint8_t key_data_des[8] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
|
||||
uint8_t key_data_3des[16] = { 'C', 'a', 'r', 'd', ' ', 'M', 'a', 's', 't', 'e', 'r', ' ', 'K', 'e', 'y', '!' };
|
||||
uint8_t key_data_aes[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
const uint8_t key_data_aes_version = 0x42;
|
||||
|
||||
void
|
||||
mifare_desfire_auto_authenticate (MifareTag tag, uint8_t key_no)
|
||||
|
|
@ -41,6 +44,9 @@ mifare_desfire_auto_authenticate (MifareTag tag, uint8_t key_no)
|
|||
case 0x00:
|
||||
key = mifare_desfire_des_key_new_with_version (key_data_null);
|
||||
break;
|
||||
case 0x42:
|
||||
key = mifare_desfire_aes_key_new_with_version (key_data_aes, key_data_aes_version);
|
||||
break;
|
||||
case 0xAA:
|
||||
key = mifare_desfire_des_key_new_with_version (key_data_des);
|
||||
break;
|
||||
|
|
@ -54,7 +60,15 @@ mifare_desfire_auto_authenticate (MifareTag tag, uint8_t key_no)
|
|||
cut_assert_not_null (key, cut_message ("Cannot allocate key"));
|
||||
|
||||
/* Authenticate with this key */
|
||||
res = mifare_desfire_authenticate (tag, key_no, key);
|
||||
switch (key_version) {
|
||||
case 0x00:
|
||||
case 0xAA:
|
||||
case 0xC7:
|
||||
res = mifare_desfire_authenticate (tag, key_no, key);
|
||||
break;
|
||||
case 0x42:
|
||||
res = mifare_desfire_authenticate_aes (tag, key_no, key);
|
||||
}
|
||||
cut_assert_equal_int (0, res, cut_message ("mifare_desfire_authenticate()"));
|
||||
|
||||
mifare_desfire_key_free (key);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
extern uint8_t key_data_null[8];
|
||||
extern uint8_t key_data_des[8];
|
||||
extern uint8_t key_data_3des[16];
|
||||
extern uint8_t key_data_aes[16];
|
||||
extern const uint8_t key_data_aes_version;
|
||||
|
||||
void mifare_desfire_auto_authenticate (MifareTag tag, uint8_t key_no);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue