Rename MifareTag to FreefareTag.
Because we are libfreefare and not libmifare, the generic tag type should not be so specific.
This commit is contained in:
parent
d946230aec
commit
42b21ff42f
42 changed files with 384 additions and 381 deletions
6
HACKING
6
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
|
multiple places. Here is a list of the things to do in order to have the
|
||||||
infrastructure ready for hacking the new card support:
|
infrastructure ready for hacking the new card support:
|
||||||
- Edit libfreefare/freefare.h:
|
- Edit libfreefare/freefare.h:
|
||||||
- Add your tag to the `mifare_tag_type' enum;
|
- Add your tag to the `freefare_tag_type' enum;
|
||||||
- Add a <tag>_connect() and a <tag>_disconnect() function prototype;
|
- Add a <tag>_connect() and a <tag>_disconnect() function prototype;
|
||||||
- Edit libfreefare/freefare.3:
|
- 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:
|
- Edit libfreefare/freefare_internal.h:
|
||||||
- Add a new <tag>_tag struct. It's very first member SHALL be `struct
|
- Add a new <tag>_tag struct. It's very first member SHALL be `struct
|
||||||
mifare_tag __tag';
|
freefare_tag __tag';
|
||||||
- Add a <tag>_tag_new() and a <tag>_tag_free() function prototype;
|
- Add a <tag>_tag_new() and a <tag>_tag_free() function prototype;
|
||||||
- Add a ASSERT_<TAG>() macro to check the tag's type;
|
- Add a ASSERT_<TAG>() macro to check the tag's type;
|
||||||
- Add a <TAG>() macro to cast a generic tag to your type.
|
- Add a <TAG>() macro to cast a generic tag to your type.
|
||||||
|
|
|
@ -54,7 +54,7 @@ exec "Snippet MD MIFARE_DESFIRE".st.et
|
||||||
exec "Snippet MDA MifareDESFireAID".st.et
|
exec "Snippet MDA MifareDESFireAID".st.et
|
||||||
exec "Snippet MDK MifareDESFireKey".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 MU MIFARE_ULTRALIGHT".st.et
|
||||||
exec "Snippet MUP MifareUltralightPage".st.et
|
exec "Snippet MUP MifareUltralightPage".st.et
|
||||||
|
|
|
@ -44,9 +44,9 @@ MifareClassicKey default_keys_int[] = {
|
||||||
{ 0xaa,0xbb,0xcc,0xdd,0xee,0xff },
|
{ 0xaa,0xbb,0xcc,0xdd,0xee,0xff },
|
||||||
{ 0x00,0x00,0x00,0x00,0x00,0x00 }
|
{ 0x00,0x00,0x00,0x00,0x00,0x00 }
|
||||||
};
|
};
|
||||||
int format_mifare_classic_1k (MifareTag tag);
|
int format_mifare_classic_1k (FreefareTag tag);
|
||||||
int format_mifare_classic_4k (MifareTag tag);
|
int format_mifare_classic_4k (FreefareTag tag);
|
||||||
int try_format_sector (MifareTag tag, MifareClassicSectorNumber sector);
|
int try_format_sector (FreefareTag tag, MifareClassicSectorNumber sector);
|
||||||
|
|
||||||
static int at_block = 0;
|
static int at_block = 0;
|
||||||
static int mod_block = 10;
|
static int mod_block = 10;
|
||||||
|
@ -73,7 +73,7 @@ display_progress (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
format_mifare_classic_1k (MifareTag tag)
|
format_mifare_classic_1k (FreefareTag tag)
|
||||||
{
|
{
|
||||||
printf (START_FORMAT_N, 16);
|
printf (START_FORMAT_N, 16);
|
||||||
for (int sector = 0; sector < 16; sector++) {
|
for (int sector = 0; sector < 16; sector++) {
|
||||||
|
@ -85,7 +85,7 @@ format_mifare_classic_1k (MifareTag tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
format_mifare_classic_4k (MifareTag tag)
|
format_mifare_classic_4k (FreefareTag tag)
|
||||||
{
|
{
|
||||||
printf (START_FORMAT_N, 32 + 8);
|
printf (START_FORMAT_N, 32 + 8);
|
||||||
for (int sector = 0; sector < (32 + 8); sector++) {
|
for (int sector = 0; sector < (32 + 8); sector++) {
|
||||||
|
@ -97,7 +97,7 @@ format_mifare_classic_4k (MifareTag tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
try_format_sector (MifareTag tag, MifareClassicSectorNumber sector)
|
try_format_sector (FreefareTag tag, MifareClassicSectorNumber sector)
|
||||||
{
|
{
|
||||||
display_progress ();
|
display_progress ();
|
||||||
for (size_t i = 0; i < (sizeof (default_keys) / sizeof (MifareClassicKey)); i++) {
|
for (size_t i = 0; i < (sizeof (default_keys) / sizeof (MifareClassicKey)); i++) {
|
||||||
|
@ -143,7 +143,7 @@ main(int argc, char *argv[])
|
||||||
int ch;
|
int ch;
|
||||||
int error = EXIT_SUCCESS;
|
int error = EXIT_SUCCESS;
|
||||||
nfc_device *device = NULL;
|
nfc_device *device = NULL;
|
||||||
MifareTag *tags = NULL;
|
FreefareTag *tags = NULL;
|
||||||
|
|
||||||
while ((ch = getopt (argc, argv, "fhy")) != -1) {
|
while ((ch = getopt (argc, argv, "fhy")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
@ -238,7 +238,7 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format) {
|
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;
|
at_block = 0;
|
||||||
|
|
||||||
if (format_options.fast) {
|
if (format_options.fast) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
nfc_device *device = NULL;
|
nfc_device *device = NULL;
|
||||||
MifareTag *tags = NULL;
|
FreefareTag *tags = NULL;
|
||||||
Mad mad;
|
Mad mad;
|
||||||
|
|
||||||
int ch;
|
int ch;
|
||||||
|
|
|
@ -69,7 +69,7 @@ uint8_t *ndef_msg;
|
||||||
size_t ndef_msg_len;
|
size_t ndef_msg_len;
|
||||||
|
|
||||||
static int
|
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);
|
MifareClassicBlockNumber block = mifare_classic_sector_last_block (sector);
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ search_sector_key (MifareTag tag, MifareClassicSectorNumber sector, MifareClassi
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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;
|
MifareClassicBlock block;
|
||||||
mifare_classic_trailer_block (&block, mad_public_key_a, 0x0, 0x1, 0x1, 0x6, 0x00, default_keyb);
|
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;
|
int error = 0;
|
||||||
nfc_device *device = NULL;
|
nfc_device *device = NULL;
|
||||||
MifareTag *tags = NULL;
|
FreefareTag *tags = NULL;
|
||||||
Mad mad;
|
Mad mad;
|
||||||
MifareClassicKey transport_key = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
MifareClassicKey transport_key = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int error = EXIT_SUCCESS;
|
int error = EXIT_SUCCESS;
|
||||||
nfc_device *device = NULL;
|
nfc_device *device = NULL;
|
||||||
MifareTag *tags = NULL;
|
FreefareTag *tags = NULL;
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
errx (EXIT_FAILURE, "usage: %s", argv[0]);
|
errx (EXIT_FAILURE, "usage: %s", argv[0]);
|
||||||
|
|
|
@ -63,7 +63,7 @@ main(int argc, char *argv[])
|
||||||
int ch;
|
int ch;
|
||||||
int error = EXIT_SUCCESS;
|
int error = EXIT_SUCCESS;
|
||||||
nfc_device *device = NULL;
|
nfc_device *device = NULL;
|
||||||
MifareTag *tags = NULL;
|
FreefareTag *tags = NULL;
|
||||||
|
|
||||||
while ((ch = getopt (argc, argv, "hyK:")) != -1) {
|
while ((ch = getopt (argc, argv, "hyK:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ main(int argc, char *argv[])
|
||||||
int ch;
|
int ch;
|
||||||
int error = EXIT_SUCCESS;
|
int error = EXIT_SUCCESS;
|
||||||
nfc_device *device = NULL;
|
nfc_device *device = NULL;
|
||||||
MifareTag *tags = NULL;
|
FreefareTag *tags = NULL;
|
||||||
|
|
||||||
while ((ch = getopt (argc, argv, "hyK:")) != -1) {
|
while ((ch = getopt (argc, argv, "hyK:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ main(int argc, char *argv[])
|
||||||
int ch;
|
int ch;
|
||||||
int error = EXIT_SUCCESS;
|
int error = EXIT_SUCCESS;
|
||||||
nfc_device *device = NULL;
|
nfc_device *device = NULL;
|
||||||
MifareTag *tags = NULL;
|
FreefareTag *tags = NULL;
|
||||||
|
|
||||||
while ((ch = getopt (argc, argv, "hy")) != -1) {
|
while ((ch = getopt (argc, argv, "hy")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ main(int argc, char *argv[])
|
||||||
int ch;
|
int ch;
|
||||||
int error = EXIT_SUCCESS;
|
int error = EXIT_SUCCESS;
|
||||||
nfc_device *device = NULL;
|
nfc_device *device = NULL;
|
||||||
MifareTag *tags = NULL;
|
FreefareTag *tags = NULL;
|
||||||
|
|
||||||
while ((ch = getopt (argc, argv, "hyK:")) != -1) {
|
while ((ch = getopt (argc, argv, "hyK:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ main(int argc, char *argv[])
|
||||||
int ch;
|
int ch;
|
||||||
int error = EXIT_SUCCESS;
|
int error = EXIT_SUCCESS;
|
||||||
nfc_device *device = NULL;
|
nfc_device *device = NULL;
|
||||||
MifareTag *tags = NULL;
|
FreefareTag *tags = NULL;
|
||||||
|
|
||||||
while ((ch = getopt (argc, argv, "hyK:")) != -1) {
|
while ((ch = getopt (argc, argv, "hyK:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int error = EXIT_SUCCESS;
|
int error = EXIT_SUCCESS;
|
||||||
nfc_device *device = NULL;
|
nfc_device *device = NULL;
|
||||||
MifareTag *tags = NULL;
|
FreefareTag *tags = NULL;
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
errx (EXIT_FAILURE, "usage: %s", argv[0]);
|
errx (EXIT_FAILURE, "usage: %s", argv[0]);
|
||||||
|
|
|
@ -68,7 +68,7 @@ main(int argc, char *argv[])
|
||||||
int ch;
|
int ch;
|
||||||
int error = EXIT_SUCCESS;
|
int error = EXIT_SUCCESS;
|
||||||
nfc_device *device = NULL;
|
nfc_device *device = NULL;
|
||||||
MifareTag *tags = NULL;
|
FreefareTag *tags = NULL;
|
||||||
|
|
||||||
char *ndef_output = NULL;
|
char *ndef_output = NULL;
|
||||||
while ((ch = getopt (argc, argv, "hyo:k:")) != -1) {
|
while ((ch = getopt (argc, argv, "hyo:k:")) != -1) {
|
||||||
|
|
|
@ -76,7 +76,7 @@ main(int argc, char *argv[])
|
||||||
int ch;
|
int ch;
|
||||||
int error = EXIT_SUCCESS;
|
int error = EXIT_SUCCESS;
|
||||||
nfc_device *device = NULL;
|
nfc_device *device = NULL;
|
||||||
MifareTag *tags = NULL;
|
FreefareTag *tags = NULL;
|
||||||
|
|
||||||
char *ndef_input = NULL;
|
char *ndef_input = NULL;
|
||||||
while ((ch = getopt (argc, argv, "hyi:k:")) != -1) {
|
while ((ch = getopt (argc, argv, "hyi:k:")) != -1) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int error = EXIT_SUCCESS;
|
int error = EXIT_SUCCESS;
|
||||||
nfc_device *device = NULL;
|
nfc_device *device = NULL;
|
||||||
MifareTag *tags = NULL;
|
FreefareTag *tags = NULL;
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
errx (EXIT_FAILURE, "usage: %s", argv[0]);
|
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]);
|
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]));
|
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) {
|
if (freefare_get_tag_type (tags[i]) == ULTRALIGHT_C) {
|
||||||
MifareTag tag = tags[i];
|
FreefareTag tag = tags[i];
|
||||||
int res;
|
int res;
|
||||||
MifareDESFireKey key;
|
MifareDESFireKey key;
|
||||||
uint8_t key1_3des_data[16] = { 0x49, 0x45, 0x4D, 0x4B, 0x41, 0x45, 0x52, 0x42, 0x21, 0x4E, 0x41, 0x43, 0x55, 0x4F, 0x59, 0x46 };
|
uint8_t key1_3des_data[16] = { 0x49, 0x45, 0x4D, 0x4B, 0x41, 0x45, 0x52, 0x42, 0x21, 0x4E, 0x41, 0x43, 0x55, 0x4F, 0x59, 0x46 };
|
||||||
|
|
|
@ -48,25 +48,25 @@ Mifare card manipulation library (libfreefare, \-lfreefare)
|
||||||
.\" |___/ |_|
|
.\" |___/ |_|
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.In freefare.h
|
.In freefare.h
|
||||||
.Ft "MifareTag *"
|
.Ft "FreefareTag *"
|
||||||
.Fn freefare_get_tags "nfc_device_t *device"
|
.Fn freefare_get_tags "nfc_device_t *device"
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
enum mifare_tag_type {
|
enum freefare_tag_type {
|
||||||
ULTRALIGHT,
|
ULTRALIGHT,
|
||||||
CLASSIC_1K,
|
CLASSIC_1K,
|
||||||
CLASSIC_4K
|
CLASSIC_4K
|
||||||
};
|
};
|
||||||
.Ed
|
.Ed
|
||||||
.Ft "enum mifare_tag_type"
|
.Ft "enum freefare_tag_type"
|
||||||
.Fn freefare_get_tag_type "MifareTag tag"
|
.Fn freefare_get_tag_type "FreefareTag tag"
|
||||||
.Ft "const char *"
|
.Ft "const char *"
|
||||||
.Fn freefare_get_tag_friendly_name "MifareTag tag"
|
.Fn freefare_get_tag_friendly_name "FreefareTag tag"
|
||||||
.Ft "char *"
|
.Ft "char *"
|
||||||
.Fn freefare_get_tag_uid "MifareTag tag"
|
.Fn freefare_get_tag_uid "FreefareTag tag"
|
||||||
.Ft "void"
|
.Ft "void"
|
||||||
.Fn freefare_free_tag "MifareTag tags"
|
.Fn freefare_free_tag "FreefareTag tags"
|
||||||
.Ft "void"
|
.Ft "void"
|
||||||
.Fn freefare_free_tags "MifareTag *tags"
|
.Fn freefare_free_tags "FreefareTag *tags"
|
||||||
.\" ____ _ _ _
|
.\" ____ _ _ _
|
||||||
.\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __
|
.\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __
|
||||||
.\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \
|
.\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \
|
||||||
|
@ -77,12 +77,12 @@ enum mifare_tag_type {
|
||||||
The
|
The
|
||||||
.Fn freefare_*
|
.Fn freefare_*
|
||||||
family of functions allow agnostic access to the
|
family of functions allow agnostic access to the
|
||||||
.Vt MifareTag
|
.Vt FreefareTag
|
||||||
present on a given NFC device.
|
present on a given NFC device.
|
||||||
.Pp
|
.Pp
|
||||||
.Fn freefare_get_tags
|
.Fn freefare_get_tags
|
||||||
returns a NULL-terminated list of
|
returns a NULL-terminated list of
|
||||||
.Vt MifareTag
|
.Vt FreefareTag
|
||||||
present on
|
present on
|
||||||
.Vt device .
|
.Vt device .
|
||||||
This list has to be freed after usage by either:
|
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.
|
function.
|
||||||
.Pp
|
.Pp
|
||||||
Information about a given
|
Information about a given
|
||||||
.Vt MifareTag
|
.Vt FreefareTag
|
||||||
can be gathered using the
|
can be gathered using the
|
||||||
.Fn freefare_get_tag_type ,
|
.Fn freefare_get_tag_type ,
|
||||||
.Fn freefare_get_tag_uid
|
.Fn freefare_get_tag_uid
|
||||||
|
|
|
@ -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)
|
freefare_tag_new (nfc_device *device, nfc_iso14443a_info nai)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
struct supported_tag *tag_info;
|
struct supported_tag *tag_info;
|
||||||
MifareTag tag;
|
FreefareTag tag;
|
||||||
|
|
||||||
/* Ensure the target is supported */
|
/* Ensure the target is supported */
|
||||||
for (size_t i = 0; i < sizeof (supported_tags) / sizeof (struct supported_tag); i++) {
|
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.
|
* The list has to be freed using the freefare_free_tags() function.
|
||||||
*/
|
*/
|
||||||
MifareTag *
|
FreefareTag *
|
||||||
freefare_get_tags (nfc_device *device)
|
freefare_get_tags (nfc_device *device)
|
||||||
{
|
{
|
||||||
MifareTag *tags = NULL;
|
FreefareTag *tags = NULL;
|
||||||
int tag_count = 0;
|
int tag_count = 0;
|
||||||
|
|
||||||
nfc_initiator_init(device);
|
nfc_initiator_init(device);
|
||||||
|
@ -148,10 +148,10 @@ freefare_get_tags (nfc_device *device)
|
||||||
tags[0] = NULL;
|
tags[0] = NULL;
|
||||||
|
|
||||||
for (int c = 0; c < candidates_count; c++) {
|
for (int c = 0; c < candidates_count; c++) {
|
||||||
MifareTag t;
|
FreefareTag t;
|
||||||
if ((t = freefare_tag_new(device, candidates[c].nti.nai))) {
|
if ((t = freefare_tag_new(device, candidates[c].nti.nai))) {
|
||||||
/* (Re)Allocate memory for the found MIFARE targets array */
|
/* (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)
|
if (p)
|
||||||
tags = p;
|
tags = p;
|
||||||
else
|
else
|
||||||
|
@ -167,8 +167,8 @@ freefare_get_tags (nfc_device *device)
|
||||||
/*
|
/*
|
||||||
* Returns the type of the provided tag.
|
* Returns the type of the provided tag.
|
||||||
*/
|
*/
|
||||||
enum mifare_tag_type
|
enum freefare_tag_type
|
||||||
freefare_get_tag_type (MifareTag tag)
|
freefare_get_tag_type (FreefareTag tag)
|
||||||
{
|
{
|
||||||
return tag->tag_info->type;
|
return tag->tag_info->type;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ freefare_get_tag_type (MifareTag tag)
|
||||||
* Returns the friendly name of the provided tag.
|
* Returns the friendly name of the provided tag.
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
freefare_get_tag_friendly_name (MifareTag tag)
|
freefare_get_tag_friendly_name (FreefareTag tag)
|
||||||
{
|
{
|
||||||
return tag->tag_info->friendly_name;
|
return tag->tag_info->friendly_name;
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ freefare_get_tag_friendly_name (MifareTag tag)
|
||||||
* Returns the UID of the provided tag.
|
* Returns the UID of the provided tag.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
freefare_get_tag_uid (MifareTag tag)
|
freefare_get_tag_uid (FreefareTag tag)
|
||||||
{
|
{
|
||||||
char *res;
|
char *res;
|
||||||
if ((res = malloc (2 * tag->info.szUidLen + 1))) {
|
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.
|
* Free the provided tag.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
freefare_free_tag (MifareTag tag)
|
freefare_free_tag (FreefareTag tag)
|
||||||
{
|
{
|
||||||
if (tag) {
|
if (tag) {
|
||||||
switch (tag->tag_info->type) {
|
switch (tag->tag_info->type) {
|
||||||
|
@ -228,7 +228,7 @@ freefare_free_tag (MifareTag tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
freefare_strerror (MifareTag tag)
|
freefare_strerror (FreefareTag tag)
|
||||||
{
|
{
|
||||||
const char *p = "Unknown error";
|
const char *p = "Unknown error";
|
||||||
if (nfc_device_get_last_error (tag->device) < 0) {
|
if (nfc_device_get_last_error (tag->device) < 0) {
|
||||||
|
@ -246,13 +246,13 @@ freefare_strerror (MifareTag tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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;
|
return (snprintf (buffer, len, "%s", freefare_strerror (tag)) < 0) ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freefare_perror (MifareTag tag, const char *string)
|
freefare_perror (FreefareTag tag, const char *string)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: %s\n", string, freefare_strerror (tag));
|
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.
|
* Free the provided tag list.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
freefare_free_tags (MifareTag *tags)
|
freefare_free_tags (FreefareTag *tags)
|
||||||
{
|
{
|
||||||
if (tags) {
|
if (tags) {
|
||||||
for (int i=0; tags[i]; i++) {
|
for (int i=0; tags[i]; i++) {
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
enum mifare_tag_type {
|
enum freefare_tag_type {
|
||||||
ULTRALIGHT,
|
ULTRALIGHT,
|
||||||
ULTRALIGHT_C,
|
ULTRALIGHT_C,
|
||||||
// MINI,
|
// MINI,
|
||||||
|
@ -43,8 +43,11 @@ enum mifare_tag_type {
|
||||||
DESFIRE
|
DESFIRE
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mifare_tag;
|
struct freefare_tag;
|
||||||
typedef struct mifare_tag *MifareTag;
|
typedef struct freefare_tag *FreefareTag;
|
||||||
|
|
||||||
|
/* Replace any MifareTag by the generic FreefareTag. */
|
||||||
|
typedef struct freefare_tag *MifareTag __attribute__ ((deprecated));
|
||||||
|
|
||||||
struct mifare_desfire_key;
|
struct mifare_desfire_key;
|
||||||
typedef struct mifare_desfire_key *MifareDESFireKey;
|
typedef struct mifare_desfire_key *MifareDESFireKey;
|
||||||
|
@ -52,26 +55,26 @@ typedef struct mifare_desfire_key *MifareDESFireKey;
|
||||||
typedef uint8_t MifareUltralightPageNumber;
|
typedef uint8_t MifareUltralightPageNumber;
|
||||||
typedef unsigned char MifareUltralightPage[4];
|
typedef unsigned char MifareUltralightPage[4];
|
||||||
|
|
||||||
MifareTag *freefare_get_tags (nfc_device *device);
|
FreefareTag *freefare_get_tags (nfc_device *device);
|
||||||
MifareTag freefare_tag_new (nfc_device *device, nfc_iso14443a_info nai);
|
FreefareTag freefare_tag_new (nfc_device *device, nfc_iso14443a_info nai);
|
||||||
enum mifare_tag_type freefare_get_tag_type (MifareTag tag);
|
enum freefare_tag_type freefare_get_tag_type (FreefareTag tag);
|
||||||
const char *freefare_get_tag_friendly_name (MifareTag tag);
|
const char *freefare_get_tag_friendly_name (FreefareTag tag);
|
||||||
char *freefare_get_tag_uid (MifareTag tag);
|
char *freefare_get_tag_uid (FreefareTag tag);
|
||||||
void freefare_free_tag (MifareTag tag);
|
void freefare_free_tag (FreefareTag tag);
|
||||||
void freefare_free_tags (MifareTag *tags);
|
void freefare_free_tags (FreefareTag *tags);
|
||||||
bool freefare_selected_tag_is_present(nfc_device *device);
|
bool freefare_selected_tag_is_present(nfc_device *device);
|
||||||
|
|
||||||
const char *freefare_strerror (MifareTag tag);
|
const char *freefare_strerror (FreefareTag tag);
|
||||||
int freefare_strerror_r (MifareTag tag, char *buffer, size_t len);
|
int freefare_strerror_r (FreefareTag tag, char *buffer, size_t len);
|
||||||
void freefare_perror (MifareTag tag, const char *string);
|
void freefare_perror (FreefareTag tag, const char *string);
|
||||||
|
|
||||||
int mifare_ultralight_connect (MifareTag tag);
|
int mifare_ultralight_connect (FreefareTag tag);
|
||||||
int mifare_ultralight_disconnect (MifareTag tag);
|
int mifare_ultralight_disconnect (FreefareTag tag);
|
||||||
|
|
||||||
int mifare_ultralight_read (MifareTag tag, const MifareUltralightPageNumber page, MifareUltralightPage *data);
|
int mifare_ultralight_read (FreefareTag tag, const MifareUltralightPageNumber page, MifareUltralightPage *data);
|
||||||
int mifare_ultralight_write (MifareTag tag, const MifareUltralightPageNumber page, const 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);
|
bool is_mifare_ultralightc_on_reader (nfc_device *device, nfc_iso14443a_info nai);
|
||||||
|
|
||||||
typedef unsigned char MifareClassicBlock[16];
|
typedef unsigned char MifareClassicBlock[16];
|
||||||
|
@ -85,24 +88,24 @@ typedef unsigned char MifareClassicKey[6];
|
||||||
/* NFC Forum public key */
|
/* NFC Forum public key */
|
||||||
extern const MifareClassicKey mifare_classic_nfcforum_public_key_a;
|
extern const MifareClassicKey mifare_classic_nfcforum_public_key_a;
|
||||||
|
|
||||||
int mifare_classic_connect (MifareTag tag);
|
int mifare_classic_connect (FreefareTag tag);
|
||||||
int mifare_classic_disconnect (MifareTag 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_authenticate (FreefareTag 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_read (FreefareTag 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_init_value (FreefareTag 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_read_value (FreefareTag tag, const MifareClassicBlockNumber block, int32_t *value, MifareClassicBlockNumber *adr);
|
||||||
int mifare_classic_write (MifareTag tag, const MifareClassicBlockNumber block, const MifareClassicBlock data);
|
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_increment (FreefareTag tag, const MifareClassicBlockNumber block, const uint32_t amount);
|
||||||
int mifare_classic_decrement (MifareTag 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 (MifareTag tag, const MifareClassicBlockNumber block);
|
int mifare_classic_restore (FreefareTag tag, const MifareClassicBlockNumber block);
|
||||||
int mifare_classic_transfer (MifareTag 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_trailer_block_permission (FreefareTag 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_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);
|
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;
|
extern const MadAid mad_nfcforum_aid;
|
||||||
|
|
||||||
Mad mad_new (const uint8_t version);
|
Mad mad_new (const uint8_t version);
|
||||||
Mad mad_read (MifareTag tag);
|
Mad mad_read (FreefareTag tag);
|
||||||
int mad_write (MifareTag tag, Mad mad, const MifareClassicKey key_b_sector_00, const MifareClassicKey key_b_sector_10);
|
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);
|
int mad_get_version (Mad mad);
|
||||||
void mad_set_version (Mad mad, const uint8_t version);
|
void mad_set_version (Mad mad, const uint8_t version);
|
||||||
MifareClassicSectorNumber mad_get_card_publisher_sector (Mad mad);
|
MifareClassicSectorNumber mad_get_card_publisher_sector (Mad mad);
|
||||||
|
@ -169,8 +172,8 @@ bool mad_sector_reserved (const MifareClassicSectorNumber sector);
|
||||||
void mad_free (Mad mad);
|
void mad_free (Mad mad);
|
||||||
|
|
||||||
MifareClassicSectorNumber *mifare_application_alloc (Mad mad, const MadAid aid, const size_t size);
|
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_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 (MifareTag tag, Mad mad, const MadAid aid, const 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);
|
int mifare_application_free (Mad mad, const MadAid aid);
|
||||||
|
|
||||||
MifareClassicSectorNumber *mifare_application_find (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);
|
MifareDESFireAID mifare_desfire_aid_new_with_mad_aid (MadAid mad_aid, uint8_t n);
|
||||||
uint32_t mifare_desfire_aid_get_aid (MifareDESFireAID aid);
|
uint32_t mifare_desfire_aid_get_aid (MifareDESFireAID aid);
|
||||||
|
|
||||||
uint8_t mifare_desfire_last_pcd_error (MifareTag tag);
|
uint8_t mifare_desfire_last_pcd_error (FreefareTag tag);
|
||||||
uint8_t mifare_desfire_last_picc_error (MifareTag tag);
|
uint8_t mifare_desfire_last_picc_error (FreefareTag tag);
|
||||||
|
|
||||||
#pragma pack (push)
|
#pragma pack (push)
|
||||||
#pragma pack (1)
|
#pragma pack (1)
|
||||||
|
@ -324,70 +327,70 @@ struct mifare_desfire_file_settings {
|
||||||
} settings;
|
} settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
int mifare_desfire_connect (MifareTag tag);
|
int mifare_desfire_connect (FreefareTag tag);
|
||||||
int mifare_desfire_disconnect (MifareTag tag);
|
int mifare_desfire_disconnect (FreefareTag tag);
|
||||||
|
|
||||||
int mifare_desfire_authenticate (MifareTag tag, uint8_t key_no, MifareDESFireKey key);
|
int mifare_desfire_authenticate (FreefareTag tag, uint8_t key_no, MifareDESFireKey key);
|
||||||
int mifare_desfire_authenticate_iso (MifareTag 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 (MifareTag 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 (MifareTag tag, uint8_t settings);
|
int mifare_desfire_change_key_settings (FreefareTag tag, uint8_t settings);
|
||||||
int mifare_desfire_get_key_settings (MifareTag tag, uint8_t *settings, uint8_t *max_keys);
|
int mifare_desfire_get_key_settings (FreefareTag 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_change_key (FreefareTag tag, uint8_t key_no, MifareDESFireKey new_key, MifareDESFireKey old_key);
|
||||||
int mifare_desfire_get_key_version (MifareTag tag, uint8_t key_no, uint8_t *version);
|
int mifare_desfire_get_key_version (FreefareTag 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 (FreefareTag 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_3k3des (FreefareTag 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_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_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 (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 (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 (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 (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_delete_application (FreefareTag tag, MifareDESFireAID aid);
|
||||||
int mifare_desfire_get_application_ids (MifareTag tag, MifareDESFireAID *aids[], size_t *count);
|
int mifare_desfire_get_application_ids (FreefareTag tag, MifareDESFireAID *aids[], size_t *count);
|
||||||
int mifare_desfire_get_df_names (MifareTag tag, MifareDESFireDF *dfs[], size_t *count);
|
int mifare_desfire_get_df_names (FreefareTag tag, MifareDESFireDF *dfs[], size_t *count);
|
||||||
void mifare_desfire_free_application_ids (MifareDESFireAID aids[]);
|
void mifare_desfire_free_application_ids (MifareDESFireAID aids[]);
|
||||||
int mifare_desfire_select_application (MifareTag tag, MifareDESFireAID aid);
|
int mifare_desfire_select_application (FreefareTag tag, MifareDESFireAID aid);
|
||||||
int mifare_desfire_format_picc (MifareTag tag);
|
int mifare_desfire_format_picc (FreefareTag tag);
|
||||||
int mifare_desfire_get_version (MifareTag tag, struct mifare_desfire_version_info *version_info);
|
int mifare_desfire_get_version (FreefareTag tag, struct mifare_desfire_version_info *version_info);
|
||||||
int mifare_desfire_free_mem (MifareTag tag, uint32_t *size);
|
int mifare_desfire_free_mem (FreefareTag tag, uint32_t *size);
|
||||||
int mifare_desfire_set_configuration (MifareTag tag, bool disable_format, bool enable_random_uid);
|
int mifare_desfire_set_configuration (FreefareTag tag, bool disable_format, bool enable_random_uid);
|
||||||
int mifare_desfire_set_default_key (MifareTag tag, MifareDESFireKey key);
|
int mifare_desfire_set_default_key (FreefareTag tag, MifareDESFireKey key);
|
||||||
int mifare_desfire_set_ats (MifareTag tag, uint8_t *ats);
|
int mifare_desfire_set_ats (FreefareTag tag, uint8_t *ats);
|
||||||
int mifare_desfire_get_card_uid (MifareTag tag, char **uid);
|
int mifare_desfire_get_card_uid (FreefareTag tag, char **uid);
|
||||||
int mifare_desfire_get_file_ids (MifareTag tag, uint8_t **files, size_t *count);
|
int mifare_desfire_get_file_ids (FreefareTag 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_iso_file_ids (FreefareTag 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_get_file_settings (FreefareTag tag, uint8_t file_no, struct mifare_desfire_file_settings *settings);
|
||||||
int mifare_desfire_change_file_settings (MifareTag tag, uint8_t file_no, uint8_t communication_settings, uint16_t access_rights);
|
int mifare_desfire_change_file_settings (FreefareTag 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 (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 (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_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 (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 (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 (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_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 (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_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 (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 (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 (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_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 (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 (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 (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_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 (MifareTag tag, uint8_t file_no);
|
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 (FreefareTag 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_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 (MifareTag tag, uint8_t file_no, off_t offset, size_t length, const void *data);
|
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 (MifareTag tag, uint8_t file_no, off_t offset, size_t length, const void *data, int cs);
|
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 (MifareTag tag, uint8_t file_no, int32_t *value);
|
int mifare_desfire_get_value (FreefareTag 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_get_value_ex (FreefareTag 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 (FreefareTag 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_credit_ex (FreefareTag 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 (FreefareTag 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_debit_ex (FreefareTag 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 (FreefareTag 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);
|
int mifare_desfire_limited_credit_ex (FreefareTag 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 (FreefareTag 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_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 (MifareTag tag, uint8_t file_no, off_t offset, size_t length, void *data);
|
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 (MifareTag tag, uint8_t file_no, off_t offset, size_t length, void *data, int cs);
|
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 (MifareTag tag, uint8_t file_no);
|
int mifare_desfire_clear_record_file (FreefareTag tag, uint8_t file_no);
|
||||||
int mifare_desfire_commit_transaction (MifareTag tag);
|
int mifare_desfire_commit_transaction (FreefareTag tag);
|
||||||
int mifare_desfire_abort_transaction (MifareTag tag);
|
int mifare_desfire_abort_transaction (FreefareTag tag);
|
||||||
|
|
||||||
MifareDESFireKey mifare_desfire_des_key_new (const uint8_t value[8]);
|
MifareDESFireKey mifare_desfire_des_key_new (const uint8_t value[8]);
|
||||||
MifareDESFireKey mifare_desfire_3des_key_new (const uint8_t value[16]);
|
MifareDESFireKey mifare_desfire_3des_key_new (const uint8_t value[16]);
|
||||||
|
|
|
@ -47,15 +47,15 @@ Mifare card manipulation library (libfreefare, \-lfreefare)
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.In freefare.h
|
.In freefare.h
|
||||||
.Ft "const char *"
|
.Ft "const char *"
|
||||||
.Fn freefare_strerror "MifareTag tag"
|
.Fn freefare_strerror "FreefareTag tag"
|
||||||
.Ft "int"
|
.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"
|
.Ft "void"
|
||||||
.Fn freefare_strerror "MifareTag tag" "char *string"
|
.Fn freefare_strerror "FreefareTag tag" "char *string"
|
||||||
.Ft "uint8_t"
|
.Ft "uint8_t"
|
||||||
.Fn mifare_desfire_last_pcd_error "MifareTag tag"
|
.Fn mifare_desfire_last_pcd_error "FreefareTag tag"
|
||||||
.Ft "uint8_t"
|
.Ft "uint8_t"
|
||||||
.Fn mifare_desfire_last_picc_error "MifareTag tag"
|
.Fn mifare_desfire_last_picc_error "FreefareTag tag"
|
||||||
.\" ____ _ _ _
|
.\" ____ _ _ _
|
||||||
.\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __
|
.\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __
|
||||||
.\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \
|
.\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \
|
||||||
|
|
|
@ -104,12 +104,12 @@ struct mad_sector_0x00;
|
||||||
struct mad_sector_0x10;
|
struct mad_sector_0x10;
|
||||||
|
|
||||||
void nxp_crc (uint8_t *crc, const uint8_t value);
|
void nxp_crc (uint8_t *crc, const uint8_t value);
|
||||||
MifareTag mifare_classic_tag_new (void);
|
FreefareTag mifare_classic_tag_new (void);
|
||||||
void mifare_classic_tag_free (MifareTag tag);
|
void mifare_classic_tag_free (FreefareTag tag);
|
||||||
MifareTag mifare_desfire_tag_new (void);
|
FreefareTag mifare_desfire_tag_new (void);
|
||||||
void mifare_desfire_tag_free (MifareTag tags);
|
void mifare_desfire_tag_free (FreefareTag tags);
|
||||||
MifareTag mifare_ultralight_tag_new (void);
|
FreefareTag mifare_ultralight_tag_new (void);
|
||||||
void mifare_ultralight_tag_free (MifareTag tag);
|
void mifare_ultralight_tag_free (FreefareTag tag);
|
||||||
uint8_t sector_0x00_crc8 (Mad mad);
|
uint8_t sector_0x00_crc8 (Mad mad);
|
||||||
uint8_t sector_0x10_crc8 (Mad mad);
|
uint8_t sector_0x10_crc8 (Mad mad);
|
||||||
|
|
||||||
|
@ -143,21 +143,21 @@ typedef enum {
|
||||||
#define MAC_MASK 0x0F0
|
#define MAC_MASK 0x0F0
|
||||||
#define CMAC_MACK 0xF00
|
#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_preprocess_data (FreefareTag 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_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_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 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 (const uint8_t *data, const size_t len, uint8_t *crc);
|
||||||
void desfire_crc32_append (uint8_t *data, const size_t len);
|
void desfire_crc32_append (uint8_t *data, const size_t len);
|
||||||
size_t key_block_size (const MifareDESFireKey key);
|
size_t key_block_size (const MifareDESFireKey key);
|
||||||
size_t padded_data_length (const size_t nbytes, const size_t block_size);
|
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 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_generate_subkeys (MifareDESFireKey key);
|
||||||
void cmac (const MifareDESFireKey key, uint8_t *ivect, const uint8_t *data, size_t len, uint8_t *cmac);
|
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_PAGE_COUNT 0x10
|
||||||
#define MIFARE_ULTRALIGHT_C_PAGE_COUNT 0x30
|
#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
|
#define MIFARE_ULTRALIGHT_MAX_PAGE_COUNT 0x30
|
||||||
|
|
||||||
struct supported_tag {
|
struct supported_tag {
|
||||||
enum mifare_tag_type type;
|
enum freefare_tag_type type;
|
||||||
const char *friendly_name;
|
const char *friendly_name;
|
||||||
uint8_t SAK;
|
uint8_t SAK;
|
||||||
uint8_t ATS_min_length;
|
uint8_t ATS_min_length;
|
||||||
|
@ -183,7 +183,7 @@ struct supported_tag {
|
||||||
* Extra members in derived classes are initialized in the correpsonding
|
* Extra members in derived classes are initialized in the correpsonding
|
||||||
* mifare_*_connect() function.
|
* mifare_*_connect() function.
|
||||||
*/
|
*/
|
||||||
struct mifare_tag {
|
struct freefare_tag {
|
||||||
nfc_device *device;
|
nfc_device *device;
|
||||||
nfc_iso14443a_info info;
|
nfc_iso14443a_info info;
|
||||||
const struct supported_tag *tag_info;
|
const struct supported_tag *tag_info;
|
||||||
|
@ -191,7 +191,7 @@ struct mifare_tag {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mifare_classic_tag {
|
struct mifare_classic_tag {
|
||||||
struct mifare_tag __tag;
|
struct freefare_tag __tag;
|
||||||
|
|
||||||
MifareClassicKeyType last_authentication_key_type;
|
MifareClassicKeyType last_authentication_key_type;
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ struct mifare_desfire_key {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mifare_desfire_tag {
|
struct mifare_desfire_tag {
|
||||||
struct mifare_tag __tag;
|
struct freefare_tag __tag;
|
||||||
|
|
||||||
uint8_t last_picc_error;
|
uint8_t last_picc_error;
|
||||||
uint8_t last_internal_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);
|
const char *mifare_desfire_error_lookup (uint8_t error);
|
||||||
|
|
||||||
struct mifare_ultralight_tag {
|
struct mifare_ultralight_tag {
|
||||||
struct mifare_tag __tag;
|
struct freefare_tag __tag;
|
||||||
|
|
||||||
/* mifare_ultralight_read() reads 4 pages at a time (wrapping) */
|
/* mifare_ultralight_read() reads 4 pages at a time (wrapping) */
|
||||||
MifareUltralightPage cache[MIFARE_ULTRALIGHT_MAX_PAGE_COUNT + 3];
|
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
|
* This macros provide a simple and unified way to perform various tests at the
|
||||||
* beginning of the different targets functions.
|
* 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)
|
#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
|
* 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_CLASSIC(tag) ((struct mifare_classic_tag *) tag)
|
||||||
#define MIFARE_DESFIRE(tag) ((struct mifare_desfire_tag *) tag)
|
#define MIFARE_DESFIRE(tag) ((struct mifare_desfire_tag *) tag)
|
||||||
|
|
|
@ -55,9 +55,9 @@ Mifare card manipulation library (libfreefare, \-lfreefare)
|
||||||
.Ft "Mad"
|
.Ft "Mad"
|
||||||
.Fn mad_new "uint8_t version"
|
.Fn mad_new "uint8_t version"
|
||||||
.Ft "Mad"
|
.Ft "Mad"
|
||||||
.Fn mad_read "MifareTag tag"
|
.Fn mad_read "FreefareTag tag"
|
||||||
.Ft "int"
|
.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"
|
.Ft "int"
|
||||||
.Fn mad_get_version "Mad mad"
|
.Fn mad_get_version "Mad mad"
|
||||||
.Ft "void"
|
.Ft "void"
|
||||||
|
|
|
@ -176,7 +176,7 @@ sector_0x10_crc8 (Mad mad)
|
||||||
* Read a MAD from the provided MIFARE tag.
|
* Read a MAD from the provided MIFARE tag.
|
||||||
*/
|
*/
|
||||||
Mad
|
Mad
|
||||||
mad_read (MifareTag tag)
|
mad_read (FreefareTag tag)
|
||||||
{
|
{
|
||||||
Mad mad = malloc (sizeof (*mad));
|
Mad mad = malloc (sizeof (*mad));
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ error:
|
||||||
* Write the mad to the provided MIFARE tad using the provided Key-B keys.
|
* Write the mad to the provided MIFARE tad using the provided Key-B keys.
|
||||||
*/
|
*/
|
||||||
int
|
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;
|
MifareClassicBlock data;
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,9 @@ Mifare card manipulation library (libfreefare, \-lfreefare)
|
||||||
.Ft "MifareClassicSectorNumber *"
|
.Ft "MifareClassicSectorNumber *"
|
||||||
.Fn mifare_application_find "Mad mad" "MadAid aid"
|
.Fn mifare_application_find "Mad mad" "MadAid aid"
|
||||||
.Ft "ssize_t"
|
.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"
|
.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"
|
||||||
.\" ____ _ _ _
|
.\" ____ _ _ _
|
||||||
.\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __
|
.\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __
|
||||||
.\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \
|
.\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \
|
||||||
|
|
|
@ -213,7 +213,7 @@ mifare_application_find (Mad mad, MadAid aid)
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t
|
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;
|
ssize_t res = 0;
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ mifare_application_read (MifareTag tag, Mad mad, const MadAid aid, void *buf, si
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t
|
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;
|
ssize_t res = 0;
|
||||||
|
|
||||||
|
|
|
@ -62,33 +62,33 @@ Mifare card manipulation library (libfreefare, \-lfreefare)
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.In freefare.h
|
.In freefare.h
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn mifare_classic_connect "MifareTag tag"
|
.Fn mifare_classic_connect "FreefareTag tag"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn mifare_classic_disconnect "MifareTag tag"
|
.Fn mifare_classic_disconnect "FreefareTag tag"
|
||||||
.Ft int
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.Ft int
|
||||||
.Fn mifare_classic_restore "MifareTag tag" "const MifareClassicBlockNumber block"
|
.Fn mifare_classic_restore "FreefareTag tag" "const MifareClassicBlockNumber block"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn mifare_classic_transfer "MifareTag tag" "const MifareClassicBlockNumber block"
|
.Fn mifare_classic_transfer "FreefareTag tag" "const MifareClassicBlockNumber block"
|
||||||
.Ft int
|
.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
|
.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
|
.Ft int
|
||||||
.Fn mifare_classic_format_sector "MifareTag tag" "const MifareClassicSectorNumber sector"
|
.Fn mifare_classic_format_sector "FreefareTag tag" "const MifareClassicSectorNumber sector"
|
||||||
.Ft void
|
.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"
|
.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
|
.Ft MifareClassicSectorNumber
|
||||||
|
|
|
@ -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_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.
|
* Allocates and initialize a MIFARE Classic tag.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MifareTag
|
FreefareTag
|
||||||
mifare_classic_tag_new (void)
|
mifare_classic_tag_new (void)
|
||||||
{
|
{
|
||||||
return malloc (sizeof (struct mifare_classic_tag));
|
return malloc (sizeof (struct mifare_classic_tag));
|
||||||
|
@ -209,7 +209,7 @@ mifare_classic_tag_new (void)
|
||||||
* Free the provided tag.
|
* Free the provided tag.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
mifare_classic_tag_free (MifareTag tag)
|
mifare_classic_tag_free (FreefareTag tag)
|
||||||
{
|
{
|
||||||
free (tag);
|
free (tag);
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ mifare_classic_tag_free (MifareTag tag)
|
||||||
* Establish connection to the provided tag.
|
* Establish connection to the provided tag.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mifare_classic_connect (MifareTag tag)
|
mifare_classic_connect (FreefareTag tag)
|
||||||
{
|
{
|
||||||
ASSERT_INACTIVE (tag);
|
ASSERT_INACTIVE (tag);
|
||||||
ASSERT_MIFARE_CLASSIC (tag);
|
ASSERT_MIFARE_CLASSIC (tag);
|
||||||
|
@ -250,7 +250,7 @@ mifare_classic_connect (MifareTag tag)
|
||||||
* Terminate connection with the provided tag.
|
* Terminate connection with the provided tag.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mifare_classic_disconnect (MifareTag tag)
|
mifare_classic_disconnect (FreefareTag tag)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_CLASSIC (tag);
|
ASSERT_MIFARE_CLASSIC (tag);
|
||||||
|
@ -276,7 +276,7 @@ mifare_classic_disconnect (MifareTag tag)
|
||||||
* Send an authentification command to the provided MIFARE target.
|
* Send an authentification command to the provided MIFARE target.
|
||||||
*/
|
*/
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_CLASSIC (tag);
|
ASSERT_MIFARE_CLASSIC (tag);
|
||||||
|
@ -307,7 +307,7 @@ mifare_classic_authenticate (MifareTag tag, const MifareClassicBlockNumber block
|
||||||
* Read data from the provided MIFARE target.
|
* Read data from the provided MIFARE target.
|
||||||
*/
|
*/
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_CLASSIC (tag);
|
ASSERT_MIFARE_CLASSIC (tag);
|
||||||
|
@ -324,7 +324,7 @@ mifare_classic_read (MifareTag tag, const MifareClassicBlockNumber block, Mifare
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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;
|
union mifare_classic_block b;
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ mifare_classic_init_value (MifareTag tag, const MifareClassicBlockNumber block,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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;
|
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.
|
* Write data to the provided MIFARE target.
|
||||||
*/
|
*/
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_CLASSIC (tag);
|
ASSERT_MIFARE_CLASSIC (tag);
|
||||||
|
@ -398,7 +398,7 @@ mifare_classic_write (MifareTag tag, const MifareClassicBlockNumber block, const
|
||||||
* data register.
|
* data register.
|
||||||
*/
|
*/
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_CLASSIC (tag);
|
ASSERT_MIFARE_CLASSIC (tag);
|
||||||
|
@ -420,7 +420,7 @@ mifare_classic_increment (MifareTag tag, const MifareClassicBlockNumber block, c
|
||||||
* data register.
|
* data register.
|
||||||
*/
|
*/
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_CLASSIC (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.
|
* Store the provided block to the internal data register.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mifare_classic_restore (MifareTag tag, const MifareClassicBlockNumber block)
|
mifare_classic_restore (FreefareTag tag, const MifareClassicBlockNumber block)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_CLASSIC (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.
|
* Store the internal data register to the provided block.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mifare_classic_transfer (MifareTag tag, const MifareClassicBlockNumber block)
|
mifare_classic_transfer (FreefareTag tag, const MifareClassicBlockNumber block)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_CLASSIC (tag);
|
ASSERT_MIFARE_CLASSIC (tag);
|
||||||
|
@ -539,7 +539,7 @@ get_block_access_bits_shift (MifareClassicBlockNumber block, MifareClassicBlockN
|
||||||
* block.
|
* block.
|
||||||
*/
|
*/
|
||||||
int
|
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
|
* 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.
|
* Get information about the trailer block.
|
||||||
*/
|
*/
|
||||||
int
|
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;
|
MifareClassicAccessBits access_bits;
|
||||||
if (get_block_access_bits (tag, block, &access_bits) < 0) {
|
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.
|
* Get information about data blocks.
|
||||||
*/
|
*/
|
||||||
int
|
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;
|
MifareClassicAccessBits access_bits;
|
||||||
if (get_block_access_bits (tag, block, &access_bits) < 0) {
|
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.
|
* Reset a MIFARE target sector to factory default.
|
||||||
*/
|
*/
|
||||||
int
|
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 first_sector_block = mifare_classic_sector_first_block (sector);
|
||||||
MifareClassicBlockNumber last_sector_block = mifare_classic_sector_last_block (sector);
|
MifareClassicBlockNumber last_sector_block = mifare_classic_sector_last_block (sector);
|
||||||
|
|
|
@ -109,125 +109,125 @@ Mifare card manipulation library (libfreefare, \-lfreefare)
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.In freefare.h
|
.In freefare.h
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn mifare_desfire_connect "MifareTag tag"
|
.Fn mifare_desfire_connect "FreefareTag tag"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn mifare_desfire_disconnect "MifareTag tag"
|
.Fn mifare_desfire_disconnect "FreefareTag tag"
|
||||||
.Ft int
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.Ft int
|
||||||
.Fn mifare_desfire_delete_application "MifareTag tag" "MifareDESFireAID aid"
|
.Fn mifare_desfire_delete_application "FreefareTag tag" "MifareDESFireAID aid"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn mifare_desfire_get_application_ids "MifareTag tag" "MifareDESFireAID *aids[]" "size_t *count"
|
.Fn mifare_desfire_get_application_ids "FreefareTag tag" "MifareDESFireAID *aids[]" "size_t *count"
|
||||||
.Ft void
|
.Ft void
|
||||||
.Fn mifare_desfire_free_application_ids "MifareDESFireAID aids[]"
|
.Fn mifare_desfire_free_application_ids "MifareDESFireAID aids[]"
|
||||||
.Ft int
|
.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
|
.Ft int
|
||||||
.Fn mifare_desfire_select_application "MifareTag tag" "MifareDESFireAID aid"
|
.Fn mifare_desfire_select_application "FreefareTag tag" "MifareDESFireAID aid"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn mifare_desfire_format_picc "MifareTag tag"
|
.Fn mifare_desfire_format_picc "FreefareTag tag"
|
||||||
.Ft int
|
.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
|
.Ft int
|
||||||
.Fn mifare_desfire_free_mem "MifareTag tag" "uint32_t *size"
|
.Fn mifare_desfire_free_mem "FreefareTag tag" "uint32_t *size"
|
||||||
.Ft int
|
.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
|
.Ft int
|
||||||
.Fn mifare_desfire_set_default_key "MifareTag tag" "MifareDESFireKey key"
|
.Fn mifare_desfire_set_default_key "FreefareTag tag" "MifareDESFireKey key"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn mifare_desfire_set_ats "MifareTag tag" "uint8_t *ats"
|
.Fn mifare_desfire_set_ats "FreefareTag tag" "uint8_t *ats"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn mifare_desfire_get_card_uid "MifareTag tag" "char **uid"
|
.Fn mifare_desfire_get_card_uid "FreefareTag tag" "char **uid"
|
||||||
.Ft int
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.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
|
.Ft int
|
||||||
.Fn mifare_desfire_commit_transaction "MifareTag tag"
|
.Fn mifare_desfire_commit_transaction "FreefareTag tag"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn mifare_desfire_abort_transaction "MifareTag tag"
|
.Fn mifare_desfire_abort_transaction "FreefareTag tag"
|
||||||
.\" ____ _ _ _
|
.\" ____ _ _ _
|
||||||
.\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __
|
.\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __
|
||||||
.\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \
|
.\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \
|
||||||
|
|
|
@ -100,11 +100,11 @@ struct mifare_desfire_raw_file_settings {
|
||||||
static struct mifare_desfire_file_settings cached_file_settings[MAX_FILE_COUNT];
|
static struct mifare_desfire_file_settings cached_file_settings[MAX_FILE_COUNT];
|
||||||
static bool cached_file_settings_current[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 authenticate (FreefareTag 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_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 (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 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 (MifareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_t length, const void *data, int cs);
|
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 (MifareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_t length, 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
|
#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 int32_t le24toh (uint8_t data[3]);
|
||||||
|
|
||||||
static int
|
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;
|
struct mifare_desfire_file_settings settings;
|
||||||
if (mifare_desfire_get_file_settings (tag, file_no, &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
|
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;
|
struct mifare_desfire_file_settings settings;
|
||||||
if (mifare_desfire_get_file_settings (tag, file_no, &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.
|
* Allocates and initialize a MIFARE DESFire tag.
|
||||||
*/
|
*/
|
||||||
MifareTag
|
FreefareTag
|
||||||
mifare_desfire_tag_new (void)
|
mifare_desfire_tag_new (void)
|
||||||
{
|
{
|
||||||
MifareTag tag;
|
FreefareTag tag;
|
||||||
if ((tag= malloc (sizeof (struct mifare_desfire_tag)))) {
|
if ((tag= malloc (sizeof (struct mifare_desfire_tag)))) {
|
||||||
MIFARE_DESFIRE (tag)->last_picc_error = OPERATION_OK;
|
MIFARE_DESFIRE (tag)->last_picc_error = OPERATION_OK;
|
||||||
MIFARE_DESFIRE (tag)->last_pcd_error = OPERATION_OK;
|
MIFARE_DESFIRE (tag)->last_pcd_error = OPERATION_OK;
|
||||||
|
@ -267,7 +267,7 @@ mifare_desfire_tag_new (void)
|
||||||
* Free the provided tag.
|
* Free the provided tag.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
mifare_desfire_tag_free (MifareTag tag)
|
mifare_desfire_tag_free (FreefareTag tag)
|
||||||
{
|
{
|
||||||
free (MIFARE_DESFIRE (tag)->session_key);
|
free (MIFARE_DESFIRE (tag)->session_key);
|
||||||
free (MIFARE_DESFIRE (tag)->crypto_buffer);
|
free (MIFARE_DESFIRE (tag)->crypto_buffer);
|
||||||
|
@ -287,7 +287,7 @@ mifare_desfire_tag_free (MifareTag tag)
|
||||||
* Establish connection to the provided tag.
|
* Establish connection to the provided tag.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mifare_desfire_connect (MifareTag tag)
|
mifare_desfire_connect (FreefareTag tag)
|
||||||
{
|
{
|
||||||
ASSERT_INACTIVE (tag);
|
ASSERT_INACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -331,7 +331,7 @@ mifare_desfire_connect (MifareTag tag)
|
||||||
* Terminate connection with the provided tag.
|
* Terminate connection with the provided tag.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mifare_desfire_disconnect (MifareTag tag)
|
mifare_desfire_disconnect (FreefareTag tag)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -352,7 +352,7 @@ mifare_desfire_disconnect (MifareTag tag)
|
||||||
#define AUTHENTICATE_AES 0xAA
|
#define AUTHENTICATE_AES 0xAA
|
||||||
|
|
||||||
static int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -439,7 +439,7 @@ authenticate (MifareTag tag, uint8_t cmd, uint8_t key_no, MifareDESFireKey key)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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) {
|
switch (key->type) {
|
||||||
case T_DES:
|
case T_DES:
|
||||||
|
@ -458,19 +458,19 @@ mifare_desfire_authenticate (MifareTag tag, uint8_t key_no, MifareDESFireKey key
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
return authenticate (tag, AUTHENTICATE_ISO, key_no, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
return authenticate (tag, AUTHENTICATE_AES, key_no, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -496,7 +496,7 @@ mifare_desfire_change_key_settings (MifareTag tag, uint8_t settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -525,7 +525,7 @@ mifare_desfire_get_key_settings (MifareTag tag, uint8_t *settings, uint8_t *max_
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (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.
|
* Retrieve version information for a given key.
|
||||||
*/
|
*/
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (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
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -706,43 +706,43 @@ create_application (MifareTag tag, MifareDESFireAID aid, uint8_t settings1, uint
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
return create_application (tag, aid, settings, key_no, 0, 0, 0, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
return create_application (tag, aid, settings, key_no, 1, want_iso_file_identifiers, iso_file_id, iso_file_name, iso_file_name_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
return create_application (tag, aid, settings, APPLICATION_CRYPTO_3K3DES | key_no, 0, 0, 0, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
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
|
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);
|
return create_application (tag, aid, settings, APPLICATION_CRYPTO_AES | key_no, 0, 0, 0, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
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
|
int
|
||||||
mifare_desfire_delete_application (MifareTag tag, MifareDESFireAID aid)
|
mifare_desfire_delete_application (FreefareTag tag, MifareDESFireAID aid)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -777,7 +777,7 @@ mifare_desfire_delete_application (MifareTag tag, MifareDESFireAID aid)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -833,7 +833,7 @@ mifare_desfire_get_application_ids (MifareTag tag, MifareDESFireAID *aids[], siz
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (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).
|
* NULL, the master application is selected (equivalent to aid = 0x00000).
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mifare_desfire_select_application (MifareTag tag, MifareDESFireAID aid)
|
mifare_desfire_select_application (FreefareTag tag, MifareDESFireAID aid)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -921,7 +921,7 @@ mifare_desfire_select_application (MifareTag tag, MifareDESFireAID aid)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mifare_desfire_format_picc (MifareTag tag)
|
mifare_desfire_format_picc (FreefareTag tag)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -953,7 +953,7 @@ mifare_desfire_format_picc (MifareTag tag)
|
||||||
* Retrieve version information form the PICC.
|
* Retrieve version information form the PICC.
|
||||||
*/
|
*/
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -991,7 +991,7 @@ mifare_desfire_get_version (MifareTag tag, struct mifare_desfire_version_info *v
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mifare_desfire_free_mem (MifareTag tag, uint32_t *size)
|
mifare_desfire_free_mem (FreefareTag tag, uint32_t *size)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -1019,7 +1019,7 @@ mifare_desfire_free_mem (MifareTag tag, uint32_t *size)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -1045,7 +1045,7 @@ mifare_desfire_set_configuration (MifareTag tag, bool disable_format, bool enabl
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mifare_desfire_set_default_key (MifareTag tag, MifareDESFireKey key)
|
mifare_desfire_set_default_key (FreefareTag tag, MifareDESFireKey key)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -1085,7 +1085,7 @@ mifare_desfire_set_default_key (MifareTag tag, MifareDESFireKey key)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mifare_desfire_set_ats (MifareTag tag, uint8_t *ats)
|
mifare_desfire_set_ats (FreefareTag tag, uint8_t *ats)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -1122,7 +1122,7 @@ mifare_desfire_set_ats (MifareTag tag, uint8_t *ats)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mifare_desfire_get_card_uid (MifareTag tag, char **uid)
|
mifare_desfire_get_card_uid (FreefareTag tag, char **uid)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -1160,7 +1160,7 @@ mifare_desfire_get_card_uid (MifareTag tag, char **uid)
|
||||||
/* Application level commands */
|
/* Application level commands */
|
||||||
|
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -1193,7 +1193,7 @@ mifare_desfire_get_file_ids (MifareTag tag, uint8_t **files, size_t *count)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -1241,7 +1241,7 @@ mifare_desfire_get_iso_file_ids (MifareTag tag, uint16_t **files, size_t *count)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -1300,7 +1300,7 @@ mifare_desfire_get_file_settings (MifareTag tag, uint8_t file_no, struct mifare_
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (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
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (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
|
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);
|
return create_file1 (tag, 0xCD, file_no, 0, 0x0000, communication_settings, access_rights, file_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
return create_file1 (tag, 0xCD, file_no, 1, iso_file_id, communication_settings, access_rights, file_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
return create_file1 (tag, 0xCB, file_no, 0, 0x0000, communication_settings, access_rights, file_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
return create_file1 (tag, 0xCB, file_no, 1, iso_file_id, communication_settings, access_rights, file_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (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
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (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
|
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);
|
return create_file2 (tag, 0xC1, file_no, 0, 0x0000, communication_settings, access_rights, record_size, max_number_of_records);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
return create_file2 (tag, 0xC1, file_no, 1, iso_file_id, communication_settings, access_rights, record_size, max_number_of_records);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
return create_file2 (tag, 0xC0, file_no, 0, 0x000, communication_settings, access_rights, record_size, max_number_of_records);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
return create_file2 (tag, 0xC0, file_no, 1, iso_file_id, communication_settings, access_rights, record_size, max_number_of_records);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -1529,7 +1529,7 @@ mifare_desfire_delete_file (MifareTag tag, uint8_t file_no)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static ssize_t
|
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;
|
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
|
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));
|
return mifare_desfire_read_data_ex (tag, file_no, offset, length, data, madame_soleil_get_read_communication_settings (tag, file_no));
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t
|
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);
|
return read_data (tag, 0xBD, file_no, offset, length, data, cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
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_left;
|
||||||
size_t bytes_send = 0;
|
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
|
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));
|
return mifare_desfire_write_data_ex (tag, file_no, offset, length, data, madame_soleil_get_write_communication_settings (tag, file_no));
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t
|
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);
|
return write_data (tag, 0x3D, file_no, offset, length, data, cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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));
|
return mifare_desfire_get_value_ex (tag, file_no, value, madame_soleil_get_read_communication_settings (tag, file_no));
|
||||||
}
|
}
|
||||||
int
|
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)
|
if (!value)
|
||||||
return errno = EINVAL, -1;
|
return errno = EINVAL, -1;
|
||||||
|
@ -1762,13 +1762,13 @@ mifare_desfire_get_value_ex (MifareTag tag, uint8_t file_no, int32_t *value, int
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
return mifare_desfire_credit_ex (tag, file_no, amount, madame_soleil_get_write_communication_settings (tag, file_no));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (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
|
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));
|
return mifare_desfire_debit_ex (tag, file_no, amount, madame_soleil_get_write_communication_settings (tag, file_no));
|
||||||
}
|
}
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (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
|
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));
|
return mifare_desfire_limited_credit_ex (tag, file_no, amount, madame_soleil_get_write_communication_settings (tag, file_no));
|
||||||
}
|
}
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (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
|
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));
|
return mifare_desfire_write_record_ex (tag, file_no, offset, length, data, madame_soleil_get_write_communication_settings (tag, file_no));
|
||||||
}
|
}
|
||||||
ssize_t
|
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);
|
return write_data (tag, 0x3B, file_no, offset, length, data, cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t
|
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));
|
return mifare_desfire_read_records_ex (tag, file_no, offset, length, data, madame_soleil_get_read_communication_settings (tag, file_no));
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t
|
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);
|
return read_data (tag, 0xBB, file_no, offset, length, data, cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -1912,7 +1912,7 @@ mifare_desfire_clear_record_file (MifareTag tag, uint8_t file_no)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mifare_desfire_commit_transaction (MifareTag tag)
|
mifare_desfire_commit_transaction (FreefareTag tag)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
@ -1936,7 +1936,7 @@ mifare_desfire_commit_transaction (MifareTag tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mifare_desfire_abort_transaction (MifareTag tag)
|
mifare_desfire_abort_transaction (FreefareTag tag)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
|
|
@ -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.
|
* Buffer size required to encipher nbytes of data and a two bytes CRC.
|
||||||
*/
|
*/
|
||||||
size_t
|
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;
|
size_t crc_length = 0;
|
||||||
if (!(communication_settings & NO_CRC)) {
|
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.
|
* Ensure that tag's crypto buffer is large enough to store nbytes of data.
|
||||||
*/
|
*/
|
||||||
void *
|
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;
|
void *res = MIFARE_DESFIRE (tag)->crypto_buffer;
|
||||||
if (MIFARE_DESFIRE (tag)->crypto_buffer_size < nbytes) {
|
if (MIFARE_DESFIRE (tag)->crypto_buffer_size < nbytes) {
|
||||||
|
@ -296,7 +296,7 @@ assert_crypto_buffer_size (MifareTag tag, size_t nbytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
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 *res = data;
|
||||||
uint8_t mac[4];
|
uint8_t mac[4];
|
||||||
|
@ -435,7 +435,7 @@ mifare_cryto_preprocess_data (MifareTag tag, void *data, size_t *nbytes, off_t o
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
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;
|
void *res = data;
|
||||||
size_t edl;
|
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.
|
* function with tag, key and ivect defined.
|
||||||
*/
|
*/
|
||||||
void
|
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;
|
size_t block_size;
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ mifare_desfire_error_lookup (uint8_t code)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t
|
uint8_t
|
||||||
mifare_desfire_last_pcd_error (MifareTag tag)
|
mifare_desfire_last_pcd_error (FreefareTag tag)
|
||||||
{
|
{
|
||||||
if (tag->tag_info->type != DESFIRE)
|
if (tag->tag_info->type != DESFIRE)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -81,7 +81,7 @@ mifare_desfire_last_pcd_error (MifareTag tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t
|
uint8_t
|
||||||
mifare_desfire_last_picc_error (MifareTag tag)
|
mifare_desfire_last_picc_error (FreefareTag tag)
|
||||||
{
|
{
|
||||||
if (tag->tag_info->type != DESFIRE)
|
if (tag->tag_info->type != DESFIRE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -47,13 +47,13 @@ Mifare card manipulation library (libfreefare, \-lfreefare)
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.In freefare.h
|
.In freefare.h
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn mifare_ultralight_connect "MifareTag tag"
|
.Fn mifare_ultralight_connect "FreefareTag tag"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn mifare_ultralight_disconnect "MifareTag tag"
|
.Fn mifare_ultralight_disconnect "FreefareTag tag"
|
||||||
.Ft int
|
.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
|
.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"
|
||||||
.\" ____ _ _ _
|
.\" ____ _ _ _
|
||||||
.\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __
|
.\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __
|
||||||
.\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \
|
.\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \
|
||||||
|
|
|
@ -99,7 +99,7 @@
|
||||||
/*
|
/*
|
||||||
* Allocates and initialize a MIFARE UltraLight tag.
|
* Allocates and initialize a MIFARE UltraLight tag.
|
||||||
*/
|
*/
|
||||||
MifareTag
|
FreefareTag
|
||||||
mifare_ultralight_tag_new (void)
|
mifare_ultralight_tag_new (void)
|
||||||
{
|
{
|
||||||
return malloc (sizeof (struct mifare_ultralight_tag));
|
return malloc (sizeof (struct mifare_ultralight_tag));
|
||||||
|
@ -109,7 +109,7 @@ mifare_ultralight_tag_new (void)
|
||||||
* Free the provided tag.
|
* Free the provided tag.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
mifare_ultralight_tag_free (MifareTag tag)
|
mifare_ultralight_tag_free (FreefareTag tag)
|
||||||
{
|
{
|
||||||
free (tag);
|
free (tag);
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ mifare_ultralight_tag_free (MifareTag tag)
|
||||||
* Establish connection to the provided tag.
|
* Establish connection to the provided tag.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mifare_ultralight_connect (MifareTag tag)
|
mifare_ultralight_connect (FreefareTag tag)
|
||||||
{
|
{
|
||||||
ASSERT_INACTIVE (tag);
|
ASSERT_INACTIVE (tag);
|
||||||
ASSERT_MIFARE_ULTRALIGHT (tag);
|
ASSERT_MIFARE_ULTRALIGHT (tag);
|
||||||
|
@ -153,7 +153,7 @@ mifare_ultralight_connect (MifareTag tag)
|
||||||
* Terminate connection with the provided tag.
|
* Terminate connection with the provided tag.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mifare_ultralight_disconnect (MifareTag tag)
|
mifare_ultralight_disconnect (FreefareTag tag)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_ULTRALIGHT (tag);
|
ASSERT_MIFARE_ULTRALIGHT (tag);
|
||||||
|
@ -179,7 +179,7 @@ mifare_ultralight_disconnect (MifareTag tag)
|
||||||
* Read data from the provided MIFARE tag.
|
* Read data from the provided MIFARE tag.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mifare_ultralight_read (MifareTag tag, MifareUltralightPageNumber page, MifareUltralightPage *data)
|
mifare_ultralight_read (FreefareTag tag, MifareUltralightPageNumber page, MifareUltralightPage *data)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_ULTRALIGHT (tag);
|
ASSERT_MIFARE_ULTRALIGHT (tag);
|
||||||
|
@ -219,7 +219,7 @@ mifare_ultralight_read (MifareTag tag, MifareUltralightPageNumber page, MifareUl
|
||||||
* Read data to the provided MIFARE tag.
|
* Read data to the provided MIFARE tag.
|
||||||
*/
|
*/
|
||||||
int
|
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_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_ULTRALIGHT (tag);
|
ASSERT_MIFARE_ULTRALIGHT (tag);
|
||||||
|
@ -244,7 +244,7 @@ mifare_ultralight_write (MifareTag tag, const MifareUltralightPageNumber page, c
|
||||||
* Authenticate to the provided MIFARE tag.
|
* Authenticate to the provided MIFARE tag.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mifare_ultralightc_authenticate (MifareTag tag, const MifareDESFireKey key)
|
mifare_ultralightc_authenticate (FreefareTag tag, const MifareDESFireKey key)
|
||||||
{
|
{
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_ULTRALIGHT_C (tag);
|
ASSERT_MIFARE_ULTRALIGHT_C (tag);
|
||||||
|
|
|
@ -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;
|
const uint8_t key_data_aes_version = 0x42;
|
||||||
|
|
||||||
void
|
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 */
|
/* Determine which key is currently the master one */
|
||||||
uint8_t key_version;
|
uint8_t key_version;
|
||||||
|
|
|
@ -27,6 +27,6 @@ extern uint8_t key_data_aes[16];
|
||||||
extern uint8_t key_data_3k3des[24];
|
extern uint8_t key_data_3k3des[24];
|
||||||
extern const uint8_t key_data_aes_version;
|
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
|
#endif
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
static nfc_context *context;
|
static nfc_context *context;
|
||||||
static nfc_device *device = NULL;
|
static nfc_device *device = NULL;
|
||||||
static MifareTag *tags = NULL;
|
static FreefareTag *tags = NULL;
|
||||||
MifareTag tag = NULL;
|
FreefareTag tag = NULL;
|
||||||
|
|
||||||
void
|
void
|
||||||
cut_setup (void)
|
cut_setup (void)
|
||||||
|
|
|
@ -17,4 +17,4 @@
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern MifareTag tag;
|
extern FreefareTag tag;
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
static nfc_context *context;
|
static nfc_context *context;
|
||||||
static nfc_device *device = NULL;
|
static nfc_device *device = NULL;
|
||||||
static MifareTag *tags = NULL;
|
static FreefareTag *tags = NULL;
|
||||||
MifareTag tag = NULL;
|
FreefareTag tag = NULL;
|
||||||
|
|
||||||
void
|
void
|
||||||
cut_setup (void)
|
cut_setup (void)
|
||||||
|
|
|
@ -17,4 +17,4 @@
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern MifareTag tag;
|
extern FreefareTag tag;
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
static nfc_context *context;
|
static nfc_context *context;
|
||||||
static nfc_device *device = NULL;
|
static nfc_device *device = NULL;
|
||||||
static MifareTag *tags = NULL;
|
static FreefareTag *tags = NULL;
|
||||||
MifareTag tag = NULL;
|
FreefareTag tag = NULL;
|
||||||
|
|
||||||
void
|
void
|
||||||
cut_setup (void)
|
cut_setup (void)
|
||||||
|
|
|
@ -17,4 +17,4 @@
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern MifareTag tag;
|
extern FreefareTag tag;
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
static nfc_context *context;
|
static nfc_context *context;
|
||||||
static nfc_device *device = NULL;
|
static nfc_device *device = NULL;
|
||||||
static MifareTag *tags = NULL;
|
static FreefareTag *tags = NULL;
|
||||||
MifareTag tag = NULL;
|
FreefareTag tag = NULL;
|
||||||
|
|
||||||
void
|
void
|
||||||
cut_setup (void)
|
cut_setup (void)
|
||||||
|
|
|
@ -17,4 +17,4 @@
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern MifareTag tag;
|
extern FreefareTag tag;
|
||||||
|
|
Loading…
Reference in a new issue