New API functions mifare_desfire_create_application_3k3des(), mifare_desfire_create_application_aes().

Update issue 37
Only ISO application creation as requested by Issue 57 is lacking now.
This commit is contained in:
Romain Tartiere 2011-03-25 13:00:24 +00:00
parent 4b41f8b78b
commit c7dc9f0ccc
6 changed files with 52 additions and 4 deletions

5
NEWS
View file

@ -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] Changes between 0.3.0 and 0.3.1 [23 feb 2011]
*) Fix mifare_classic_transfer() for devices returning a 1 byte response on *) Fix mifare_classic_transfer() for devices returning a 1 byte response on

View file

@ -189,6 +189,12 @@ enum mifare_desfire_file_types {
#define MDCM_MACED 0x01 #define MDCM_MACED 0x01
#define MDCM_ENCIPHERED 0x03 #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 */ /* Access right */
#define MDAR(read,write,read_write,change_access_rights) ( \ #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_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_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 (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_delete_application (MifareTag tag, MifareDESFireAID aid);
int mifare_desfire_get_application_ids (MifareTag tag, MifareDESFireAID *aids[], size_t *count); int mifare_desfire_get_application_ids (MifareTag tag, MifareDESFireAID *aids[], size_t *count);
void mifare_desfire_free_application_ids (MifareDESFireAID aids[]); void mifare_desfire_free_application_ids (MifareDESFireAID aids[]);

View file

@ -37,6 +37,8 @@
.Nm mifare_desfire_get_key_version , .Nm mifare_desfire_get_key_version ,
.\" .\"
.Nm mifare_desfire_create_application , .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_delete_application ,
.Nm mifare_desfire_get_application_ids , .Nm mifare_desfire_get_application_ids ,
.Nm mifare_desfire_free_application_ids , .Nm mifare_desfire_free_application_ids ,
@ -118,6 +120,10 @@ Mifare card manipulation library (libfreefare, \-lfreefare)
.Ft int .Ft int
.Fn mifare_desfire_create_application "MifareTag tag" "MifareDESFireAID aid" "uint8_t settings" "uint8_t key_no" .Fn mifare_desfire_create_application "MifareTag tag" "MifareDESFireAID aid" "uint8_t settings" "uint8_t key_no"
.Ft int .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" .Fn mifare_desfire_delete_application "MifareTag tag" "MifareDESFireAID aid"
.Ft int .Ft int
.Fn mifare_desfire_get_application_ids "MifareTag tag" "MifareDESFireAID *aids[]" "size_t *count" .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. authentication keys. Authentication keys are set to 0 after creation.
.Pp .Pp
The 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 .Fn mifare_desfire_delete_application
deletes the application identified by AID deletes the application identified by AID
.Vt aid . .Vt aid .

View file

@ -657,6 +657,18 @@ mifare_desfire_create_application (MifareTag tag, MifareDESFireAID aid, uint8_t
return create_application (tag, aid, settings, key_no, 0, NULL); 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 int
mifare_desfire_delete_application (MifareTag tag, MifareDESFireAID aid) mifare_desfire_delete_application (MifareTag tag, MifareDESFireAID aid)
{ {

View file

@ -98,12 +98,12 @@ test_mifare_desfire_ev1_3k3des (void)
MifareDESFireAID aid_b = mifare_desfire_aid_new (0x00BBBBBB); MifareDESFireAID aid_b = mifare_desfire_aid_new (0x00BBBBBB);
cut_assert_not_null (aid_b, cut_message ("Cannot allocate AID")); 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()"); cut_assert_success ("mifare_desfire_create_application()");
MifareDESFireAID aid_c = mifare_desfire_aid_new (0x00CCCCCC); MifareDESFireAID aid_c = mifare_desfire_aid_new (0x00CCCCCC);
cut_assert_not_null (aid_c, cut_message ("Cannot allocate AID")); 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()"); cut_assert_success ("mifare_desfire_create_application()");
// Ensure we can find the created applications // Ensure we can find the created applications

View file

@ -96,12 +96,12 @@ test_mifare_desfire_ev1_aes (void)
MifareDESFireAID aid_b = mifare_desfire_aid_new (0x00BBBBBB); MifareDESFireAID aid_b = mifare_desfire_aid_new (0x00BBBBBB);
cut_assert_not_null (aid_b, cut_message ("Cannot allocate AID")); 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()"); cut_assert_success ("mifare_desfire_create_application()");
MifareDESFireAID aid_c = mifare_desfire_aid_new (0x00CCCCCC); MifareDESFireAID aid_c = mifare_desfire_aid_new (0x00CCCCCC);
cut_assert_not_null (aid_c, cut_message ("Cannot allocate AID")); 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()"); cut_assert_success ("mifare_desfire_create_application()");
// Ensure we can find the created applications // Ensure we can find the created applications