Enable the mifare-desfire-ev1-configure-random-uid example.
This commit is contained in:
parent
b91080ffc7
commit
3fd80a3eff
3 changed files with 60 additions and 0 deletions
|
@ -6,6 +6,7 @@ AM_LDFLAGS = @LIBNFC_LIBS@
|
||||||
bin_PROGRAMS = mifare-classic-format \
|
bin_PROGRAMS = mifare-classic-format \
|
||||||
mifare-classic-write-ndef \
|
mifare-classic-write-ndef \
|
||||||
mifare-desfire-access \
|
mifare-desfire-access \
|
||||||
|
mifare-desfire-ev1-configure-random-uid \
|
||||||
mifare-desfire-format \
|
mifare-desfire-format \
|
||||||
mifare-desfire-info \
|
mifare-desfire-info \
|
||||||
mifare-desfire-write-ndef
|
mifare-desfire-write-ndef
|
||||||
|
@ -19,6 +20,9 @@ mifare_classic_write_ndef_LDADD = -lnfc $(top_builddir)/libfreefare/libfreefare.
|
||||||
mifare_desfire_access_SOURCES = mifare-desfire-access.c
|
mifare_desfire_access_SOURCES = mifare-desfire-access.c
|
||||||
mifare_desfire_access_LDADD = -lnfc $(top_builddir)/libfreefare/libfreefare.la
|
mifare_desfire_access_LDADD = -lnfc $(top_builddir)/libfreefare/libfreefare.la
|
||||||
|
|
||||||
|
mifare_desfire_ev1_configure_random_uid_SOURCES = mifare-desfire-ev1-configure-random-uid.c
|
||||||
|
mifare_desfire_ev1_configure_random_uid_LDADD = -lnfc $(top_builddir)/libfreefare/libfreefare.la
|
||||||
|
|
||||||
mifare_desfire_format_SOURCES = mifare-desfire-format.c
|
mifare_desfire_format_SOURCES = mifare-desfire-format.c
|
||||||
mifare_desfire_format_LDADD = -lnfc $(top_builddir)/libfreefare/libfreefare.la
|
mifare_desfire_format_LDADD = -lnfc $(top_builddir)/libfreefare/libfreefare.la
|
||||||
|
|
||||||
|
|
|
@ -317,6 +317,8 @@ int mifare_desfire_select_application (MifareTag tag, MifareDESFireAID aid);
|
||||||
int mifare_desfire_format_picc (MifareTag tag);
|
int mifare_desfire_format_picc (MifareTag tag);
|
||||||
int mifare_desfire_get_version (MifareTag tag, struct mifare_desfire_version_info *version_info);
|
int mifare_desfire_get_version (MifareTag tag, struct mifare_desfire_version_info *version_info);
|
||||||
int mifare_desfire_free_mem (MifareTag tag, uint32_t *size);
|
int mifare_desfire_free_mem (MifareTag tag, uint32_t *size);
|
||||||
|
int mifare_desfire_set_configuration (MifareTag tag, bool disable_format, bool enable_random_uid);
|
||||||
|
int mifare_desfire_get_card_uid (MifareTag tag, char **uid);
|
||||||
int mifare_desfire_get_file_ids (MifareTag tag, uint8_t *files[], size_t *count);
|
int mifare_desfire_get_file_ids (MifareTag tag, uint8_t *files[], size_t *count);
|
||||||
int mifare_desfire_get_file_settings (MifareTag tag, uint8_t file_no, struct mifare_desfire_file_settings *settings);
|
int mifare_desfire_get_file_settings (MifareTag tag, uint8_t file_no, struct mifare_desfire_file_settings *settings);
|
||||||
int mifare_desfire_change_file_settings (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights);
|
int mifare_desfire_change_file_settings (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights);
|
||||||
|
|
|
@ -835,6 +835,60 @@ mifare_desfire_free_mem (MifareTag tag, uint32_t *size)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
mifare_desfire_set_configuration (MifareTag tag, bool disable_format, bool enable_random_uid)
|
||||||
|
{
|
||||||
|
ASSERT_ACTIVE (tag);
|
||||||
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
|
||||||
|
BUFFER_INIT (cmd, 10);
|
||||||
|
BUFFER_INIT (res, 1 + CMAC_LENGTH);
|
||||||
|
|
||||||
|
BUFFER_APPEND (cmd, 0x5C);
|
||||||
|
BUFFER_APPEND (cmd, 0x00);
|
||||||
|
BUFFER_APPEND (cmd, (enable_random_uid ? 0x02 : 0x00) | (disable_format ? 0x01 : 0x00));
|
||||||
|
|
||||||
|
uint8_t *p = mifare_cryto_preprocess_data (tag, cmd, &__cmd_n, 2, MDCM_ENCIPHERED | ENC_COMMAND);
|
||||||
|
|
||||||
|
DESFIRE_TRANSCEIVE2 (tag, p, __cmd_n, res);
|
||||||
|
|
||||||
|
ssize_t sn = __res_n;
|
||||||
|
p = mifare_cryto_postprocess_data (tag, res, &sn, MDCM_PLAIN | CMAC_COMMAND | CMAC_VERIFY);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
mifare_desfire_get_card_uid (MifareTag tag, char **uid)
|
||||||
|
{
|
||||||
|
ASSERT_ACTIVE (tag);
|
||||||
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
|
||||||
|
ASSERT_NOT_NULL (uid);
|
||||||
|
|
||||||
|
BUFFER_INIT (cmd, 1);
|
||||||
|
BUFFER_INIT (res, 17 + CMAC_LENGTH);
|
||||||
|
|
||||||
|
BUFFER_APPEND (cmd, 0x51);
|
||||||
|
|
||||||
|
uint8_t *p = mifare_cryto_preprocess_data (tag, cmd, &__cmd_n, 1, MDCM_PLAIN | CMAC_COMMAND);
|
||||||
|
|
||||||
|
DESFIRE_TRANSCEIVE2 (tag, p, __cmd_n, res);
|
||||||
|
|
||||||
|
ssize_t sn = __res_n;
|
||||||
|
p = mifare_cryto_postprocess_data (tag, res, &sn, MDCM_ENCIPHERED);
|
||||||
|
|
||||||
|
if (!(*uid = malloc (2*7+1))) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf (*uid, "%02x%02x%02x%02x%02x%02x%02x",
|
||||||
|
p[0], p[1], p[2], p[3],
|
||||||
|
p[4], p[5], p[6]);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Application level commands */
|
/* Application level commands */
|
||||||
|
|
Loading…
Reference in a new issue