Man page - mad_write(3)

Packages contains this manual

Manual


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 mad_* () set of functions.

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

A mad can be written to a Mifare Classic tag using mad_write () 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 mad_get_version () and changed using mad_set_version ().

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

Sectors allocation in the mad is handled by the mad_get_aid () and mad_set_aid () 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> Debian March 30, 2010 MAD (3)