diff --git a/NEWS b/NEWS index 399e723..a2b7980 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +Changes between 0.3.1 and 0.3.2 [XX xxx XXXX] + + *) New API functions mifare_desfire_create_application_3k3des() and + mifare_desfire_create_application_aes(). + Changes between 0.3.0 and 0.3.1 [23 feb 2011] *) Fix mifare_classic_transfer() for devices returning a 1 byte response on diff --git a/libfreefare/freefare.h b/libfreefare/freefare.h index 842c65e..52c5c36 100644 --- a/libfreefare/freefare.h +++ b/libfreefare/freefare.h @@ -189,6 +189,12 @@ enum mifare_desfire_file_types { #define MDCM_MACED 0x01 #define MDCM_ENCIPHERED 0x03 +/* Mifare DESFire EV1 Application crypto operations */ + +#define APPLICATION_CRYPTO_DES 0x00 +#define APPLICATION_CRYPTO_3K3DES 0x40 +#define APPLICATION_CRYPTO_AES 0x80 + /* Access right */ #define MDAR(read,write,read_write,change_access_rights) ( \ @@ -319,6 +325,8 @@ int mifare_desfire_get_key_settings (MifareTag tag, uint8_t *settings, uint8_t int mifare_desfire_change_key (MifareTag tag, uint8_t key_no, MifareDESFireKey new_key, MifareDESFireKey old_key); int mifare_desfire_get_key_version (MifareTag tag, uint8_t key_no, uint8_t *version); int mifare_desfire_create_application (MifareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no); +int mifare_desfire_create_application_3k3des (MifareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no); +int mifare_desfire_create_application_aes (MifareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no); int mifare_desfire_delete_application (MifareTag tag, MifareDESFireAID aid); int mifare_desfire_get_application_ids (MifareTag tag, MifareDESFireAID *aids[], size_t *count); void mifare_desfire_free_application_ids (MifareDESFireAID aids[]); diff --git a/libfreefare/mifare_desfire.3 b/libfreefare/mifare_desfire.3 index 25b5b95..270a23e 100644 --- a/libfreefare/mifare_desfire.3 +++ b/libfreefare/mifare_desfire.3 @@ -37,6 +37,8 @@ .Nm mifare_desfire_get_key_version , .\" .Nm mifare_desfire_create_application , +.Nm mifare_desfire_create_application_3k3des , +.Nm mifare_desfire_create_application_aes , .Nm mifare_desfire_delete_application , .Nm mifare_desfire_get_application_ids , .Nm mifare_desfire_free_application_ids , @@ -118,6 +120,10 @@ Mifare card manipulation library (libfreefare, \-lfreefare) .Ft int .Fn mifare_desfire_create_application "MifareTag tag" "MifareDESFireAID aid" "uint8_t settings" "uint8_t key_no" .Ft int +.Fn mifare_desfire_create_application_aes "MifareTag tag" "MifareDESFireAID aid" "uint8_t settings" "uint8_t key_no" +.Ft int +.Fn mifare_desfire_create_application_3k3des "MifareTag tag" "MifareDESFireAID aid" "uint8_t settings" "uint8_t key_no" +.Ft int .Fn mifare_desfire_delete_application "MifareTag tag" "MifareDESFireAID aid" .Ft int .Fn mifare_desfire_get_application_ids "MifareTag tag" "MifareDESFireAID *aids[]" "size_t *count" @@ -351,6 +357,23 @@ key settings and authentication keys. Authentication keys are set to 0 after creation. .Pp The +.Fn mifare_desfire_create_application_3k3des +and +.Fn mifare_desfire_create_application_aes +functions acts as the +.Fn mifare_desfire_create_application +function except that the whole application is configured to use 3K3DES or AES +keys. It is possible to achive the same result using the +.Fn mifare_desfire_create_application +function and ORing the +.Vt key_no +argument with +.Vt APPLICATION_CRYPTO_3K3DES +or +.Vt APPLICATION_CRYPTO_AES +respectively. +.Pp +The .Fn mifare_desfire_delete_application deletes the application identified by AID .Vt aid . diff --git a/libfreefare/mifare_desfire.c b/libfreefare/mifare_desfire.c index a8d378a..e0329c9 100644 --- a/libfreefare/mifare_desfire.c +++ b/libfreefare/mifare_desfire.c @@ -657,6 +657,18 @@ mifare_desfire_create_application (MifareTag tag, MifareDESFireAID aid, uint8_t return create_application (tag, aid, settings, key_no, 0, NULL); } +int +mifare_desfire_create_application_3k3des (MifareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no) +{ + return create_application (tag, aid, settings, APPLICATION_CRYPTO_3K3DES | key_no, 0, NULL); +} + +int +mifare_desfire_create_application_aes (MifareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no) +{ + return create_application (tag, aid, settings, APPLICATION_CRYPTO_AES | key_no, 0, NULL); +} + int mifare_desfire_delete_application (MifareTag tag, MifareDESFireAID aid) { diff --git a/test/test_mifare_desfire_ev1_3k3des.c b/test/test_mifare_desfire_ev1_3k3des.c index 566ca52..50ad932 100644 --- a/test/test_mifare_desfire_ev1_3k3des.c +++ b/test/test_mifare_desfire_ev1_3k3des.c @@ -98,12 +98,12 @@ test_mifare_desfire_ev1_3k3des (void) MifareDESFireAID aid_b = mifare_desfire_aid_new (0x00BBBBBB); cut_assert_not_null (aid_b, cut_message ("Cannot allocate AID")); - res = mifare_desfire_create_application (tag, aid_b, 0xEF, 0x40 | 6); + res = mifare_desfire_create_application_3k3des (tag, aid_b, 0xEF, 6); cut_assert_success ("mifare_desfire_create_application()"); MifareDESFireAID aid_c = mifare_desfire_aid_new (0x00CCCCCC); cut_assert_not_null (aid_c, cut_message ("Cannot allocate AID")); - res = mifare_desfire_create_application (tag, aid_c, 0xC2, 0x40 | 14); + res = mifare_desfire_create_application_3k3des (tag, aid_c, 0xC2, 14); cut_assert_success ("mifare_desfire_create_application()"); // Ensure we can find the created applications diff --git a/test/test_mifare_desfire_ev1_aes.c b/test/test_mifare_desfire_ev1_aes.c index 36a0c42..2bec747 100644 --- a/test/test_mifare_desfire_ev1_aes.c +++ b/test/test_mifare_desfire_ev1_aes.c @@ -96,12 +96,12 @@ test_mifare_desfire_ev1_aes (void) MifareDESFireAID aid_b = mifare_desfire_aid_new (0x00BBBBBB); cut_assert_not_null (aid_b, cut_message ("Cannot allocate AID")); - res = mifare_desfire_create_application (tag, aid_b, 0xEF, 0x80 | 6); + res = mifare_desfire_create_application_aes (tag, aid_b, 0xEF, 6); cut_assert_success ("mifare_desfire_create_application()"); MifareDESFireAID aid_c = mifare_desfire_aid_new (0x00CCCCCC); cut_assert_not_null (aid_c, cut_message ("Cannot allocate AID")); - res = mifare_desfire_create_application (tag, aid_c, 0xC2, 0x80 | 14); + res = mifare_desfire_create_application_aes (tag, aid_c, 0xC2, 14); cut_assert_success ("mifare_desfire_create_application()"); // Ensure we can find the created applications