mad_read(3) mad_get_card_publisher_sector

Other Alias

mad_new, mad_write, mad_get_version, mad_set_version


Mifare card manipulation library (libfreefare, -lfreefare)


In freefare.h Ft Mad Fn mad_new uint8_t version Ft Mad Fn mad_read MifareTag tag Ft int Fn mad_write MifareTag tag Mad mad MifareClassicKey key_b_sector_00 MifareClassicKey key_b_sector_10 Ft int Fn mad_get_version Mad mad Ft void Fn mad_set_version Mad mad uint8_t version Ft MifareClassicSectorNumber Fn mad_get_card_publisher_sector Mad mad Ft int Fn mad_set_card_publisher_sector Mad mad MifareClassicSectorNumber cps Ft int Fn mad_get_aid Mad mad MifareClassicSectorNumber sector MadAid *aid Ft int Fn mad_set_aid Mad mad MifareClassicSectorNumber sector MadAid aid Ft void Fn mad_free Mad mad


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

A Vt mad can be loaded form a Mifare Classic Vt tag using Fn mad_read or generated from scratch using Fn mad_new and providing the Vt version of the Vt mad to generate. After using a Vt mad , the memory can be reclaimed using Fn mad_free .

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

The Vt version of a MAD Vt mad can be read using Fn mad_get_version and changed using Fn mad_set_version .

The card publisher sector number Vt cps can be read read using Fn mad_get_card_publisher_sector and writen using Fn mad_set_card_publisher_sector .

Sectors allocation in the Vt mad is handled by the Fn mad_get_aid and Fn mad_set_aid functions. These functions fill-in or read the Application Identifier, Vt aid for the given Vt sector .


The Fn mad_new function return NULL on failure and allocates memory that has to be freed using Fn 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.


An Romain Tartiere Aq [email protected] An Romuald Conty Aq [email protected]