Fix mifare_desfire_create_value_file().

Fixes issue 59
Committed, thanks!

PR:		Issue 59
Submitted by:	ervin.kaljola
This commit is contained in:
Romain Tartiere 2011-04-23 15:31:45 +00:00
parent 52e1c90425
commit ec16eb5572
2 changed files with 41 additions and 2 deletions

View file

@ -1328,12 +1328,12 @@ mifare_desfire_create_value_file (MifareTag tag, uint8_t file_no, uint8_t commun
BUFFER_APPEND_LE (cmd, value, 4, sizeof (int32_t));
BUFFER_APPEND (cmd, limited_credit_enable);
char *p = mifare_cryto_preprocess_data (tag, cmd, &__cmd_n, 0, communication_settings | CMAC_COMMAND);
char *p = mifare_cryto_preprocess_data (tag, cmd, &__cmd_n, 0, MDCM_PLAIN | CMAC_COMMAND);
DESFIRE_TRANSCEIVE2 (tag, p, __cmd_n, res);
ssize_t sn = __res_n;
p = mifare_cryto_postprocess_data (tag, res, &sn, communication_settings | CMAC_COMMAND | CMAC_VERIFY);
p = mifare_cryto_postprocess_data (tag, res, &sn, MDCM_PLAIN | CMAC_COMMAND | CMAC_VERIFY);
cached_file_settings_current[file_no] = false;

View file

@ -870,3 +870,42 @@ test_mifare_desfire_ev1_aes_write_data_encyphered (void)
free (aid);
}
void
test_mifare_desfire_ev1_aes_create_value_file_encyphered (void)
{
int res;
mifare_desfire_auto_authenticate (tag, 0);
/* Wipeout the card */
res = mifare_desfire_format_picc (tag);
cut_assert_success ("mifare_desfire_format_picc()");
MifareDESFireAID aid = mifare_desfire_aid_new (0x112233);
res = mifare_desfire_create_application (tag, aid, 0x0F, 0x83);
cut_assert_success ("mifare_desfire_create_application()");
res = mifare_desfire_select_application (tag, aid);
cut_assert_success ("mifare_desfire_select_application()");
MifareDESFireKey key = mifare_desfire_aes_key_new (key_data_aes);
res = mifare_desfire_authenticate_aes (tag, 0, key);
cut_assert_success ("mifare_desfire_authenticate_aes()");
mifare_desfire_key_free (key);
res = mifare_desfire_create_value_file (tag, 9, MDCM_ENCIPHERED, 0x0000, 0, 1000, 0, 0);
cut_assert_success ("mifare_desfire_create_value_file");
res = mifare_desfire_select_application (tag, NULL);
cut_assert_success ("mifare_desfire_select_application()");
mifare_desfire_auto_authenticate (tag, 0);
/* Wipeout the card */
res = mifare_desfire_format_picc (tag);
cut_assert_success ("mifare_desfire_format_picc()");
free (aid);
}