Scroll to navigation

MAD(3) Library Functions Manual MAD(3)

NAME

mad_new, mad_read, mad_write, mad_get_version, mad_set_version, mad_get_card_publisher_sector, mad_set_card_publisher_sector, mad_get_aid, mad_set_aid, mad_free, — Mifare Application Directory (MAD) Manipulation Functions

LIBRARY

Mifare card manipulation library (libfreefare, -lfreefare)

SYNOPSIS

#include <freefare.h>

Mad
mad_new(uint8_t version);

Mad
mad_read(MifareTag tag);

int
mad_write(MifareTag tag, Mad mad, MifareClassicKey key_b_sector_00, MifareClassicKey key_b_sector_10);

int
mad_get_version(Mad mad);

void
mad_set_version(Mad mad, uint8_t version);

MifareClassicSectorNumber
mad_get_card_publisher_sector(Mad mad);

int
mad_set_card_publisher_sector(Mad mad, MifareClassicSectorNumber cps);

int
mad_get_aid(Mad mad, MifareClassicSectorNumber sector, MadAid *aid);

int
mad_set_aid(Mad mad, MifareClassicSectorNumber sector, MadAid aid);

void
mad_free(Mad mad);

DESCRIPTION

Mifare Application Directories (MAD) can be easily manipulated using the () set of functions.

A mad can be loaded form a Mifare Classic tag using () or generated from scratch using () and providing the version of the mad to generate. After using a mad, the memory can be reclaimed using ().

A mad can be written to a Mifare Classic tag using () and providing the B keys required for writing to sectors 0, key_b_sector_00, and the one required for writing to sectors 10, key_b_sector_10. When writing a MAD version 1 mad, the key_b_sector_10.

The version of a MAD mad can be read using () and changed using ().

The card publisher sector number cps can be read read using () and writen using ().

Sectors allocation in the mad is handled by the () and () functions. These functions fill-in or read the Application Identifier, aid for the given sector.

RETURN VALUES

The mad_new() function return NULL on failure and allocates memory that has to be freed using mad_free() on success. Unless stated otherwise, all other functions return a value greater than or equal to 0 on success or -1 on failure.

SEE ALSO

freefare(3), mifare_application(3), mifare_classic(3)

AUTHORS

Romain Tartiere ⟨romain@blogreen.org⟩
Romuald Conty ⟨romuald@libnfc.org⟩

March 30, 2010 Debian