diff --git a/HACKING b/HACKING index 62c79a3..964362c 100644 --- a/HACKING +++ b/HACKING @@ -47,13 +47,13 @@ Adding a new supported card to the libfreefare requires a few modification in multiple places. Here is a list of the things to do in order to have the infrastructure ready for hacking the new card support: - Edit libfreefare/freefare.h: - - Add your tag to the `mifare_tag_type' enum; + - Add your tag to the `freefare_tag_type' enum; - Add a _connect() and a _disconnect() function prototype; - Edit libfreefare/freefare.3: - - Add your tag to the `mifare_tag_type' enum documentation; + - Add your tag to the `freefare_tag_type' enum documentation; - Edit libfreefare/freefare_internal.h: - Add a new _tag struct. It's very first member SHALL be `struct - mifare_tag __tag'; + freefare_tag __tag'; - Add a _tag_new() and a _tag_free() function prototype; - Add a ASSERT_() macro to check the tag's type; - Add a () macro to cast a generic tag to your type. diff --git a/contrib/libfreefare_zsnippets.vim b/contrib/libfreefare_zsnippets.vim index 5d74ccb..1094d97 100644 --- a/contrib/libfreefare_zsnippets.vim +++ b/contrib/libfreefare_zsnippets.vim @@ -54,7 +54,7 @@ exec "Snippet MD MIFARE_DESFIRE".st.et exec "Snippet MDA MifareDESFireAID".st.et exec "Snippet MDK MifareDESFireKey".st.et -exec "Snippet MT MifareTag".st.et +exec "Snippet MT FreefareTag".st.et exec "Snippet MU MIFARE_ULTRALIGHT".st.et exec "Snippet MUP MifareUltralightPage".st.et diff --git a/examples/mifare-classic-format.c b/examples/mifare-classic-format.c index 30f75ea..df03294 100644 --- a/examples/mifare-classic-format.c +++ b/examples/mifare-classic-format.c @@ -44,9 +44,9 @@ MifareClassicKey default_keys_int[] = { { 0xaa,0xbb,0xcc,0xdd,0xee,0xff }, { 0x00,0x00,0x00,0x00,0x00,0x00 } }; -int format_mifare_classic_1k (MifareTag tag); -int format_mifare_classic_4k (MifareTag tag); -int try_format_sector (MifareTag tag, MifareClassicSectorNumber sector); +int format_mifare_classic_1k (FreefareTag tag); +int format_mifare_classic_4k (FreefareTag tag); +int try_format_sector (FreefareTag tag, MifareClassicSectorNumber sector); static int at_block = 0; static int mod_block = 10; @@ -73,7 +73,7 @@ display_progress (void) } int -format_mifare_classic_1k (MifareTag tag) +format_mifare_classic_1k (FreefareTag tag) { printf (START_FORMAT_N, 16); for (int sector = 0; sector < 16; sector++) { @@ -85,7 +85,7 @@ format_mifare_classic_1k (MifareTag tag) } int -format_mifare_classic_4k (MifareTag tag) +format_mifare_classic_4k (FreefareTag tag) { printf (START_FORMAT_N, 32 + 8); for (int sector = 0; sector < (32 + 8); sector++) { @@ -97,7 +97,7 @@ format_mifare_classic_4k (MifareTag tag) } int -try_format_sector (MifareTag tag, MifareClassicSectorNumber sector) +try_format_sector (FreefareTag tag, MifareClassicSectorNumber sector) { display_progress (); for (size_t i = 0; i < (sizeof (default_keys) / sizeof (MifareClassicKey)); i++) { @@ -143,7 +143,7 @@ main(int argc, char *argv[]) int ch; int error = EXIT_SUCCESS; nfc_device *device = NULL; - MifareTag *tags = NULL; + FreefareTag *tags = NULL; while ((ch = getopt (argc, argv, "fhy")) != -1) { switch (ch) { @@ -238,7 +238,7 @@ main(int argc, char *argv[]) } if (format) { - enum mifare_tag_type tt = freefare_get_tag_type (tags[i]); + enum freefare_tag_type tt = freefare_get_tag_type (tags[i]); at_block = 0; if (format_options.fast) { diff --git a/examples/mifare-classic-read-ndef.c b/examples/mifare-classic-read-ndef.c index 7443dca..09fabfd 100644 --- a/examples/mifare-classic-read-ndef.c +++ b/examples/mifare-classic-read-ndef.c @@ -67,7 +67,7 @@ main(int argc, char *argv[]) { int error = 0; nfc_device *device = NULL; - MifareTag *tags = NULL; + FreefareTag *tags = NULL; Mad mad; int ch; diff --git a/examples/mifare-classic-write-ndef.c b/examples/mifare-classic-write-ndef.c index 5bc02c8..6e83647 100644 --- a/examples/mifare-classic-write-ndef.c +++ b/examples/mifare-classic-write-ndef.c @@ -69,7 +69,7 @@ uint8_t *ndef_msg; size_t ndef_msg_len; static int -search_sector_key (MifareTag tag, MifareClassicSectorNumber sector, MifareClassicKey *key, MifareClassicKeyType *key_type) +search_sector_key (FreefareTag tag, MifareClassicSectorNumber sector, MifareClassicKey *key, MifareClassicKeyType *key_type) { MifareClassicBlockNumber block = mifare_classic_sector_last_block (sector); @@ -107,7 +107,7 @@ search_sector_key (MifareTag tag, MifareClassicSectorNumber sector, MifareClassi } static int -fix_mad_trailer_block (nfc_device *device, MifareTag tag, MifareClassicSectorNumber sector, MifareClassicKey key, MifareClassicKeyType key_type) +fix_mad_trailer_block (nfc_device *device, FreefareTag tag, MifareClassicSectorNumber sector, MifareClassicKey key, MifareClassicKeyType key_type) { MifareClassicBlock block; mifare_classic_trailer_block (&block, mad_public_key_a, 0x0, 0x1, 0x1, 0x6, 0x00, default_keyb); @@ -136,7 +136,7 @@ main(int argc, char *argv[]) { int error = 0; nfc_device *device = NULL; - MifareTag *tags = NULL; + FreefareTag *tags = NULL; Mad mad; MifareClassicKey transport_key = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; diff --git a/examples/mifare-desfire-access.c b/examples/mifare-desfire-access.c index 3c38c73..1120f0c 100644 --- a/examples/mifare-desfire-access.c +++ b/examples/mifare-desfire-access.c @@ -33,7 +33,7 @@ main(int argc, char *argv[]) { int error = EXIT_SUCCESS; nfc_device *device = NULL; - MifareTag *tags = NULL; + FreefareTag *tags = NULL; if (argc > 1) errx (EXIT_FAILURE, "usage: %s", argv[0]); diff --git a/examples/mifare-desfire-create-ndef.c b/examples/mifare-desfire-create-ndef.c index d2a6ee6..97c0c80 100644 --- a/examples/mifare-desfire-create-ndef.c +++ b/examples/mifare-desfire-create-ndef.c @@ -63,7 +63,7 @@ main(int argc, char *argv[]) int ch; int error = EXIT_SUCCESS; nfc_device *device = NULL; - MifareTag *tags = NULL; + FreefareTag *tags = NULL; while ((ch = getopt (argc, argv, "hyK:")) != -1) { switch (ch) { diff --git a/examples/mifare-desfire-ev1-configure-ats.c b/examples/mifare-desfire-ev1-configure-ats.c index c7e71a3..f50ab19 100644 --- a/examples/mifare-desfire-ev1-configure-ats.c +++ b/examples/mifare-desfire-ev1-configure-ats.c @@ -56,7 +56,7 @@ main(int argc, char *argv[]) int ch; int error = EXIT_SUCCESS; nfc_device *device = NULL; - MifareTag *tags = NULL; + FreefareTag *tags = NULL; while ((ch = getopt (argc, argv, "hyK:")) != -1) { switch (ch) { diff --git a/examples/mifare-desfire-ev1-configure-default-key.c b/examples/mifare-desfire-ev1-configure-default-key.c index 462f9a8..5fb1ff3 100644 --- a/examples/mifare-desfire-ev1-configure-default-key.c +++ b/examples/mifare-desfire-ev1-configure-default-key.c @@ -54,7 +54,7 @@ main(int argc, char *argv[]) int ch; int error = EXIT_SUCCESS; nfc_device *device = NULL; - MifareTag *tags = NULL; + FreefareTag *tags = NULL; while ((ch = getopt (argc, argv, "hy")) != -1) { switch (ch) { diff --git a/examples/mifare-desfire-ev1-configure-random-uid.c b/examples/mifare-desfire-ev1-configure-random-uid.c index 65e23e5..60d96c7 100644 --- a/examples/mifare-desfire-ev1-configure-random-uid.c +++ b/examples/mifare-desfire-ev1-configure-random-uid.c @@ -52,7 +52,7 @@ main(int argc, char *argv[]) int ch; int error = EXIT_SUCCESS; nfc_device *device = NULL; - MifareTag *tags = NULL; + FreefareTag *tags = NULL; while ((ch = getopt (argc, argv, "hyK:")) != -1) { switch (ch) { diff --git a/examples/mifare-desfire-format.c b/examples/mifare-desfire-format.c index e4271b8..137005d 100644 --- a/examples/mifare-desfire-format.c +++ b/examples/mifare-desfire-format.c @@ -52,7 +52,7 @@ main(int argc, char *argv[]) int ch; int error = EXIT_SUCCESS; nfc_device *device = NULL; - MifareTag *tags = NULL; + FreefareTag *tags = NULL; while ((ch = getopt (argc, argv, "hyK:")) != -1) { switch (ch) { diff --git a/examples/mifare-desfire-info.c b/examples/mifare-desfire-info.c index fc9172f..5174e38 100644 --- a/examples/mifare-desfire-info.c +++ b/examples/mifare-desfire-info.c @@ -31,7 +31,7 @@ main(int argc, char *argv[]) { int error = EXIT_SUCCESS; nfc_device *device = NULL; - MifareTag *tags = NULL; + FreefareTag *tags = NULL; if (argc > 1) errx (EXIT_FAILURE, "usage: %s", argv[0]); diff --git a/examples/mifare-desfire-read-ndef.c b/examples/mifare-desfire-read-ndef.c index 38055c2..79fa674 100644 --- a/examples/mifare-desfire-read-ndef.c +++ b/examples/mifare-desfire-read-ndef.c @@ -68,7 +68,7 @@ main(int argc, char *argv[]) int ch; int error = EXIT_SUCCESS; nfc_device *device = NULL; - MifareTag *tags = NULL; + FreefareTag *tags = NULL; char *ndef_output = NULL; while ((ch = getopt (argc, argv, "hyo:k:")) != -1) { diff --git a/examples/mifare-desfire-write-ndef.c b/examples/mifare-desfire-write-ndef.c index 2c8746a..264aad3 100644 --- a/examples/mifare-desfire-write-ndef.c +++ b/examples/mifare-desfire-write-ndef.c @@ -76,7 +76,7 @@ main(int argc, char *argv[]) int ch; int error = EXIT_SUCCESS; nfc_device *device = NULL; - MifareTag *tags = NULL; + FreefareTag *tags = NULL; char *ndef_input = NULL; while ((ch = getopt (argc, argv, "hyi:k:")) != -1) { diff --git a/examples/mifare-ultralight-info.c b/examples/mifare-ultralight-info.c index b3793af..b4099ec 100644 --- a/examples/mifare-ultralight-info.c +++ b/examples/mifare-ultralight-info.c @@ -28,7 +28,7 @@ main (int argc, char *argv[]) { int error = EXIT_SUCCESS; nfc_device *device = NULL; - MifareTag *tags = NULL; + FreefareTag *tags = NULL; if (argc > 1) errx (EXIT_FAILURE, "usage: %s", argv[0]); @@ -69,7 +69,7 @@ main (int argc, char *argv[]) char *tag_uid = freefare_get_tag_uid (tags[i]); printf ("Tag with UID %s is a %s\n", tag_uid, freefare_get_tag_friendly_name (tags[i])); if (freefare_get_tag_type (tags[i]) == ULTRALIGHT_C) { - MifareTag tag = tags[i]; + FreefareTag tag = tags[i]; int res; MifareDESFireKey key; uint8_t key1_3des_data[16] = { 0x49, 0x45, 0x4D, 0x4B, 0x41, 0x45, 0x52, 0x42, 0x21, 0x4E, 0x41, 0x43, 0x55, 0x4F, 0x59, 0x46 }; diff --git a/libfreefare/freefare.3 b/libfreefare/freefare.3 index d9321c4..f94e10d 100644 --- a/libfreefare/freefare.3 +++ b/libfreefare/freefare.3 @@ -48,25 +48,25 @@ Mifare card manipulation library (libfreefare, \-lfreefare) .\" |___/ |_| .Sh SYNOPSIS .In freefare.h -.Ft "MifareTag *" +.Ft "FreefareTag *" .Fn freefare_get_tags "nfc_device_t *device" .Bd -literal -enum mifare_tag_type { +enum freefare_tag_type { ULTRALIGHT, CLASSIC_1K, CLASSIC_4K }; .Ed -.Ft "enum mifare_tag_type" -.Fn freefare_get_tag_type "MifareTag tag" +.Ft "enum freefare_tag_type" +.Fn freefare_get_tag_type "FreefareTag tag" .Ft "const char *" -.Fn freefare_get_tag_friendly_name "MifareTag tag" +.Fn freefare_get_tag_friendly_name "FreefareTag tag" .Ft "char *" -.Fn freefare_get_tag_uid "MifareTag tag" +.Fn freefare_get_tag_uid "FreefareTag tag" .Ft "void" -.Fn freefare_free_tag "MifareTag tags" +.Fn freefare_free_tag "FreefareTag tags" .Ft "void" -.Fn freefare_free_tags "MifareTag *tags" +.Fn freefare_free_tags "FreefareTag *tags" .\" ____ _ _ _ .\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __ .\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \ @@ -77,12 +77,12 @@ enum mifare_tag_type { The .Fn freefare_* family of functions allow agnostic access to the -.Vt MifareTag +.Vt FreefareTag present on a given NFC device. .Pp .Fn freefare_get_tags returns a NULL-terminated list of -.Vt MifareTag +.Vt FreefareTag present on .Vt device . This list has to be freed after usage by either: @@ -108,7 +108,7 @@ It is the programmer's responsibility to free these targets before calling the function. .Pp Information about a given -.Vt MifareTag +.Vt FreefareTag can be gathered using the .Fn freefare_get_tag_type , .Fn freefare_get_tag_uid diff --git a/libfreefare/freefare.c b/libfreefare/freefare.c index c130105..8aaa07a 100644 --- a/libfreefare/freefare.c +++ b/libfreefare/freefare.c @@ -43,14 +43,14 @@ struct supported_tag supported_tags[] = { }; /* - * Automagically allocate a MifareTag given a device and target info. + * Automagically allocate a FreefareTag given a device and target info. */ -MifareTag +FreefareTag freefare_tag_new (nfc_device *device, nfc_iso14443a_info nai) { bool found = false; struct supported_tag *tag_info; - MifareTag tag; + FreefareTag tag; /* Ensure the target is supported */ for (size_t i = 0; i < sizeof (supported_tags) / sizeof (struct supported_tag); i++) { @@ -114,10 +114,10 @@ freefare_tag_new (nfc_device *device, nfc_iso14443a_info nai) * * The list has to be freed using the freefare_free_tags() function. */ -MifareTag * +FreefareTag * freefare_get_tags (nfc_device *device) { - MifareTag *tags = NULL; + FreefareTag *tags = NULL; int tag_count = 0; nfc_initiator_init(device); @@ -148,10 +148,10 @@ freefare_get_tags (nfc_device *device) tags[0] = NULL; for (int c = 0; c < candidates_count; c++) { - MifareTag t; + FreefareTag t; if ((t = freefare_tag_new(device, candidates[c].nti.nai))) { /* (Re)Allocate memory for the found MIFARE targets array */ - MifareTag *p = realloc (tags, (tag_count + 2) * sizeof (MifareTag)); + FreefareTag *p = realloc (tags, (tag_count + 2) * sizeof (FreefareTag)); if (p) tags = p; else @@ -167,8 +167,8 @@ freefare_get_tags (nfc_device *device) /* * Returns the type of the provided tag. */ -enum mifare_tag_type -freefare_get_tag_type (MifareTag tag) +enum freefare_tag_type +freefare_get_tag_type (FreefareTag tag) { return tag->tag_info->type; } @@ -177,7 +177,7 @@ freefare_get_tag_type (MifareTag tag) * Returns the friendly name of the provided tag. */ const char * -freefare_get_tag_friendly_name (MifareTag tag) +freefare_get_tag_friendly_name (FreefareTag tag) { return tag->tag_info->friendly_name; } @@ -186,7 +186,7 @@ freefare_get_tag_friendly_name (MifareTag tag) * Returns the UID of the provided tag. */ char * -freefare_get_tag_uid (MifareTag tag) +freefare_get_tag_uid (FreefareTag tag) { char *res; if ((res = malloc (2 * tag->info.szUidLen + 1))) { @@ -208,7 +208,7 @@ bool freefare_selected_tag_is_present(nfc_device *device) * Free the provided tag. */ void -freefare_free_tag (MifareTag tag) +freefare_free_tag (FreefareTag tag) { if (tag) { switch (tag->tag_info->type) { @@ -228,7 +228,7 @@ freefare_free_tag (MifareTag tag) } const char * -freefare_strerror (MifareTag tag) +freefare_strerror (FreefareTag tag) { const char *p = "Unknown error"; if (nfc_device_get_last_error (tag->device) < 0) { @@ -246,13 +246,13 @@ freefare_strerror (MifareTag tag) } int -freefare_strerror_r (MifareTag tag, char *buffer, size_t len) +freefare_strerror_r (FreefareTag tag, char *buffer, size_t len) { return (snprintf (buffer, len, "%s", freefare_strerror (tag)) < 0) ? -1 : 0; } void -freefare_perror (MifareTag tag, const char *string) +freefare_perror (FreefareTag tag, const char *string) { fprintf (stderr, "%s: %s\n", string, freefare_strerror (tag)); } @@ -261,7 +261,7 @@ freefare_perror (MifareTag tag, const char *string) * Free the provided tag list. */ void -freefare_free_tags (MifareTag *tags) +freefare_free_tags (FreefareTag *tags) { if (tags) { for (int i=0; tags[i]; i++) { diff --git a/libfreefare/freefare.h b/libfreefare/freefare.h index 460ecce..2c35ee9 100644 --- a/libfreefare/freefare.h +++ b/libfreefare/freefare.h @@ -30,7 +30,7 @@ extern "C" { #endif // __cplusplus -enum mifare_tag_type { +enum freefare_tag_type { ULTRALIGHT, ULTRALIGHT_C, // MINI, @@ -43,8 +43,11 @@ enum mifare_tag_type { DESFIRE }; -struct mifare_tag; -typedef struct mifare_tag *MifareTag; +struct freefare_tag; +typedef struct freefare_tag *FreefareTag; + +/* Replace any MifareTag by the generic FreefareTag. */ +typedef struct freefare_tag *MifareTag __attribute__ ((deprecated)); struct mifare_desfire_key; typedef struct mifare_desfire_key *MifareDESFireKey; @@ -52,26 +55,26 @@ typedef struct mifare_desfire_key *MifareDESFireKey; typedef uint8_t MifareUltralightPageNumber; typedef unsigned char MifareUltralightPage[4]; -MifareTag *freefare_get_tags (nfc_device *device); -MifareTag freefare_tag_new (nfc_device *device, nfc_iso14443a_info nai); -enum mifare_tag_type freefare_get_tag_type (MifareTag tag); -const char *freefare_get_tag_friendly_name (MifareTag tag); -char *freefare_get_tag_uid (MifareTag tag); -void freefare_free_tag (MifareTag tag); -void freefare_free_tags (MifareTag *tags); +FreefareTag *freefare_get_tags (nfc_device *device); +FreefareTag freefare_tag_new (nfc_device *device, nfc_iso14443a_info nai); +enum freefare_tag_type freefare_get_tag_type (FreefareTag tag); +const char *freefare_get_tag_friendly_name (FreefareTag tag); +char *freefare_get_tag_uid (FreefareTag tag); +void freefare_free_tag (FreefareTag tag); +void freefare_free_tags (FreefareTag *tags); bool freefare_selected_tag_is_present(nfc_device *device); -const char *freefare_strerror (MifareTag tag); -int freefare_strerror_r (MifareTag tag, char *buffer, size_t len); -void freefare_perror (MifareTag tag, const char *string); +const char *freefare_strerror (FreefareTag tag); +int freefare_strerror_r (FreefareTag tag, char *buffer, size_t len); +void freefare_perror (FreefareTag tag, const char *string); -int mifare_ultralight_connect (MifareTag tag); -int mifare_ultralight_disconnect (MifareTag tag); +int mifare_ultralight_connect (FreefareTag tag); +int mifare_ultralight_disconnect (FreefareTag tag); -int mifare_ultralight_read (MifareTag tag, const MifareUltralightPageNumber page, MifareUltralightPage *data); -int mifare_ultralight_write (MifareTag tag, const MifareUltralightPageNumber page, const MifareUltralightPage data); +int mifare_ultralight_read (FreefareTag tag, const MifareUltralightPageNumber page, MifareUltralightPage *data); +int mifare_ultralight_write (FreefareTag tag, const MifareUltralightPageNumber page, const MifareUltralightPage data); -int mifare_ultralightc_authenticate (MifareTag tag, const MifareDESFireKey key); +int mifare_ultralightc_authenticate (FreefareTag tag, const MifareDESFireKey key); bool is_mifare_ultralightc_on_reader (nfc_device *device, nfc_iso14443a_info nai); typedef unsigned char MifareClassicBlock[16]; @@ -85,24 +88,24 @@ typedef unsigned char MifareClassicKey[6]; /* NFC Forum public key */ extern const MifareClassicKey mifare_classic_nfcforum_public_key_a; -int mifare_classic_connect (MifareTag tag); -int mifare_classic_disconnect (MifareTag tag); +int mifare_classic_connect (FreefareTag tag); +int mifare_classic_disconnect (FreefareTag tag); -int mifare_classic_authenticate (MifareTag tag, const MifareClassicBlockNumber block, const MifareClassicKey key, const MifareClassicKeyType key_type); -int mifare_classic_read (MifareTag tag, const MifareClassicBlockNumber block, MifareClassicBlock *data); -int mifare_classic_init_value (MifareTag tag, const MifareClassicBlockNumber block, const int32_t value, const MifareClassicBlockNumber adr); -int mifare_classic_read_value (MifareTag tag, const MifareClassicBlockNumber block, int32_t *value, MifareClassicBlockNumber *adr); -int mifare_classic_write (MifareTag tag, const MifareClassicBlockNumber block, const MifareClassicBlock data); +int mifare_classic_authenticate (FreefareTag tag, const MifareClassicBlockNumber block, const MifareClassicKey key, const MifareClassicKeyType key_type); +int mifare_classic_read (FreefareTag tag, const MifareClassicBlockNumber block, MifareClassicBlock *data); +int mifare_classic_init_value (FreefareTag tag, const MifareClassicBlockNumber block, const int32_t value, const MifareClassicBlockNumber adr); +int mifare_classic_read_value (FreefareTag tag, const MifareClassicBlockNumber block, int32_t *value, MifareClassicBlockNumber *adr); +int mifare_classic_write (FreefareTag tag, const MifareClassicBlockNumber block, const MifareClassicBlock data); -int mifare_classic_increment (MifareTag tag, const MifareClassicBlockNumber block, const uint32_t amount); -int mifare_classic_decrement (MifareTag tag, const MifareClassicBlockNumber block, const uint32_t amount); -int mifare_classic_restore (MifareTag tag, const MifareClassicBlockNumber block); -int mifare_classic_transfer (MifareTag tag, const MifareClassicBlockNumber block); +int mifare_classic_increment (FreefareTag tag, const MifareClassicBlockNumber block, const uint32_t amount); +int mifare_classic_decrement (FreefareTag tag, const MifareClassicBlockNumber block, const uint32_t amount); +int mifare_classic_restore (FreefareTag tag, const MifareClassicBlockNumber block); +int mifare_classic_transfer (FreefareTag tag, const MifareClassicBlockNumber block); -int mifare_classic_get_trailer_block_permission (MifareTag tag, const MifareClassicBlockNumber block, const uint16_t permission, const MifareClassicKeyType key_type); -int mifare_classic_get_data_block_permission (MifareTag tag, const MifareClassicBlockNumber block, const unsigned char permission, const MifareClassicKeyType key_type); +int mifare_classic_get_trailer_block_permission (FreefareTag tag, const MifareClassicBlockNumber block, const uint16_t permission, const MifareClassicKeyType key_type); +int mifare_classic_get_data_block_permission (FreefareTag tag, const MifareClassicBlockNumber block, const unsigned char permission, const MifareClassicKeyType key_type); -int mifare_classic_format_sector (MifareTag tag, const MifareClassicSectorNumber sector); +int mifare_classic_format_sector (FreefareTag tag, const MifareClassicSectorNumber sector); void mifare_classic_trailer_block (MifareClassicBlock *block, const MifareClassicKey key_a, uint8_t ab_0, uint8_t ab_1, uint8_t ab_2, uint8_t ab_tb, const uint8_t gpb, const MifareClassicKey key_b); @@ -157,8 +160,8 @@ extern const MadAid mad_not_applicable_aid; extern const MadAid mad_nfcforum_aid; Mad mad_new (const uint8_t version); -Mad mad_read (MifareTag tag); -int mad_write (MifareTag tag, Mad mad, const MifareClassicKey key_b_sector_00, const MifareClassicKey key_b_sector_10); +Mad mad_read (FreefareTag tag); +int mad_write (FreefareTag tag, Mad mad, const MifareClassicKey key_b_sector_00, const MifareClassicKey key_b_sector_10); int mad_get_version (Mad mad); void mad_set_version (Mad mad, const uint8_t version); MifareClassicSectorNumber mad_get_card_publisher_sector (Mad mad); @@ -169,8 +172,8 @@ bool mad_sector_reserved (const MifareClassicSectorNumber sector); void mad_free (Mad mad); MifareClassicSectorNumber *mifare_application_alloc (Mad mad, const MadAid aid, const size_t size); -ssize_t mifare_application_read (MifareTag tag, Mad mad, const MadAid aid, void *buf, size_t nbytes, const MifareClassicKey key, const MifareClassicKeyType key_type); -ssize_t mifare_application_write (MifareTag tag, Mad mad, const MadAid aid, const void *buf, size_t nbytes, const MifareClassicKey key, const MifareClassicKeyType key_type); +ssize_t mifare_application_read (FreefareTag tag, Mad mad, const MadAid aid, void *buf, size_t nbytes, const MifareClassicKey key, const MifareClassicKeyType key_type); +ssize_t mifare_application_write (FreefareTag tag, Mad mad, const MadAid aid, const void *buf, size_t nbytes, const MifareClassicKey key, const MifareClassicKeyType key_type); int mifare_application_free (Mad mad, const MadAid aid); MifareClassicSectorNumber *mifare_application_find (Mad mad, const MadAid aid); @@ -271,8 +274,8 @@ MifareDESFireAID mifare_desfire_aid_new (uint32_t aid); MifareDESFireAID mifare_desfire_aid_new_with_mad_aid (MadAid mad_aid, uint8_t n); uint32_t mifare_desfire_aid_get_aid (MifareDESFireAID aid); -uint8_t mifare_desfire_last_pcd_error (MifareTag tag); -uint8_t mifare_desfire_last_picc_error (MifareTag tag); +uint8_t mifare_desfire_last_pcd_error (FreefareTag tag); +uint8_t mifare_desfire_last_picc_error (FreefareTag tag); #pragma pack (push) #pragma pack (1) @@ -324,70 +327,70 @@ struct mifare_desfire_file_settings { } settings; }; -int mifare_desfire_connect (MifareTag tag); -int mifare_desfire_disconnect (MifareTag tag); +int mifare_desfire_connect (FreefareTag tag); +int mifare_desfire_disconnect (FreefareTag tag); -int mifare_desfire_authenticate (MifareTag tag, uint8_t key_no, MifareDESFireKey key); -int mifare_desfire_authenticate_iso (MifareTag tag, uint8_t key_no, MifareDESFireKey key); -int mifare_desfire_authenticate_aes (MifareTag tag, uint8_t key_no, MifareDESFireKey key); -int mifare_desfire_change_key_settings (MifareTag tag, uint8_t settings); -int mifare_desfire_get_key_settings (MifareTag tag, uint8_t *settings, uint8_t *max_keys); -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_authenticate (FreefareTag tag, uint8_t key_no, MifareDESFireKey key); +int mifare_desfire_authenticate_iso (FreefareTag tag, uint8_t key_no, MifareDESFireKey key); +int mifare_desfire_authenticate_aes (FreefareTag tag, uint8_t key_no, MifareDESFireKey key); +int mifare_desfire_change_key_settings (FreefareTag tag, uint8_t settings); +int mifare_desfire_get_key_settings (FreefareTag tag, uint8_t *settings, uint8_t *max_keys); +int mifare_desfire_change_key (FreefareTag tag, uint8_t key_no, MifareDESFireKey new_key, MifareDESFireKey old_key); +int mifare_desfire_get_key_version (FreefareTag tag, uint8_t key_no, uint8_t *version); +int mifare_desfire_create_application (FreefareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no); +int mifare_desfire_create_application_3k3des (FreefareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no); +int mifare_desfire_create_application_aes (FreefareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no); -int mifare_desfire_create_application_iso (MifareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no, int want_iso_file_identifiers, uint16_t iso_file_id, uint8_t *iso_file_name, size_t iso_file_name_len); -int mifare_desfire_create_application_3k3des_iso (MifareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no, int want_iso_file_identifiers, uint16_t iso_file_id, uint8_t *iso_file_name, size_t iso_file_name_len); -int mifare_desfire_create_application_aes_iso (MifareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no, int want_iso_file_identifiers, uint16_t iso_file_id, uint8_t *iso_file_name, size_t iso_file_name_len); +int mifare_desfire_create_application_iso (FreefareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no, int want_iso_file_identifiers, uint16_t iso_file_id, uint8_t *iso_file_name, size_t iso_file_name_len); +int mifare_desfire_create_application_3k3des_iso (FreefareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no, int want_iso_file_identifiers, uint16_t iso_file_id, uint8_t *iso_file_name, size_t iso_file_name_len); +int mifare_desfire_create_application_aes_iso (FreefareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no, int want_iso_file_identifiers, uint16_t iso_file_id, uint8_t *iso_file_name, size_t iso_file_name_len); -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_df_names (MifareTag tag, MifareDESFireDF *dfs[], size_t *count); +int mifare_desfire_delete_application (FreefareTag tag, MifareDESFireAID aid); +int mifare_desfire_get_application_ids (FreefareTag tag, MifareDESFireAID *aids[], size_t *count); +int mifare_desfire_get_df_names (FreefareTag tag, MifareDESFireDF *dfs[], size_t *count); void mifare_desfire_free_application_ids (MifareDESFireAID aids[]); -int mifare_desfire_select_application (MifareTag tag, MifareDESFireAID aid); -int mifare_desfire_format_picc (MifareTag tag); -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_set_configuration (MifareTag tag, bool disable_format, bool enable_random_uid); -int mifare_desfire_set_default_key (MifareTag tag, MifareDESFireKey key); -int mifare_desfire_set_ats (MifareTag tag, uint8_t *ats); -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_iso_file_ids (MifareTag tag, uint16_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_change_file_settings (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights); -int mifare_desfire_create_std_data_file (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size); -int mifare_desfire_create_std_data_file_iso (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size, uint16_t iso_file_id); -int mifare_desfire_create_backup_data_file (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size); -int mifare_desfire_create_backup_data_file_iso (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size, uint16_t iso_file_id); -int mifare_desfire_create_value_file (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, int32_t lower_limit, int32_t upper_limit, int32_t value, uint8_t limited_credit_enable); -int mifare_desfire_create_linear_record_file (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records); -int mifare_desfire_create_linear_record_file_iso (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records, uint16_t iso_file_id); -int mifare_desfire_create_cyclic_record_file (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records); -int mifare_desfire_create_cyclic_record_file_iso (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records, uint16_t iso_file_id); -int mifare_desfire_delete_file (MifareTag tag, uint8_t file_no); +int mifare_desfire_select_application (FreefareTag tag, MifareDESFireAID aid); +int mifare_desfire_format_picc (FreefareTag tag); +int mifare_desfire_get_version (FreefareTag tag, struct mifare_desfire_version_info *version_info); +int mifare_desfire_free_mem (FreefareTag tag, uint32_t *size); +int mifare_desfire_set_configuration (FreefareTag tag, bool disable_format, bool enable_random_uid); +int mifare_desfire_set_default_key (FreefareTag tag, MifareDESFireKey key); +int mifare_desfire_set_ats (FreefareTag tag, uint8_t *ats); +int mifare_desfire_get_card_uid (FreefareTag tag, char **uid); +int mifare_desfire_get_file_ids (FreefareTag tag, uint8_t **files, size_t *count); +int mifare_desfire_get_iso_file_ids (FreefareTag tag, uint16_t **files, size_t *count); +int mifare_desfire_get_file_settings (FreefareTag tag, uint8_t file_no, struct mifare_desfire_file_settings *settings); +int mifare_desfire_change_file_settings (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights); +int mifare_desfire_create_std_data_file (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size); +int mifare_desfire_create_std_data_file_iso (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size, uint16_t iso_file_id); +int mifare_desfire_create_backup_data_file (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size); +int mifare_desfire_create_backup_data_file_iso (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size, uint16_t iso_file_id); +int mifare_desfire_create_value_file (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, int32_t lower_limit, int32_t upper_limit, int32_t value, uint8_t limited_credit_enable); +int mifare_desfire_create_linear_record_file (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records); +int mifare_desfire_create_linear_record_file_iso (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records, uint16_t iso_file_id); +int mifare_desfire_create_cyclic_record_file (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records); +int mifare_desfire_create_cyclic_record_file_iso (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records, uint16_t iso_file_id); +int mifare_desfire_delete_file (FreefareTag tag, uint8_t file_no); -ssize_t mifare_desfire_read_data (MifareTag tag, uint8_t file_no, off_t offset, size_t length, void *data); -ssize_t mifare_desfire_read_data_ex (MifareTag tag, uint8_t file_no, off_t offset, size_t length, void *data, int cs); -ssize_t mifare_desfire_write_data (MifareTag tag, uint8_t file_no, off_t offset, size_t length, const void *data); -ssize_t mifare_desfire_write_data_ex (MifareTag tag, uint8_t file_no, off_t offset, size_t length, const void *data, int cs); -int mifare_desfire_get_value (MifareTag tag, uint8_t file_no, int32_t *value); -int mifare_desfire_get_value_ex (MifareTag tag, uint8_t file_no, int32_t *value, int cs); -int mifare_desfire_credit (MifareTag tag, uint8_t file_no, int32_t amount); -int mifare_desfire_credit_ex (MifareTag tag, uint8_t file_no, int32_t amount, int cs); -int mifare_desfire_debit (MifareTag tag, uint8_t file_no, int32_t amount); -int mifare_desfire_debit_ex (MifareTag tag, uint8_t file_no, int32_t amount, int cs); -int mifare_desfire_limited_credit (MifareTag tag, uint8_t file_no, int32_t amount); -int mifare_desfire_limited_credit_ex (MifareTag tag, uint8_t file_no, int32_t amount, int cs); -ssize_t mifare_desfire_write_record (MifareTag tag, uint8_t file_no, off_t offset, size_t length, void *data); -ssize_t mifare_desfire_write_record_ex (MifareTag tag, uint8_t file_no, off_t offset, size_t length, void *data, int cs); -ssize_t mifare_desfire_read_records (MifareTag tag, uint8_t file_no, off_t offset, size_t length, void *data); -ssize_t mifare_desfire_read_records_ex (MifareTag tag, uint8_t file_no, off_t offset, size_t length, void *data, int cs); -int mifare_desfire_clear_record_file (MifareTag tag, uint8_t file_no); -int mifare_desfire_commit_transaction (MifareTag tag); -int mifare_desfire_abort_transaction (MifareTag tag); +ssize_t mifare_desfire_read_data (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, void *data); +ssize_t mifare_desfire_read_data_ex (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, void *data, int cs); +ssize_t mifare_desfire_write_data (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, const void *data); +ssize_t mifare_desfire_write_data_ex (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, const void *data, int cs); +int mifare_desfire_get_value (FreefareTag tag, uint8_t file_no, int32_t *value); +int mifare_desfire_get_value_ex (FreefareTag tag, uint8_t file_no, int32_t *value, int cs); +int mifare_desfire_credit (FreefareTag tag, uint8_t file_no, int32_t amount); +int mifare_desfire_credit_ex (FreefareTag tag, uint8_t file_no, int32_t amount, int cs); +int mifare_desfire_debit (FreefareTag tag, uint8_t file_no, int32_t amount); +int mifare_desfire_debit_ex (FreefareTag tag, uint8_t file_no, int32_t amount, int cs); +int mifare_desfire_limited_credit (FreefareTag tag, uint8_t file_no, int32_t amount); +int mifare_desfire_limited_credit_ex (FreefareTag tag, uint8_t file_no, int32_t amount, int cs); +ssize_t mifare_desfire_write_record (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, void *data); +ssize_t mifare_desfire_write_record_ex (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, void *data, int cs); +ssize_t mifare_desfire_read_records (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, void *data); +ssize_t mifare_desfire_read_records_ex (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, void *data, int cs); +int mifare_desfire_clear_record_file (FreefareTag tag, uint8_t file_no); +int mifare_desfire_commit_transaction (FreefareTag tag); +int mifare_desfire_abort_transaction (FreefareTag tag); MifareDESFireKey mifare_desfire_des_key_new (const uint8_t value[8]); MifareDESFireKey mifare_desfire_3des_key_new (const uint8_t value[16]); diff --git a/libfreefare/freefare_error.3 b/libfreefare/freefare_error.3 index 816152b..4712aa2 100644 --- a/libfreefare/freefare_error.3 +++ b/libfreefare/freefare_error.3 @@ -47,15 +47,15 @@ Mifare card manipulation library (libfreefare, \-lfreefare) .Sh SYNOPSIS .In freefare.h .Ft "const char *" -.Fn freefare_strerror "MifareTag tag" +.Fn freefare_strerror "FreefareTag tag" .Ft "int" -.Fn freefare_strerror_r "MifareTag tag" "char *buffer" "size_t len" +.Fn freefare_strerror_r "FreefareTag tag" "char *buffer" "size_t len" .Ft "void" -.Fn freefare_strerror "MifareTag tag" "char *string" +.Fn freefare_strerror "FreefareTag tag" "char *string" .Ft "uint8_t" -.Fn mifare_desfire_last_pcd_error "MifareTag tag" +.Fn mifare_desfire_last_pcd_error "FreefareTag tag" .Ft "uint8_t" -.Fn mifare_desfire_last_picc_error "MifareTag tag" +.Fn mifare_desfire_last_picc_error "FreefareTag tag" .\" ____ _ _ _ .\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __ .\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \ diff --git a/libfreefare/freefare_internal.h b/libfreefare/freefare_internal.h index 77cb1fd..9e4d15a 100644 --- a/libfreefare/freefare_internal.h +++ b/libfreefare/freefare_internal.h @@ -104,12 +104,12 @@ struct mad_sector_0x00; struct mad_sector_0x10; void nxp_crc (uint8_t *crc, const uint8_t value); -MifareTag mifare_classic_tag_new (void); -void mifare_classic_tag_free (MifareTag tag); -MifareTag mifare_desfire_tag_new (void); -void mifare_desfire_tag_free (MifareTag tags); -MifareTag mifare_ultralight_tag_new (void); -void mifare_ultralight_tag_free (MifareTag tag); +FreefareTag mifare_classic_tag_new (void); +void mifare_classic_tag_free (FreefareTag tag); +FreefareTag mifare_desfire_tag_new (void); +void mifare_desfire_tag_free (FreefareTag tags); +FreefareTag mifare_ultralight_tag_new (void); +void mifare_ultralight_tag_free (FreefareTag tag); uint8_t sector_0x00_crc8 (Mad mad); uint8_t sector_0x10_crc8 (Mad mad); @@ -143,21 +143,21 @@ typedef enum { #define MAC_MASK 0x0F0 #define CMAC_MACK 0xF00 -void *mifare_cryto_preprocess_data (MifareTag tag, void *data, size_t *nbytes, off_t offset, int communication_settings); -void *mifare_cryto_postprocess_data (MifareTag tag, void *data, ssize_t *nbytes, int communication_settings); +void *mifare_cryto_preprocess_data (FreefareTag tag, void *data, size_t *nbytes, off_t offset, int communication_settings); +void *mifare_cryto_postprocess_data (FreefareTag tag, void *data, ssize_t *nbytes, int communication_settings); void mifare_cypher_single_block (MifareDESFireKey key, uint8_t *data, uint8_t *ivect, MifareCryptoDirection direction, MifareCryptoOperation operation, size_t block_size); -void mifare_cypher_blocks_chained (MifareTag tag, MifareDESFireKey key, uint8_t *ivect, uint8_t *data, size_t data_size, MifareCryptoDirection direction, MifareCryptoOperation operation); +void mifare_cypher_blocks_chained (FreefareTag tag, MifareDESFireKey key, uint8_t *ivect, uint8_t *data, size_t data_size, MifareCryptoDirection direction, MifareCryptoOperation operation); void rol (uint8_t *data, const size_t len); void desfire_crc32 (const uint8_t *data, const size_t len, uint8_t *crc); void desfire_crc32_append (uint8_t *data, const size_t len); size_t key_block_size (const MifareDESFireKey key); size_t padded_data_length (const size_t nbytes, const size_t block_size); size_t maced_data_length (const MifareDESFireKey key, const size_t nbytes); -size_t enciphered_data_length (const MifareTag tag, const size_t nbytes, int communication_settings); +size_t enciphered_data_length (const FreefareTag tag, const size_t nbytes, int communication_settings); void cmac_generate_subkeys (MifareDESFireKey key); void cmac (const MifareDESFireKey key, uint8_t *ivect, const uint8_t *data, size_t len, uint8_t *cmac); -void *assert_crypto_buffer_size (MifareTag tag, size_t nbytes); +void *assert_crypto_buffer_size (FreefareTag tag, size_t nbytes); #define MIFARE_ULTRALIGHT_PAGE_COUNT 0x10 #define MIFARE_ULTRALIGHT_C_PAGE_COUNT 0x30 @@ -166,7 +166,7 @@ void *assert_crypto_buffer_size (MifareTag tag, size_t nbytes); #define MIFARE_ULTRALIGHT_MAX_PAGE_COUNT 0x30 struct supported_tag { - enum mifare_tag_type type; + enum freefare_tag_type type; const char *friendly_name; uint8_t SAK; uint8_t ATS_min_length; @@ -183,7 +183,7 @@ struct supported_tag { * Extra members in derived classes are initialized in the correpsonding * mifare_*_connect() function. */ -struct mifare_tag { +struct freefare_tag { nfc_device *device; nfc_iso14443a_info info; const struct supported_tag *tag_info; @@ -191,7 +191,7 @@ struct mifare_tag { }; struct mifare_classic_tag { - struct mifare_tag __tag; + struct freefare_tag __tag; MifareClassicKeyType last_authentication_key_type; @@ -228,7 +228,7 @@ struct mifare_desfire_key { }; struct mifare_desfire_tag { - struct mifare_tag __tag; + struct freefare_tag __tag; uint8_t last_picc_error; uint8_t last_internal_error; @@ -247,7 +247,7 @@ MifareDESFireKey mifare_desfire_session_key_new (const uint8_t rnda[], const uin const char *mifare_desfire_error_lookup (uint8_t error); struct mifare_ultralight_tag { - struct mifare_tag __tag; + struct freefare_tag __tag; /* mifare_ultralight_read() reads 4 pages at a time (wrapping) */ MifareUltralightPage cache[MIFARE_ULTRALIGHT_MAX_PAGE_COUNT + 3]; @@ -255,7 +255,7 @@ struct mifare_ultralight_tag { }; /* - * MifareTag assertion macros + * FreefareTag assertion macros * * This macros provide a simple and unified way to perform various tests at the * beginning of the different targets functions. @@ -270,10 +270,10 @@ struct mifare_ultralight_tag { #define ASSERT_MIFARE_ULTRALIGHT_C(tag) do { if (! IS_MIFARE_ULTRALIGHT_C(tag)) return errno = ENODEV, -1; } while (0) /* - * MifareTag cast macros + * FreefareTag cast macros * * This macros are intended to provide a convenient way to cast abstract - * MifareTag structures to concrete Tags (e.g. MIFARE Classic tag). + * FreefareTag structures to concrete Tags (e.g. MIFARE Classic tag). */ #define MIFARE_CLASSIC(tag) ((struct mifare_classic_tag *) tag) #define MIFARE_DESFIRE(tag) ((struct mifare_desfire_tag *) tag) diff --git a/libfreefare/mad.3 b/libfreefare/mad.3 index 882484d..98e5a3a 100644 --- a/libfreefare/mad.3 +++ b/libfreefare/mad.3 @@ -55,9 +55,9 @@ Mifare card manipulation library (libfreefare, \-lfreefare) .Ft "Mad" .Fn mad_new "uint8_t version" .Ft "Mad" -.Fn mad_read "MifareTag tag" +.Fn mad_read "FreefareTag tag" .Ft "int" -.Fn mad_write "MifareTag tag" "Mad mad" "MifareClassicKey key_b_sector_00" "MifareClassicKey key_b_sector_10" +.Fn mad_write "FreefareTag tag" "Mad mad" "MifareClassicKey key_b_sector_00" "MifareClassicKey key_b_sector_10" .Ft "int" .Fn mad_get_version "Mad mad" .Ft "void" diff --git a/libfreefare/mad.c b/libfreefare/mad.c index c547650..c3f7220 100644 --- a/libfreefare/mad.c +++ b/libfreefare/mad.c @@ -176,7 +176,7 @@ sector_0x10_crc8 (Mad mad) * Read a MAD from the provided MIFARE tag. */ Mad -mad_read (MifareTag tag) +mad_read (FreefareTag tag) { Mad mad = malloc (sizeof (*mad)); @@ -275,7 +275,7 @@ error: * Write the mad to the provided MIFARE tad using the provided Key-B keys. */ int -mad_write (MifareTag tag, Mad mad, const MifareClassicKey key_b_sector_00, const MifareClassicKey key_b_sector_10) +mad_write (FreefareTag tag, Mad mad, const MifareClassicKey key_b_sector_00, const MifareClassicKey key_b_sector_10) { MifareClassicBlock data; diff --git a/libfreefare/mifare_application.3 b/libfreefare/mifare_application.3 index 5e0055f..7aa27e8 100644 --- a/libfreefare/mifare_application.3 +++ b/libfreefare/mifare_application.3 @@ -54,9 +54,9 @@ Mifare card manipulation library (libfreefare, \-lfreefare) .Ft "MifareClassicSectorNumber *" .Fn mifare_application_find "Mad mad" "MadAid aid" .Ft "ssize_t" -.Fn mifare_application_read "MifareTag tag" "Mad mad" "MadAid aid" "void *buf" "size_t nbytes" "MifareClassicKey key" "MifareClassicKeyType key_type" +.Fn mifare_application_read "FreefareTag tag" "Mad mad" "MadAid aid" "void *buf" "size_t nbytes" "MifareClassicKey key" "MifareClassicKeyType key_type" .Ft "ssize_t" -.Fn mifare_application_write "MifareTag tag" "Mad mad" "MadAid aid" "const void *buf" "size_t nbytes" "MifareClassicKey key" "MifareClassicKeyType key_type" +.Fn mifare_application_write "FreefareTag tag" "Mad mad" "MadAid aid" "const void *buf" "size_t nbytes" "MifareClassicKey key" "MifareClassicKeyType key_type" .\" ____ _ _ _ .\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __ .\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \ diff --git a/libfreefare/mifare_application.c b/libfreefare/mifare_application.c index f41c726..db15866 100644 --- a/libfreefare/mifare_application.c +++ b/libfreefare/mifare_application.c @@ -213,7 +213,7 @@ mifare_application_find (Mad mad, MadAid aid) } ssize_t -mifare_application_read (MifareTag tag, Mad mad, const MadAid aid, void *buf, size_t nbytes, const MifareClassicKey key, const MifareClassicKeyType key_type) +mifare_application_read (FreefareTag tag, Mad mad, const MadAid aid, void *buf, size_t nbytes, const MifareClassicKey key, const MifareClassicKeyType key_type) { ssize_t res = 0; @@ -258,7 +258,7 @@ mifare_application_read (MifareTag tag, Mad mad, const MadAid aid, void *buf, si } ssize_t -mifare_application_write (MifareTag tag, Mad mad, const MadAid aid, const void *buf, size_t nbytes, const MifareClassicKey key, const MifareClassicKeyType key_type) +mifare_application_write (FreefareTag tag, Mad mad, const MadAid aid, const void *buf, size_t nbytes, const MifareClassicKey key, const MifareClassicKeyType key_type) { ssize_t res = 0; diff --git a/libfreefare/mifare_classic.3 b/libfreefare/mifare_classic.3 index 71b903a..34efe42 100644 --- a/libfreefare/mifare_classic.3 +++ b/libfreefare/mifare_classic.3 @@ -62,33 +62,33 @@ Mifare card manipulation library (libfreefare, \-lfreefare) .Sh SYNOPSIS .In freefare.h .Ft int -.Fn mifare_classic_connect "MifareTag tag" +.Fn mifare_classic_connect "FreefareTag tag" .Ft int -.Fn mifare_classic_disconnect "MifareTag tag" +.Fn mifare_classic_disconnect "FreefareTag tag" .Ft int -.Fn mifare_classic_authenticate "MifareTag tag" "const MifareClassicBlockNumber block" "const MifareClassicKey key" "const MifareClassicKeyType key_type" +.Fn mifare_classic_authenticate "FreefareTag tag" "const MifareClassicBlockNumber block" "const MifareClassicKey key" "const MifareClassicKeyType key_type" .Ft int -.Fn mifare_classic_read "MifareTag tag" "const MifareClassicBlockNumber block" "MifareClassicBlock *data" +.Fn mifare_classic_read "FreefareTag tag" "const MifareClassicBlockNumber block" "MifareClassicBlock *data" .Ft int -.Fn mifare_classic_init_value "MifareTag tag" "const MifareClassicBlockNumber block" "const int32_t value" "const MifareClassicBlockNumber adr" +.Fn mifare_classic_init_value "FreefareTag tag" "const MifareClassicBlockNumber block" "const int32_t value" "const MifareClassicBlockNumber adr" .Ft int -.Fn mifare_classic_read_value "MifareTag tag" "const MifareClassicBlockNumber block" "int32_t *value" "MifareClassicBlockNumber *adr" +.Fn mifare_classic_read_value "FreefareTag tag" "const MifareClassicBlockNumber block" "int32_t *value" "MifareClassicBlockNumber *adr" .Ft int -.Fn mifare_classic_write "MifareTag tag" "const MifareClassicBlockNumber block" "const MifareClassicBlock data" +.Fn mifare_classic_write "FreefareTag tag" "const MifareClassicBlockNumber block" "const MifareClassicBlock data" .Ft int -.Fn mifare_classic_increment "MifareTag tag" "const MifareClassicBlockNumber block" "const uint32_t amount" +.Fn mifare_classic_increment "FreefareTag tag" "const MifareClassicBlockNumber block" "const uint32_t amount" .Ft int -.Fn mifare_classic_decrement "MifareTag tag" "const MifareClassicBlockNumber block" "const uint32_t amount" +.Fn mifare_classic_decrement "FreefareTag tag" "const MifareClassicBlockNumber block" "const uint32_t amount" .Ft int -.Fn mifare_classic_restore "MifareTag tag" "const MifareClassicBlockNumber block" +.Fn mifare_classic_restore "FreefareTag tag" "const MifareClassicBlockNumber block" .Ft int -.Fn mifare_classic_transfer "MifareTag tag" "const MifareClassicBlockNumber block" +.Fn mifare_classic_transfer "FreefareTag tag" "const MifareClassicBlockNumber block" .Ft int -.Fn mifare_classic_get_trailer_block_permission "MifareTag tag" "const MifareClassicBlockNumber block" "const uint16_t permission" "const MifareClassicKeyType key_type" +.Fn mifare_classic_get_trailer_block_permission "FreefareTag tag" "const MifareClassicBlockNumber block" "const uint16_t permission" "const MifareClassicKeyType key_type" .Ft int -.Fn mifare_classic_get_data_block_permission "MifareTag tag" "const MifareClassicBlockNumber block" "const unsigned char permission" "const MifareClassicKeyType key_type" +.Fn mifare_classic_get_data_block_permission "FreefareTag tag" "const MifareClassicBlockNumber block" "const unsigned char permission" "const MifareClassicKeyType key_type" .Ft int -.Fn mifare_classic_format_sector "MifareTag tag" "const MifareClassicSectorNumber sector" +.Fn mifare_classic_format_sector "FreefareTag tag" "const MifareClassicSectorNumber sector" .Ft void .Fn mifare_classic_trailer_block "MifareClassicBlock *block" "const MifareClassicKey key_a" "const uint8_t ab_0" "const uint8_t ab_1" "const uint8_t ab_2" "const uint8_t ab_tb" "const uint8_t gpb" "const MifareClassicKey key_b" .Ft MifareClassicSectorNumber diff --git a/libfreefare/mifare_classic.c b/libfreefare/mifare_classic.c index 5a60273..6ce6e37 100644 --- a/libfreefare/mifare_classic.c +++ b/libfreefare/mifare_classic.c @@ -188,7 +188,7 @@ uint16_t mifare_trailer_access_permissions[] = { */ int get_block_access_bits_shift (MifareClassicBlockNumber block, MifareClassicBlockNumber trailer); -int get_block_access_bits (MifareTag tag, const MifareClassicBlockNumber block, MifareClassicAccessBits *block_access_bits); +int get_block_access_bits (FreefareTag tag, const MifareClassicBlockNumber block, MifareClassicAccessBits *block_access_bits); /* @@ -199,7 +199,7 @@ int get_block_access_bits (MifareTag tag, const MifareClassicBlockNumber block * Allocates and initialize a MIFARE Classic tag. */ -MifareTag +FreefareTag mifare_classic_tag_new (void) { return malloc (sizeof (struct mifare_classic_tag)); @@ -209,7 +209,7 @@ mifare_classic_tag_new (void) * Free the provided tag. */ void -mifare_classic_tag_free (MifareTag tag) +mifare_classic_tag_free (FreefareTag tag) { free (tag); } @@ -227,7 +227,7 @@ mifare_classic_tag_free (MifareTag tag) * Establish connection to the provided tag. */ int -mifare_classic_connect (MifareTag tag) +mifare_classic_connect (FreefareTag tag) { ASSERT_INACTIVE (tag); ASSERT_MIFARE_CLASSIC (tag); @@ -250,7 +250,7 @@ mifare_classic_connect (MifareTag tag) * Terminate connection with the provided tag. */ int -mifare_classic_disconnect (MifareTag tag) +mifare_classic_disconnect (FreefareTag tag) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_CLASSIC (tag); @@ -276,7 +276,7 @@ mifare_classic_disconnect (MifareTag tag) * Send an authentification command to the provided MIFARE target. */ int -mifare_classic_authenticate (MifareTag tag, const MifareClassicBlockNumber block, const MifareClassicKey key, const MifareClassicKeyType key_type) +mifare_classic_authenticate (FreefareTag tag, const MifareClassicBlockNumber block, const MifareClassicKey key, const MifareClassicKeyType key_type) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_CLASSIC (tag); @@ -307,7 +307,7 @@ mifare_classic_authenticate (MifareTag tag, const MifareClassicBlockNumber block * Read data from the provided MIFARE target. */ int -mifare_classic_read (MifareTag tag, const MifareClassicBlockNumber block, MifareClassicBlock *data) +mifare_classic_read (FreefareTag tag, const MifareClassicBlockNumber block, MifareClassicBlock *data) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_CLASSIC (tag); @@ -324,7 +324,7 @@ mifare_classic_read (MifareTag tag, const MifareClassicBlockNumber block, Mifare } int -mifare_classic_init_value (MifareTag tag, const MifareClassicBlockNumber block, const int32_t value, const MifareClassicBlockNumber adr) +mifare_classic_init_value (FreefareTag tag, const MifareClassicBlockNumber block, const int32_t value, const MifareClassicBlockNumber adr) { union mifare_classic_block b; @@ -346,7 +346,7 @@ mifare_classic_init_value (MifareTag tag, const MifareClassicBlockNumber block, } int -mifare_classic_read_value (MifareTag tag, const MifareClassicBlockNumber block, int32_t *value, MifareClassicBlockNumber *adr) +mifare_classic_read_value (FreefareTag tag, const MifareClassicBlockNumber block, int32_t *value, MifareClassicBlockNumber *adr) { union mifare_classic_block b; @@ -376,7 +376,7 @@ mifare_classic_read_value (MifareTag tag, const MifareClassicBlockNumber block, * Write data to the provided MIFARE target. */ int -mifare_classic_write (MifareTag tag, const MifareClassicBlockNumber block, const MifareClassicBlock data) +mifare_classic_write (FreefareTag tag, const MifareClassicBlockNumber block, const MifareClassicBlock data) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_CLASSIC (tag); @@ -398,7 +398,7 @@ mifare_classic_write (MifareTag tag, const MifareClassicBlockNumber block, const * data register. */ int -mifare_classic_increment (MifareTag tag, const MifareClassicBlockNumber block, const uint32_t amount) +mifare_classic_increment (FreefareTag tag, const MifareClassicBlockNumber block, const uint32_t amount) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_CLASSIC (tag); @@ -420,7 +420,7 @@ mifare_classic_increment (MifareTag tag, const MifareClassicBlockNumber block, c * data register. */ int -mifare_classic_decrement (MifareTag tag, const MifareClassicBlockNumber block, const uint32_t amount) +mifare_classic_decrement (FreefareTag tag, const MifareClassicBlockNumber block, const uint32_t amount) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_CLASSIC (tag); @@ -441,7 +441,7 @@ mifare_classic_decrement (MifareTag tag, const MifareClassicBlockNumber block, c * Store the provided block to the internal data register. */ int -mifare_classic_restore (MifareTag tag, const MifareClassicBlockNumber block) +mifare_classic_restore (FreefareTag tag, const MifareClassicBlockNumber block) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_CLASSIC (tag); @@ -470,7 +470,7 @@ mifare_classic_restore (MifareTag tag, const MifareClassicBlockNumber block) * Store the internal data register to the provided block. */ int -mifare_classic_transfer (MifareTag tag, const MifareClassicBlockNumber block) +mifare_classic_transfer (FreefareTag tag, const MifareClassicBlockNumber block) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_CLASSIC (tag); @@ -539,7 +539,7 @@ get_block_access_bits_shift (MifareClassicBlockNumber block, MifareClassicBlockN * block. */ int -get_block_access_bits (MifareTag tag, const MifareClassicBlockNumber block, MifareClassicAccessBits *block_access_bits) +get_block_access_bits (FreefareTag tag, const MifareClassicBlockNumber block, MifareClassicAccessBits *block_access_bits) { /* * The first block which holds the manufacturer block seems to have @@ -620,7 +620,7 @@ get_block_access_bits (MifareTag tag, const MifareClassicBlockNumber block, Mifa * Get information about the trailer block. */ int -mifare_classic_get_trailer_block_permission (MifareTag tag, const MifareClassicBlockNumber block, const uint16_t permission, const MifareClassicKeyType key_type) +mifare_classic_get_trailer_block_permission (FreefareTag tag, const MifareClassicBlockNumber block, const uint16_t permission, const MifareClassicKeyType key_type) { MifareClassicAccessBits access_bits; if (get_block_access_bits (tag, block, &access_bits) < 0) { @@ -639,7 +639,7 @@ mifare_classic_get_trailer_block_permission (MifareTag tag, const MifareClassicB * Get information about data blocks. */ int -mifare_classic_get_data_block_permission (MifareTag tag, const MifareClassicBlockNumber block, const unsigned char permission, const MifareClassicKeyType key_type) +mifare_classic_get_data_block_permission (FreefareTag tag, const MifareClassicBlockNumber block, const unsigned char permission, const MifareClassicKeyType key_type) { MifareClassicAccessBits access_bits; if (get_block_access_bits (tag, block, &access_bits) < 0) { @@ -663,7 +663,7 @@ mifare_classic_get_data_block_permission (MifareTag tag, const MifareClassicBloc * Reset a MIFARE target sector to factory default. */ int -mifare_classic_format_sector (MifareTag tag, const MifareClassicSectorNumber sector) +mifare_classic_format_sector (FreefareTag tag, const MifareClassicSectorNumber sector) { MifareClassicBlockNumber first_sector_block = mifare_classic_sector_first_block (sector); MifareClassicBlockNumber last_sector_block = mifare_classic_sector_last_block (sector); diff --git a/libfreefare/mifare_desfire.3 b/libfreefare/mifare_desfire.3 index 5850685..720cf0c 100644 --- a/libfreefare/mifare_desfire.3 +++ b/libfreefare/mifare_desfire.3 @@ -109,125 +109,125 @@ Mifare card manipulation library (libfreefare, \-lfreefare) .Sh SYNOPSIS .In freefare.h .Ft int -.Fn mifare_desfire_connect "MifareTag tag" +.Fn mifare_desfire_connect "FreefareTag tag" .Ft int -.Fn mifare_desfire_disconnect "MifareTag tag" +.Fn mifare_desfire_disconnect "FreefareTag tag" .Ft int -.Fn mifare_desfire_authenticate "MifareTag tag" "uint8_t key_no" "MifareDESFireKey key" +.Fn mifare_desfire_authenticate "FreefareTag tag" "uint8_t key_no" "MifareDESFireKey key" .Ft int -.Fn mifare_desfire_authenticate_aes "MifareTag tag" "uint8_t key_no" "MifareDESFireKey key" +.Fn mifare_desfire_authenticate_aes "FreefareTag tag" "uint8_t key_no" "MifareDESFireKey key" .Ft int -.Fn mifare_desfire_authenticate_iso "MifareTag tag" "uint8_t key_no" "MifareDESFireKey key" +.Fn mifare_desfire_authenticate_iso "FreefareTag tag" "uint8_t key_no" "MifareDESFireKey key" .Ft int -.Fn mifare_desfire_change_key_settings "MifareTag tag" "uint8_t settings" +.Fn mifare_desfire_change_key_settings "FreefareTag tag" "uint8_t settings" .Ft int -.Fn mifare_desfire_get_key_settings "MifareTag tag" "uint8_t *settings" "uint8_t *max_keys" +.Fn mifare_desfire_get_key_settings "FreefareTag tag" "uint8_t *settings" "uint8_t *max_keys" .Ft int -.Fn mifare_desfire_change_key "MifareTag tag" "uint8_t key_no" "MifareDESFireKey new_key" "MifareDESFireKey old_key" +.Fn mifare_desfire_change_key "FreefareTag tag" "uint8_t key_no" "MifareDESFireKey new_key" "MifareDESFireKey old_key" .Ft int -.Fn mifare_desfire_get_key_version "MifareTag tag" "uint8_t key_no" "uint8_t *version" +.Fn mifare_desfire_get_key_version "FreefareTag tag" "uint8_t key_no" "uint8_t *version" .Ft int -.Fn mifare_desfire_create_application "MifareTag tag" "MifareDESFireAID aid" "uint8_t settings" "uint8_t key_no" +.Fn mifare_desfire_create_application "FreefareTag 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" +.Fn mifare_desfire_create_application_aes "FreefareTag 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" +.Fn mifare_desfire_create_application_3k3des "FreefareTag tag" "MifareDESFireAID aid" "uint8_t settings" "uint8_t key_no" .Ft int -.Fn mifare_desfire_create_application_iso "MifareTag tag" "MifareDESFireAID aid" "uint8_t settings" "uint8_t key_no" "int want_iso_file_identifiers" "uint16_t iso_file_id" "uint8_t *iso_file_name" "size_t iso_file_name_len" +.Fn mifare_desfire_create_application_iso "FreefareTag tag" "MifareDESFireAID aid" "uint8_t settings" "uint8_t key_no" "int want_iso_file_identifiers" "uint16_t iso_file_id" "uint8_t *iso_file_name" "size_t iso_file_name_len" .Ft int -.Fn mifare_desfire_create_application_3k3des_iso "MifareTag tag" "MifareDESFireAID aid" "uint8_t settings" "uint8_t key_no" "int want_iso_file_identifiers" "uint16_t iso_file_id" "uint8_t *iso_file_name" "size_t iso_file_name_len" +.Fn mifare_desfire_create_application_3k3des_iso "FreefareTag tag" "MifareDESFireAID aid" "uint8_t settings" "uint8_t key_no" "int want_iso_file_identifiers" "uint16_t iso_file_id" "uint8_t *iso_file_name" "size_t iso_file_name_len" .Ft int -.Fn mifare_desfire_create_application_aes_iso "MifareTag tag" "MifareDESFireAID aid" "uint8_t settings" "uint8_t key_no" "int want_iso_file_identifiers" "uint16_t iso_file_id" "uint8_t *iso_file_name" "size_t iso_file_name_len" +.Fn mifare_desfire_create_application_aes_iso "FreefareTag tag" "MifareDESFireAID aid" "uint8_t settings" "uint8_t key_no" "int want_iso_file_identifiers" "uint16_t iso_file_id" "uint8_t *iso_file_name" "size_t iso_file_name_len" .Ft int -.Fn mifare_desfire_delete_application "MifareTag tag" "MifareDESFireAID aid" +.Fn mifare_desfire_delete_application "FreefareTag tag" "MifareDESFireAID aid" .Ft int -.Fn mifare_desfire_get_application_ids "MifareTag tag" "MifareDESFireAID *aids[]" "size_t *count" +.Fn mifare_desfire_get_application_ids "FreefareTag tag" "MifareDESFireAID *aids[]" "size_t *count" .Ft void .Fn mifare_desfire_free_application_ids "MifareDESFireAID aids[]" .Ft int -.Fn mifare_desfire_get_df_names "MifareTag tag" "MifareDESFireDF *dfs[]" "size_t *count" +.Fn mifare_desfire_get_df_names "FreefareTag tag" "MifareDESFireDF *dfs[]" "size_t *count" .Ft int -.Fn mifare_desfire_select_application "MifareTag tag" "MifareDESFireAID aid" +.Fn mifare_desfire_select_application "FreefareTag tag" "MifareDESFireAID aid" .Ft int -.Fn mifare_desfire_format_picc "MifareTag tag" +.Fn mifare_desfire_format_picc "FreefareTag tag" .Ft int -.Fn mifare_desfire_get_version "MifareTag tag" "struct mifare_desfire_version_info *version_info" +.Fn mifare_desfire_get_version "FreefareTag tag" "struct mifare_desfire_version_info *version_info" .Ft int -.Fn mifare_desfire_free_mem "MifareTag tag" "uint32_t *size" +.Fn mifare_desfire_free_mem "FreefareTag tag" "uint32_t *size" .Ft int -.Fn mifare_desfire_set_configuration "MifareTag tag" "bool disable_format" "bool enable_random_uid" +.Fn mifare_desfire_set_configuration "FreefareTag tag" "bool disable_format" "bool enable_random_uid" .Ft int -.Fn mifare_desfire_set_default_key "MifareTag tag" "MifareDESFireKey key" +.Fn mifare_desfire_set_default_key "FreefareTag tag" "MifareDESFireKey key" .Ft int -.Fn mifare_desfire_set_ats "MifareTag tag" "uint8_t *ats" +.Fn mifare_desfire_set_ats "FreefareTag tag" "uint8_t *ats" .Ft int -.Fn mifare_desfire_get_card_uid "MifareTag tag" "char **uid" +.Fn mifare_desfire_get_card_uid "FreefareTag tag" "char **uid" .Ft int -.Fn mifare_desfire_get_file_ids "MifareTag tag" "uint8_t *files[]" "size_t *count" +.Fn mifare_desfire_get_file_ids "FreefareTag tag" "uint8_t *files[]" "size_t *count" .Ft int -.Fn mifare_desfire_get_iso_file_ids "MifareTag tag" "uint16_t *files[]" "size_t *count" +.Fn mifare_desfire_get_iso_file_ids "FreefareTag tag" "uint16_t *files[]" "size_t *count" .Ft int -.Fn mifare_desfire_get_file_settings "MifareTag tag" "uint8_t file_no" "struct mifare_desfire_file_settings *settings" +.Fn mifare_desfire_get_file_settings "FreefareTag tag" "uint8_t file_no" "struct mifare_desfire_file_settings *settings" .Ft int -.Fn mifare_desfire_change_file_settings "MifareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" +.Fn mifare_desfire_change_file_settings "FreefareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" .Ft int -.Fn mifare_desfire_create_std_data_file "MifareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t file_size" +.Fn mifare_desfire_create_std_data_file "FreefareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t file_size" .Ft int -.Fn mifare_desfire_create_std_data_file_iso "MifareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t file_size" "uint16_t iso_file_id" +.Fn mifare_desfire_create_std_data_file_iso "FreefareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t file_size" "uint16_t iso_file_id" .Ft int -.Fn mifare_desfire_create_backup_data_file "MifareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t file_size" +.Fn mifare_desfire_create_backup_data_file "FreefareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t file_size" .Ft int -.Fn mifare_desfire_create_backup_data_file_iso "MifareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t file_size" "uint16_t iso_file_id" +.Fn mifare_desfire_create_backup_data_file_iso "FreefareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t file_size" "uint16_t iso_file_id" .Ft int -.Fn mifare_desfire_create_value_file "MifareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "int32_t lower_limit" "int32_t upper_limit" "int32_t value" "uint8_t limited_credit_enable" +.Fn mifare_desfire_create_value_file "FreefareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "int32_t lower_limit" "int32_t upper_limit" "int32_t value" "uint8_t limited_credit_enable" .Ft int -.Fn mifare_desfire_create_linear_record_file "MifareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t record_size" "uint32_t max_number_of_records" +.Fn mifare_desfire_create_linear_record_file "FreefareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t record_size" "uint32_t max_number_of_records" .Ft int -.Fn mifare_desfire_create_linear_record_file_iso "MifareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t record_size" "uint32_t max_number_of_records" +.Fn mifare_desfire_create_linear_record_file_iso "FreefareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t record_size" "uint32_t max_number_of_records" .Ft int -.Fn mifare_desfire_create_cyclic_record_file "MifareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t record_size" "uint32_t max_number_of_records" "uint16_t iso_file_id" +.Fn mifare_desfire_create_cyclic_record_file "FreefareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t record_size" "uint32_t max_number_of_records" "uint16_t iso_file_id" .Ft int -.Fn mifare_desfire_create_cyclic_record_file_iso "MifareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t record_size" "uint32_t max_number_of_records" "uint16_t iso_file_id" +.Fn mifare_desfire_create_cyclic_record_file_iso "FreefareTag tag" "uint8_t file_no" "uint8_t communication_settings" "uint16_t access_rights" "uint32_t record_size" "uint32_t max_number_of_records" "uint16_t iso_file_id" .Ft int -.Fn mifare_desfire_delete_file "MifareTag tag" "uint8_t file_no" +.Fn mifare_desfire_delete_file "FreefareTag tag" "uint8_t file_no" .Ft ssize_t -.Fn mifare_desfire_read_data "MifareTag tag" "uint8_t file_no" "off_t offset" "size_t length" "void *data" +.Fn mifare_desfire_read_data "FreefareTag tag" "uint8_t file_no" "off_t offset" "size_t length" "void *data" .Ft ssize_t -.Fn mifare_desfire_read_data_ex "MifareTag tag" "uint8_t file_no" "off_t offset" "size_t length" "void *data" "int cs" +.Fn mifare_desfire_read_data_ex "FreefareTag tag" "uint8_t file_no" "off_t offset" "size_t length" "void *data" "int cs" .Ft ssize_t -.Fn mifare_desfire_write_data "MifareTag tag" "uint8_t file_no" "off_t offset" "size_t length" "void *data" +.Fn mifare_desfire_write_data "FreefareTag tag" "uint8_t file_no" "off_t offset" "size_t length" "void *data" .Ft ssize_t -.Fn mifare_desfire_write_data_ex "MifareTag tag" "uint8_t file_no" "off_t offset" "size_t length" "void *data" "int cs" +.Fn mifare_desfire_write_data_ex "FreefareTag tag" "uint8_t file_no" "off_t offset" "size_t length" "void *data" "int cs" .Ft int -.Fn mifare_desfire_get_value "MifareTag tag" "uint8_t file_no" "int32_t *value" +.Fn mifare_desfire_get_value "FreefareTag tag" "uint8_t file_no" "int32_t *value" .Ft int -.Fn mifare_desfire_get_value_ex "MifareTag tag" "uint8_t file_no" "int32_t *value" "int cs" +.Fn mifare_desfire_get_value_ex "FreefareTag tag" "uint8_t file_no" "int32_t *value" "int cs" .Ft int -.Fn mifare_desfire_credit "MifareTag tag" "uint8_t file_no" "int32_t amount" +.Fn mifare_desfire_credit "FreefareTag tag" "uint8_t file_no" "int32_t amount" .Ft int -.Fn mifare_desfire_credit_ex "MifareTag tag" "uint8_t file_no" "int32_t amount" "int cs" +.Fn mifare_desfire_credit_ex "FreefareTag tag" "uint8_t file_no" "int32_t amount" "int cs" .Ft int -.Fn mifare_desfire_debit "MifareTag tag" "uint8_t file_no" "int32_t amount" +.Fn mifare_desfire_debit "FreefareTag tag" "uint8_t file_no" "int32_t amount" .Ft int -.Fn mifare_desfire_debit_ex "MifareTag tag" "uint8_t file_no" "int32_t amount" "int cs" +.Fn mifare_desfire_debit_ex "FreefareTag tag" "uint8_t file_no" "int32_t amount" "int cs" .Ft int -.Fn mifare_desfire_limited_credit "MifareTag tag" "uint8_t file_no" "int32_t amount" +.Fn mifare_desfire_limited_credit "FreefareTag tag" "uint8_t file_no" "int32_t amount" .Ft int -.Fn mifare_desfire_limited_credit_ex "MifareTag tag" "uint8_t file_no" "int32_t amount" "int cs" +.Fn mifare_desfire_limited_credit_ex "FreefareTag tag" "uint8_t file_no" "int32_t amount" "int cs" .Ft ssize_t -.Fn mifare_desfire_write_record "MifareTag tag" "uint8_t file_no" "off_t offset" "size_t length" "void *data" +.Fn mifare_desfire_write_record "FreefareTag tag" "uint8_t file_no" "off_t offset" "size_t length" "void *data" .Ft ssize_t -.Fn mifare_desfire_write_record_ex "MifareTag tag" "uint8_t file_no" "off_t offset" "size_t length" "void *data" "int cs" +.Fn mifare_desfire_write_record_ex "FreefareTag tag" "uint8_t file_no" "off_t offset" "size_t length" "void *data" "int cs" .Ft ssize_t -.Fn mifare_desfire_read_records "MifareTag tag" "uint8_t file_no" "off_t offset" "size_t length" "void *data" +.Fn mifare_desfire_read_records "FreefareTag tag" "uint8_t file_no" "off_t offset" "size_t length" "void *data" .Ft ssize_t -.Fn mifare_desfire_read_records_ex "MifareTag tag" "uint7_t file_no" "off_t offset" "size_t length" "void *data" "int cs" +.Fn mifare_desfire_read_records_ex "FreefareTag tag" "uint7_t file_no" "off_t offset" "size_t length" "void *data" "int cs" .Ft int -.Fn mifare_desfire_clear_record_file "MifareTag tag" "uint8_t file_no" +.Fn mifare_desfire_clear_record_file "FreefareTag tag" "uint8_t file_no" .Ft int -.Fn mifare_desfire_commit_transaction "MifareTag tag" +.Fn mifare_desfire_commit_transaction "FreefareTag tag" .Ft int -.Fn mifare_desfire_abort_transaction "MifareTag tag" +.Fn mifare_desfire_abort_transaction "FreefareTag tag" .\" ____ _ _ _ .\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __ .\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \ diff --git a/libfreefare/mifare_desfire.c b/libfreefare/mifare_desfire.c index 543d80a..6319ef8 100644 --- a/libfreefare/mifare_desfire.c +++ b/libfreefare/mifare_desfire.c @@ -100,11 +100,11 @@ struct mifare_desfire_raw_file_settings { static struct mifare_desfire_file_settings cached_file_settings[MAX_FILE_COUNT]; static bool cached_file_settings_current[MAX_FILE_COUNT]; -static int authenticate (MifareTag tag, uint8_t cmd, uint8_t key_no, MifareDESFireKey key); -static int create_file1 (MifareTag tag, uint8_t command, uint8_t file_no, int has_iso_file_id, uint16_t iso_file_id, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size); -static int create_file2 (MifareTag tag, uint8_t command, uint8_t file_no, int has_iso_file_id, uint16_t iso_file_id, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records); -static ssize_t write_data (MifareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_t length, const void *data, int cs); -static ssize_t read_data (MifareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_t length, void *data, int cs); +static int authenticate (FreefareTag tag, uint8_t cmd, uint8_t key_no, MifareDESFireKey key); +static int create_file1 (FreefareTag tag, uint8_t command, uint8_t file_no, int has_iso_file_id, uint16_t iso_file_id, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size); +static int create_file2 (FreefareTag tag, uint8_t command, uint8_t file_no, int has_iso_file_id, uint16_t iso_file_id, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records); +static ssize_t write_data (FreefareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_t length, const void *data, int cs); +static ssize_t read_data (FreefareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_t length, void *data, int cs); #define NOT_YET_AUTHENTICATED 255 @@ -208,7 +208,7 @@ static ssize_t read_data (MifareTag tag, uint8_t command, uint8_t file_no, off_ static int32_t le24toh (uint8_t data[3]); static int -madame_soleil_get_read_communication_settings (MifareTag tag, uint8_t file_no) +madame_soleil_get_read_communication_settings (FreefareTag tag, uint8_t file_no) { struct mifare_desfire_file_settings settings; if (mifare_desfire_get_file_settings (tag, file_no, &settings)) @@ -222,7 +222,7 @@ madame_soleil_get_read_communication_settings (MifareTag tag, uint8_t file_no) } static int -madame_soleil_get_write_communication_settings (MifareTag tag, uint8_t file_no) +madame_soleil_get_write_communication_settings (FreefareTag tag, uint8_t file_no) { struct mifare_desfire_file_settings settings; if (mifare_desfire_get_file_settings (tag, file_no, &settings)) @@ -249,10 +249,10 @@ le24toh (uint8_t data[3]) /* * Allocates and initialize a MIFARE DESFire tag. */ -MifareTag +FreefareTag mifare_desfire_tag_new (void) { - MifareTag tag; + FreefareTag tag; if ((tag= malloc (sizeof (struct mifare_desfire_tag)))) { MIFARE_DESFIRE (tag)->last_picc_error = OPERATION_OK; MIFARE_DESFIRE (tag)->last_pcd_error = OPERATION_OK; @@ -267,7 +267,7 @@ mifare_desfire_tag_new (void) * Free the provided tag. */ void -mifare_desfire_tag_free (MifareTag tag) +mifare_desfire_tag_free (FreefareTag tag) { free (MIFARE_DESFIRE (tag)->session_key); free (MIFARE_DESFIRE (tag)->crypto_buffer); @@ -287,7 +287,7 @@ mifare_desfire_tag_free (MifareTag tag) * Establish connection to the provided tag. */ int -mifare_desfire_connect (MifareTag tag) +mifare_desfire_connect (FreefareTag tag) { ASSERT_INACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -331,7 +331,7 @@ mifare_desfire_connect (MifareTag tag) * Terminate connection with the provided tag. */ int -mifare_desfire_disconnect (MifareTag tag) +mifare_desfire_disconnect (FreefareTag tag) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -352,7 +352,7 @@ mifare_desfire_disconnect (MifareTag tag) #define AUTHENTICATE_AES 0xAA static int -authenticate (MifareTag tag, uint8_t cmd, uint8_t key_no, MifareDESFireKey key) +authenticate (FreefareTag tag, uint8_t cmd, uint8_t key_no, MifareDESFireKey key) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -439,7 +439,7 @@ authenticate (MifareTag tag, uint8_t cmd, uint8_t key_no, MifareDESFireKey key) } int -mifare_desfire_authenticate (MifareTag tag, uint8_t key_no, MifareDESFireKey key) +mifare_desfire_authenticate (FreefareTag tag, uint8_t key_no, MifareDESFireKey key) { switch (key->type) { case T_DES: @@ -458,19 +458,19 @@ mifare_desfire_authenticate (MifareTag tag, uint8_t key_no, MifareDESFireKey key } int -mifare_desfire_authenticate_iso (MifareTag tag, uint8_t key_no, MifareDESFireKey key) +mifare_desfire_authenticate_iso (FreefareTag tag, uint8_t key_no, MifareDESFireKey key) { return authenticate (tag, AUTHENTICATE_ISO, key_no, key); } int -mifare_desfire_authenticate_aes (MifareTag tag, uint8_t key_no, MifareDESFireKey key) +mifare_desfire_authenticate_aes (FreefareTag tag, uint8_t key_no, MifareDESFireKey key) { return authenticate (tag, AUTHENTICATE_AES, key_no, key); } int -mifare_desfire_change_key_settings (MifareTag tag, uint8_t settings) +mifare_desfire_change_key_settings (FreefareTag tag, uint8_t settings) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -496,7 +496,7 @@ mifare_desfire_change_key_settings (MifareTag tag, uint8_t settings) } int -mifare_desfire_get_key_settings (MifareTag tag, uint8_t *settings, uint8_t *max_keys) +mifare_desfire_get_key_settings (FreefareTag tag, uint8_t *settings, uint8_t *max_keys) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -525,7 +525,7 @@ mifare_desfire_get_key_settings (MifareTag tag, uint8_t *settings, uint8_t *max_ } int -mifare_desfire_change_key (MifareTag tag, uint8_t key_no, MifareDESFireKey new_key, MifareDESFireKey old_key) +mifare_desfire_change_key (FreefareTag tag, uint8_t key_no, MifareDESFireKey new_key, MifareDESFireKey old_key) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -639,7 +639,7 @@ mifare_desfire_change_key (MifareTag tag, uint8_t key_no, MifareDESFireKey new_k * Retrieve version information for a given key. */ int -mifare_desfire_get_key_version (MifareTag tag, uint8_t key_no, uint8_t *version) +mifare_desfire_get_key_version (FreefareTag tag, uint8_t key_no, uint8_t *version) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -670,7 +670,7 @@ mifare_desfire_get_key_version (MifareTag tag, uint8_t key_no, uint8_t *version) static int -create_application (MifareTag tag, MifareDESFireAID aid, uint8_t settings1, uint8_t settings2, int want_iso_application, int want_iso_file_identifiers, uint16_t iso_file_id, uint8_t *iso_file_name, size_t iso_file_name_len) +create_application (FreefareTag tag, MifareDESFireAID aid, uint8_t settings1, uint8_t settings2, int want_iso_application, int want_iso_file_identifiers, uint16_t iso_file_id, uint8_t *iso_file_name, size_t iso_file_name_len) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -706,43 +706,43 @@ create_application (MifareTag tag, MifareDESFireAID aid, uint8_t settings1, uint } int -mifare_desfire_create_application (MifareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no) +mifare_desfire_create_application (FreefareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no) { return create_application (tag, aid, settings, key_no, 0, 0, 0, NULL, 0); } int -mifare_desfire_create_application_iso (MifareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no, int want_iso_file_identifiers, uint16_t iso_file_id, uint8_t *iso_file_name, size_t iso_file_name_len) +mifare_desfire_create_application_iso (FreefareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no, int want_iso_file_identifiers, uint16_t iso_file_id, uint8_t *iso_file_name, size_t iso_file_name_len) { return create_application (tag, aid, settings, key_no, 1, want_iso_file_identifiers, iso_file_id, iso_file_name, iso_file_name_len); } int -mifare_desfire_create_application_3k3des (MifareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no) +mifare_desfire_create_application_3k3des (FreefareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no) { return create_application (tag, aid, settings, APPLICATION_CRYPTO_3K3DES | key_no, 0, 0, 0, NULL, 0); } int -mifare_desfire_create_application_3k3des_iso (MifareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no, int want_iso_file_identifiers, uint16_t iso_file_id, uint8_t *iso_file_name, size_t iso_file_name_len) +mifare_desfire_create_application_3k3des_iso (FreefareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no, int want_iso_file_identifiers, uint16_t iso_file_id, uint8_t *iso_file_name, size_t iso_file_name_len) { return create_application (tag, aid, settings, APPLICATION_CRYPTO_3K3DES | key_no, 1, want_iso_file_identifiers, iso_file_id, iso_file_name, iso_file_name_len); } int -mifare_desfire_create_application_aes (MifareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no) +mifare_desfire_create_application_aes (FreefareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no) { return create_application (tag, aid, settings, APPLICATION_CRYPTO_AES | key_no, 0, 0, 0, NULL, 0); } int -mifare_desfire_create_application_aes_iso (MifareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no, int want_iso_file_identifiers, uint16_t iso_file_id, uint8_t *iso_file_name, size_t iso_file_name_len) +mifare_desfire_create_application_aes_iso (FreefareTag tag, MifareDESFireAID aid, uint8_t settings, uint8_t key_no, int want_iso_file_identifiers, uint16_t iso_file_id, uint8_t *iso_file_name, size_t iso_file_name_len) { return create_application (tag, aid, settings, APPLICATION_CRYPTO_AES | key_no, 1, want_iso_file_identifiers, iso_file_id, iso_file_name, iso_file_name_len); } int -mifare_desfire_delete_application (MifareTag tag, MifareDESFireAID aid) +mifare_desfire_delete_application (FreefareTag tag, MifareDESFireAID aid) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -777,7 +777,7 @@ mifare_desfire_delete_application (MifareTag tag, MifareDESFireAID aid) } int -mifare_desfire_get_application_ids (MifareTag tag, MifareDESFireAID *aids[], size_t *count) +mifare_desfire_get_application_ids (FreefareTag tag, MifareDESFireAID *aids[], size_t *count) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -833,7 +833,7 @@ mifare_desfire_get_application_ids (MifareTag tag, MifareDESFireAID *aids[], siz } int -mifare_desfire_get_df_names (MifareTag tag, MifareDESFireDF *dfs[], size_t *count) +mifare_desfire_get_df_names (FreefareTag tag, MifareDESFireDF *dfs[], size_t *count) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -882,7 +882,7 @@ mifare_desfire_free_application_ids (MifareDESFireAID aids[]) * NULL, the master application is selected (equivalent to aid = 0x00000). */ int -mifare_desfire_select_application (MifareTag tag, MifareDESFireAID aid) +mifare_desfire_select_application (FreefareTag tag, MifareDESFireAID aid) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -921,7 +921,7 @@ mifare_desfire_select_application (MifareTag tag, MifareDESFireAID aid) } int -mifare_desfire_format_picc (MifareTag tag) +mifare_desfire_format_picc (FreefareTag tag) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -953,7 +953,7 @@ mifare_desfire_format_picc (MifareTag tag) * Retrieve version information form the PICC. */ int -mifare_desfire_get_version (MifareTag tag, struct mifare_desfire_version_info *version_info) +mifare_desfire_get_version (FreefareTag tag, struct mifare_desfire_version_info *version_info) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -991,7 +991,7 @@ mifare_desfire_get_version (MifareTag tag, struct mifare_desfire_version_info *v } int -mifare_desfire_free_mem (MifareTag tag, uint32_t *size) +mifare_desfire_free_mem (FreefareTag tag, uint32_t *size) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1019,7 +1019,7 @@ mifare_desfire_free_mem (MifareTag tag, uint32_t *size) } int -mifare_desfire_set_configuration (MifareTag tag, bool disable_format, bool enable_random_uid) +mifare_desfire_set_configuration (FreefareTag tag, bool disable_format, bool enable_random_uid) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1045,7 +1045,7 @@ mifare_desfire_set_configuration (MifareTag tag, bool disable_format, bool enabl } int -mifare_desfire_set_default_key (MifareTag tag, MifareDESFireKey key) +mifare_desfire_set_default_key (FreefareTag tag, MifareDESFireKey key) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1085,7 +1085,7 @@ mifare_desfire_set_default_key (MifareTag tag, MifareDESFireKey key) } int -mifare_desfire_set_ats (MifareTag tag, uint8_t *ats) +mifare_desfire_set_ats (FreefareTag tag, uint8_t *ats) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1122,7 +1122,7 @@ mifare_desfire_set_ats (MifareTag tag, uint8_t *ats) } int -mifare_desfire_get_card_uid (MifareTag tag, char **uid) +mifare_desfire_get_card_uid (FreefareTag tag, char **uid) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1160,7 +1160,7 @@ mifare_desfire_get_card_uid (MifareTag tag, char **uid) /* Application level commands */ int -mifare_desfire_get_file_ids (MifareTag tag, uint8_t **files, size_t *count) +mifare_desfire_get_file_ids (FreefareTag tag, uint8_t **files, size_t *count) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1193,7 +1193,7 @@ mifare_desfire_get_file_ids (MifareTag tag, uint8_t **files, size_t *count) } int -mifare_desfire_get_iso_file_ids (MifareTag tag, uint16_t **files, size_t *count) +mifare_desfire_get_iso_file_ids (FreefareTag tag, uint16_t **files, size_t *count) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1241,7 +1241,7 @@ mifare_desfire_get_iso_file_ids (MifareTag tag, uint16_t **files, size_t *count) } int -mifare_desfire_get_file_settings (MifareTag tag, uint8_t file_no, struct mifare_desfire_file_settings *settings) +mifare_desfire_get_file_settings (FreefareTag tag, uint8_t file_no, struct mifare_desfire_file_settings *settings) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1300,7 +1300,7 @@ mifare_desfire_get_file_settings (MifareTag tag, uint8_t file_no, struct mifare_ } int -mifare_desfire_change_file_settings (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights) +mifare_desfire_change_file_settings (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1353,7 +1353,7 @@ mifare_desfire_change_file_settings (MifareTag tag, uint8_t file_no, uint8_t com } static int -create_file1 (MifareTag tag, uint8_t command, uint8_t file_no, int has_iso_file_id, uint16_t iso_file_id, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size) +create_file1 (FreefareTag tag, uint8_t command, uint8_t file_no, int has_iso_file_id, uint16_t iso_file_id, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1385,31 +1385,31 @@ create_file1 (MifareTag tag, uint8_t command, uint8_t file_no, int has_iso_file_ } int -mifare_desfire_create_std_data_file (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size) +mifare_desfire_create_std_data_file (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size) { return create_file1 (tag, 0xCD, file_no, 0, 0x0000, communication_settings, access_rights, file_size); } int -mifare_desfire_create_std_data_file_iso (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size, uint16_t iso_file_id) +mifare_desfire_create_std_data_file_iso (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size, uint16_t iso_file_id) { return create_file1 (tag, 0xCD, file_no, 1, iso_file_id, communication_settings, access_rights, file_size); } int -mifare_desfire_create_backup_data_file (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size) +mifare_desfire_create_backup_data_file (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size) { return create_file1 (tag, 0xCB, file_no, 0, 0x0000, communication_settings, access_rights, file_size); } int -mifare_desfire_create_backup_data_file_iso (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size, uint16_t iso_file_id) +mifare_desfire_create_backup_data_file_iso (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t file_size, uint16_t iso_file_id) { return create_file1 (tag, 0xCB, file_no, 1, iso_file_id, communication_settings, access_rights, file_size); } int -mifare_desfire_create_value_file (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, int32_t lower_limit, int32_t upper_limit, int32_t value, uint8_t limited_credit_enable) +mifare_desfire_create_value_file (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, int32_t lower_limit, int32_t upper_limit, int32_t value, uint8_t limited_credit_enable) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1442,7 +1442,7 @@ mifare_desfire_create_value_file (MifareTag tag, uint8_t file_no, uint8_t commun } static int -create_file2 (MifareTag tag, uint8_t command, uint8_t file_no, int has_iso_file_id, uint16_t iso_file_id, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records) +create_file2 (FreefareTag tag, uint8_t command, uint8_t file_no, int has_iso_file_id, uint16_t iso_file_id, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1475,31 +1475,31 @@ create_file2 (MifareTag tag, uint8_t command, uint8_t file_no, int has_iso_file_ } int -mifare_desfire_create_linear_record_file (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records) +mifare_desfire_create_linear_record_file (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records) { return create_file2 (tag, 0xC1, file_no, 0, 0x0000, communication_settings, access_rights, record_size, max_number_of_records); } int -mifare_desfire_create_linear_record_file_iso (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records, uint16_t iso_file_id) +mifare_desfire_create_linear_record_file_iso (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records, uint16_t iso_file_id) { return create_file2 (tag, 0xC1, file_no, 1, iso_file_id, communication_settings, access_rights, record_size, max_number_of_records); } int -mifare_desfire_create_cyclic_record_file (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records) +mifare_desfire_create_cyclic_record_file (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records) { return create_file2 (tag, 0xC0, file_no, 0, 0x000, communication_settings, access_rights, record_size, max_number_of_records); } int -mifare_desfire_create_cyclic_record_file_iso (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records, uint16_t iso_file_id) +mifare_desfire_create_cyclic_record_file_iso (FreefareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights, uint32_t record_size, uint32_t max_number_of_records, uint16_t iso_file_id) { return create_file2 (tag, 0xC0, file_no, 1, iso_file_id, communication_settings, access_rights, record_size, max_number_of_records); } int -mifare_desfire_delete_file (MifareTag tag, uint8_t file_no) +mifare_desfire_delete_file (FreefareTag tag, uint8_t file_no) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1529,7 +1529,7 @@ mifare_desfire_delete_file (MifareTag tag, uint8_t file_no) */ static ssize_t -read_data (MifareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_t length, void *data, int cs) +read_data (FreefareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_t length, void *data, int cs) { size_t bytes_received = 0; @@ -1639,19 +1639,19 @@ read_data (MifareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_t } ssize_t -mifare_desfire_read_data (MifareTag tag, uint8_t file_no, off_t offset, size_t length, void *data) +mifare_desfire_read_data (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, void *data) { return mifare_desfire_read_data_ex (tag, file_no, offset, length, data, madame_soleil_get_read_communication_settings (tag, file_no)); } ssize_t -mifare_desfire_read_data_ex (MifareTag tag, uint8_t file_no, off_t offset, size_t length, void *data, int cs) +mifare_desfire_read_data_ex (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, void *data, int cs) { return read_data (tag, 0xBD, file_no, offset, length, data, cs); } static ssize_t -write_data (MifareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_t length, const void *data, int cs) +write_data (FreefareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_t length, const void *data, int cs) { size_t bytes_left; size_t bytes_send = 0; @@ -1714,24 +1714,24 @@ write_data (MifareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_ } ssize_t -mifare_desfire_write_data (MifareTag tag, uint8_t file_no, off_t offset, size_t length, const void *data) +mifare_desfire_write_data (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, const void *data) { return mifare_desfire_write_data_ex (tag, file_no, offset, length, data, madame_soleil_get_write_communication_settings (tag, file_no)); } ssize_t -mifare_desfire_write_data_ex (MifareTag tag, uint8_t file_no, off_t offset, size_t length, const void *data, int cs) +mifare_desfire_write_data_ex (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, const void *data, int cs) { return write_data (tag, 0x3D, file_no, offset, length, data, cs); } int -mifare_desfire_get_value (MifareTag tag, uint8_t file_no, int32_t *value) +mifare_desfire_get_value (FreefareTag tag, uint8_t file_no, int32_t *value) { return mifare_desfire_get_value_ex (tag, file_no, value, madame_soleil_get_read_communication_settings (tag, file_no)); } int -mifare_desfire_get_value_ex (MifareTag tag, uint8_t file_no, int32_t *value, int cs) +mifare_desfire_get_value_ex (FreefareTag tag, uint8_t file_no, int32_t *value, int cs) { if (!value) return errno = EINVAL, -1; @@ -1762,13 +1762,13 @@ mifare_desfire_get_value_ex (MifareTag tag, uint8_t file_no, int32_t *value, int } int -mifare_desfire_credit (MifareTag tag, uint8_t file_no, int32_t amount) +mifare_desfire_credit (FreefareTag tag, uint8_t file_no, int32_t amount) { return mifare_desfire_credit_ex (tag, file_no, amount, madame_soleil_get_write_communication_settings (tag, file_no)); } int -mifare_desfire_credit_ex (MifareTag tag, uint8_t file_no, int32_t amount, int cs) +mifare_desfire_credit_ex (FreefareTag tag, uint8_t file_no, int32_t amount, int cs) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1796,12 +1796,12 @@ mifare_desfire_credit_ex (MifareTag tag, uint8_t file_no, int32_t amount, int cs } int -mifare_desfire_debit (MifareTag tag, uint8_t file_no, int32_t amount) +mifare_desfire_debit (FreefareTag tag, uint8_t file_no, int32_t amount) { return mifare_desfire_debit_ex (tag, file_no, amount, madame_soleil_get_write_communication_settings (tag, file_no)); } int -mifare_desfire_debit_ex (MifareTag tag, uint8_t file_no, int32_t amount, int cs) +mifare_desfire_debit_ex (FreefareTag tag, uint8_t file_no, int32_t amount, int cs) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1829,12 +1829,12 @@ mifare_desfire_debit_ex (MifareTag tag, uint8_t file_no, int32_t amount, int cs) } int -mifare_desfire_limited_credit (MifareTag tag, uint8_t file_no, int32_t amount) +mifare_desfire_limited_credit (FreefareTag tag, uint8_t file_no, int32_t amount) { return mifare_desfire_limited_credit_ex (tag, file_no, amount, madame_soleil_get_write_communication_settings (tag, file_no)); } int -mifare_desfire_limited_credit_ex (MifareTag tag, uint8_t file_no, int32_t amount, int cs) +mifare_desfire_limited_credit_ex (FreefareTag tag, uint8_t file_no, int32_t amount, int cs) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1862,30 +1862,30 @@ mifare_desfire_limited_credit_ex (MifareTag tag, uint8_t file_no, int32_t amount } ssize_t -mifare_desfire_write_record (MifareTag tag, uint8_t file_no, off_t offset, size_t length, void *data) +mifare_desfire_write_record (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, void *data) { return mifare_desfire_write_record_ex (tag, file_no, offset, length, data, madame_soleil_get_write_communication_settings (tag, file_no)); } ssize_t -mifare_desfire_write_record_ex (MifareTag tag, uint8_t file_no, off_t offset, size_t length, void *data, int cs) +mifare_desfire_write_record_ex (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, void *data, int cs) { return write_data (tag, 0x3B, file_no, offset, length, data, cs); } ssize_t -mifare_desfire_read_records (MifareTag tag, uint8_t file_no, off_t offset, size_t length, void *data) +mifare_desfire_read_records (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, void *data) { return mifare_desfire_read_records_ex (tag, file_no, offset, length, data, madame_soleil_get_read_communication_settings (tag, file_no)); } ssize_t -mifare_desfire_read_records_ex (MifareTag tag, uint8_t file_no, off_t offset, size_t length, void *data, int cs) +mifare_desfire_read_records_ex (FreefareTag tag, uint8_t file_no, off_t offset, size_t length, void *data, int cs) { return read_data (tag, 0xBB, file_no, offset, length, data, cs); } int -mifare_desfire_clear_record_file (MifareTag tag, uint8_t file_no) +mifare_desfire_clear_record_file (FreefareTag tag, uint8_t file_no) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1912,7 +1912,7 @@ mifare_desfire_clear_record_file (MifareTag tag, uint8_t file_no) } int -mifare_desfire_commit_transaction (MifareTag tag) +mifare_desfire_commit_transaction (FreefareTag tag) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); @@ -1936,7 +1936,7 @@ mifare_desfire_commit_transaction (MifareTag tag) } int -mifare_desfire_abort_transaction (MifareTag tag) +mifare_desfire_abort_transaction (FreefareTag tag) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_DESFIRE (tag); diff --git a/libfreefare/mifare_desfire_crypto.c b/libfreefare/mifare_desfire_crypto.c index cc1e6cb..6b932e1 100644 --- a/libfreefare/mifare_desfire_crypto.c +++ b/libfreefare/mifare_desfire_crypto.c @@ -259,7 +259,7 @@ maced_data_length (const MifareDESFireKey key, const size_t nbytes) * Buffer size required to encipher nbytes of data and a two bytes CRC. */ size_t -enciphered_data_length (const MifareTag tag, const size_t nbytes, int communication_settings) +enciphered_data_length (const FreefareTag tag, const size_t nbytes, int communication_settings) { size_t crc_length = 0; if (!(communication_settings & NO_CRC)) { @@ -283,7 +283,7 @@ enciphered_data_length (const MifareTag tag, const size_t nbytes, int communicat * Ensure that tag's crypto buffer is large enough to store nbytes of data. */ void * -assert_crypto_buffer_size (MifareTag tag, size_t nbytes) +assert_crypto_buffer_size (FreefareTag tag, size_t nbytes) { void *res = MIFARE_DESFIRE (tag)->crypto_buffer; if (MIFARE_DESFIRE (tag)->crypto_buffer_size < nbytes) { @@ -296,7 +296,7 @@ assert_crypto_buffer_size (MifareTag tag, size_t nbytes) } void * -mifare_cryto_preprocess_data (MifareTag tag, void *data, size_t *nbytes, off_t offset, int communication_settings) +mifare_cryto_preprocess_data (FreefareTag tag, void *data, size_t *nbytes, off_t offset, int communication_settings) { uint8_t *res = data; uint8_t mac[4]; @@ -435,7 +435,7 @@ mifare_cryto_preprocess_data (MifareTag tag, void *data, size_t *nbytes, off_t o } void * -mifare_cryto_postprocess_data (MifareTag tag, void *data, ssize_t *nbytes, int communication_settings) +mifare_cryto_postprocess_data (FreefareTag tag, void *data, ssize_t *nbytes, int communication_settings) { void *res = data; size_t edl; @@ -754,7 +754,7 @@ mifare_cypher_single_block (MifareDESFireKey key, uint8_t *data, uint8_t *ivect, * function with tag, key and ivect defined. */ void -mifare_cypher_blocks_chained (MifareTag tag, MifareDESFireKey key, uint8_t *ivect, uint8_t *data, size_t data_size, MifareCryptoDirection direction, MifareCryptoOperation operation) +mifare_cypher_blocks_chained (FreefareTag tag, MifareDESFireKey key, uint8_t *ivect, uint8_t *data, size_t data_size, MifareCryptoDirection direction, MifareCryptoOperation operation) { size_t block_size; diff --git a/libfreefare/mifare_desfire_error.c b/libfreefare/mifare_desfire_error.c index 87a661b..fe3171e 100644 --- a/libfreefare/mifare_desfire_error.c +++ b/libfreefare/mifare_desfire_error.c @@ -72,7 +72,7 @@ mifare_desfire_error_lookup (uint8_t code) } uint8_t -mifare_desfire_last_pcd_error (MifareTag tag) +mifare_desfire_last_pcd_error (FreefareTag tag) { if (tag->tag_info->type != DESFIRE) return 0; @@ -81,7 +81,7 @@ mifare_desfire_last_pcd_error (MifareTag tag) } uint8_t -mifare_desfire_last_picc_error (MifareTag tag) +mifare_desfire_last_picc_error (FreefareTag tag) { if (tag->tag_info->type != DESFIRE) return 0; diff --git a/libfreefare/mifare_ultralight.3 b/libfreefare/mifare_ultralight.3 index 13328e6..1d9e609 100644 --- a/libfreefare/mifare_ultralight.3 +++ b/libfreefare/mifare_ultralight.3 @@ -47,13 +47,13 @@ Mifare card manipulation library (libfreefare, \-lfreefare) .Sh SYNOPSIS .In freefare.h .Ft int -.Fn mifare_ultralight_connect "MifareTag tag" +.Fn mifare_ultralight_connect "FreefareTag tag" .Ft int -.Fn mifare_ultralight_disconnect "MifareTag tag" +.Fn mifare_ultralight_disconnect "FreefareTag tag" .Ft int -.Fn mifare_ultralight_read "MifareTag tag" "const MifareUltralightPageNumber page" "MifareUltralightPage *data" +.Fn mifare_ultralight_read "FreefareTag tag" "const MifareUltralightPageNumber page" "MifareUltralightPage *data" .Ft int -.Fn mifare_ultralight_write "MifareTag tag" "const MifareUltralightPageNumber page" "const MifareUltralightPage data" +.Fn mifare_ultralight_write "FreefareTag tag" "const MifareUltralightPageNumber page" "const MifareUltralightPage data" .\" ____ _ _ _ .\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __ .\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \ diff --git a/libfreefare/mifare_ultralight.c b/libfreefare/mifare_ultralight.c index f94adcd..48090ef 100644 --- a/libfreefare/mifare_ultralight.c +++ b/libfreefare/mifare_ultralight.c @@ -99,7 +99,7 @@ /* * Allocates and initialize a MIFARE UltraLight tag. */ -MifareTag +FreefareTag mifare_ultralight_tag_new (void) { return malloc (sizeof (struct mifare_ultralight_tag)); @@ -109,7 +109,7 @@ mifare_ultralight_tag_new (void) * Free the provided tag. */ void -mifare_ultralight_tag_free (MifareTag tag) +mifare_ultralight_tag_free (FreefareTag tag) { free (tag); } @@ -128,7 +128,7 @@ mifare_ultralight_tag_free (MifareTag tag) * Establish connection to the provided tag. */ int -mifare_ultralight_connect (MifareTag tag) +mifare_ultralight_connect (FreefareTag tag) { ASSERT_INACTIVE (tag); ASSERT_MIFARE_ULTRALIGHT (tag); @@ -153,7 +153,7 @@ mifare_ultralight_connect (MifareTag tag) * Terminate connection with the provided tag. */ int -mifare_ultralight_disconnect (MifareTag tag) +mifare_ultralight_disconnect (FreefareTag tag) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_ULTRALIGHT (tag); @@ -179,7 +179,7 @@ mifare_ultralight_disconnect (MifareTag tag) * Read data from the provided MIFARE tag. */ int -mifare_ultralight_read (MifareTag tag, MifareUltralightPageNumber page, MifareUltralightPage *data) +mifare_ultralight_read (FreefareTag tag, MifareUltralightPageNumber page, MifareUltralightPage *data) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_ULTRALIGHT (tag); @@ -219,7 +219,7 @@ mifare_ultralight_read (MifareTag tag, MifareUltralightPageNumber page, MifareUl * Read data to the provided MIFARE tag. */ int -mifare_ultralight_write (MifareTag tag, const MifareUltralightPageNumber page, const MifareUltralightPage data) +mifare_ultralight_write (FreefareTag tag, const MifareUltralightPageNumber page, const MifareUltralightPage data) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_ULTRALIGHT (tag); @@ -244,7 +244,7 @@ mifare_ultralight_write (MifareTag tag, const MifareUltralightPageNumber page, c * Authenticate to the provided MIFARE tag. */ int -mifare_ultralightc_authenticate (MifareTag tag, const MifareDESFireKey key) +mifare_ultralightc_authenticate (FreefareTag tag, const MifareDESFireKey key) { ASSERT_ACTIVE (tag); ASSERT_MIFARE_ULTRALIGHT_C (tag); diff --git a/test/common/mifare_desfire_auto_authenticate.c b/test/common/mifare_desfire_auto_authenticate.c index 7c38bad..4193fff 100644 --- a/test/common/mifare_desfire_auto_authenticate.c +++ b/test/common/mifare_desfire_auto_authenticate.c @@ -33,7 +33,7 @@ uint8_t key_data_3k3des[24] = { 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, const uint8_t key_data_aes_version = 0x42; void -mifare_desfire_auto_authenticate (MifareTag tag, uint8_t key_no) +mifare_desfire_auto_authenticate (FreefareTag tag, uint8_t key_no) { /* Determine which key is currently the master one */ uint8_t key_version; diff --git a/test/common/mifare_desfire_auto_authenticate.h b/test/common/mifare_desfire_auto_authenticate.h index 4240420..95d06a6 100644 --- a/test/common/mifare_desfire_auto_authenticate.h +++ b/test/common/mifare_desfire_auto_authenticate.h @@ -27,6 +27,6 @@ extern uint8_t key_data_aes[16]; extern uint8_t key_data_3k3des[24]; extern const uint8_t key_data_aes_version; -void mifare_desfire_auto_authenticate (MifareTag tag, uint8_t key_no); +void mifare_desfire_auto_authenticate (FreefareTag tag, uint8_t key_no); #endif diff --git a/test/mifare_classic_fixture.c b/test/mifare_classic_fixture.c index 2e16d88..50f6246 100644 --- a/test/mifare_classic_fixture.c +++ b/test/mifare_classic_fixture.c @@ -25,8 +25,8 @@ static nfc_context *context; static nfc_device *device = NULL; -static MifareTag *tags = NULL; -MifareTag tag = NULL; +static FreefareTag *tags = NULL; +FreefareTag tag = NULL; void cut_setup (void) diff --git a/test/mifare_classic_fixture.h b/test/mifare_classic_fixture.h index 19f10d0..1c9772a 100644 --- a/test/mifare_classic_fixture.h +++ b/test/mifare_classic_fixture.h @@ -17,4 +17,4 @@ * $Id$ */ -extern MifareTag tag; +extern FreefareTag tag; diff --git a/test/mifare_desfire_ev1_fixture.c b/test/mifare_desfire_ev1_fixture.c index dd49e7f..7dc0d0c 100644 --- a/test/mifare_desfire_ev1_fixture.c +++ b/test/mifare_desfire_ev1_fixture.c @@ -25,8 +25,8 @@ static nfc_context *context; static nfc_device *device = NULL; -static MifareTag *tags = NULL; -MifareTag tag = NULL; +static FreefareTag *tags = NULL; +FreefareTag tag = NULL; void cut_setup (void) diff --git a/test/mifare_desfire_ev1_fixture.h b/test/mifare_desfire_ev1_fixture.h index 214bf9c..6089dab 100644 --- a/test/mifare_desfire_ev1_fixture.h +++ b/test/mifare_desfire_ev1_fixture.h @@ -17,4 +17,4 @@ * $Id$ */ -extern MifareTag tag; +extern FreefareTag tag; diff --git a/test/mifare_desfire_fixture.c b/test/mifare_desfire_fixture.c index 2714cd8..5cf0920 100644 --- a/test/mifare_desfire_fixture.c +++ b/test/mifare_desfire_fixture.c @@ -25,8 +25,8 @@ static nfc_context *context; static nfc_device *device = NULL; -static MifareTag *tags = NULL; -MifareTag tag = NULL; +static FreefareTag *tags = NULL; +FreefareTag tag = NULL; void cut_setup (void) diff --git a/test/mifare_desfire_fixture.h b/test/mifare_desfire_fixture.h index 214bf9c..6089dab 100644 --- a/test/mifare_desfire_fixture.h +++ b/test/mifare_desfire_fixture.h @@ -17,4 +17,4 @@ * $Id$ */ -extern MifareTag tag; +extern FreefareTag tag; diff --git a/test/mifare_ultralight_fixture.c b/test/mifare_ultralight_fixture.c index a89a9bb..47fe85e 100644 --- a/test/mifare_ultralight_fixture.c +++ b/test/mifare_ultralight_fixture.c @@ -25,8 +25,8 @@ static nfc_context *context; static nfc_device *device = NULL; -static MifareTag *tags = NULL; -MifareTag tag = NULL; +static FreefareTag *tags = NULL; +FreefareTag tag = NULL; void cut_setup (void) diff --git a/test/mifare_ultralight_fixture.h b/test/mifare_ultralight_fixture.h index 214bf9c..6089dab 100644 --- a/test/mifare_ultralight_fixture.h +++ b/test/mifare_ultralight_fixture.h @@ -17,4 +17,4 @@ * $Id$ */ -extern MifareTag tag; +extern FreefareTag tag;