MAD(3)
β¨ NAME β¨
okay so meet the whole girlboss squad π
β 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 β and together? they're the Mifare Application Directory (MAD) Manipulation Functions. no cap. π
π LIBRARY π
it's the Mifare card manipulation library, bestie β that's libfreefare, and you link it with -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) are genuinely so easy to mess with when you've got the mad_*() function set in your corner. it's giving organized. β¨
you can load a mad straight off a Mifare Classic tag with mad_read(), or you can manifest one from literally nothing with mad_new() β just hand it the version of the mad you want generated. and once you're done with your mad, give that memory back to the universe with mad_free(). recycle, bestie π«Ά
want to write a mad onto a Mifare Classic tag? that's mad_write(), and it needs the B keys for writing to sectors 0 and 10: key_b_sector_00 for sectors 0, and key_b_sector_10 for sectors 10. π
okay so about MAD version 1 mad writing... the original page says, and I quote, "When writing a MAD version 1 mad, the key_b_sector_10." that's it. that's the whole sentence. it just ends there π not me reading it five times. I'm not gonna invent the rest for you β what you see is what you get, fr fr.
the version of a MAD mad β get it with mad_get_version(), change it with mad_set_version(). π
the card publisher sector number cps β read it with mad_get_card_publisher_sector(), write it with mad_set_card_publisher_sector(). π
sector allocation inside the mad is all handled by mad_get_aid() and mad_set_aid(). these cuties fill in, or read out, the Application Identifier, aid, for whatever sector you point them at. π―
π«Ά RETURN VALUES π«Ά
mad_new()hands backNULLwhen it fails β and when it slays? it allocates memory you have to free later withmad_free(). don't leave her hanging. π- unless it says otherwise, every other function returns a value greater than or equal to
0on success, or-1on failure. that's the whole vibe check. β
π SEE ALSO π
freefare(3), mifare_application(3), mifare_classic(3)
iykyk π
π AUTHORS π
- Romain Tartiere
<romain@blogreen.org> - Romuald Conty
<romuald@libnfc.org>
absolute icons, both of them, periodt. π
and that's the page bestie!! this one came from Debian, dated March 30, 2010, and it's the MAD(3) entry in the Library Functions Manual. go forth and manipulate some Mifare Application Directories πΈπ
β¨
π¦ where this page comes from
- debian bookworm: libfreefare-doc 0.4.0-2.1 Β· LGPL-3.0-or-later
- debian trixie: libfreefare-doc 0.4.0-2.3 Β· LGPL-3.0-or-later
- nixos 26.05: libfreefare 0.4.0
- nixpkgs unstable: libfreefare 0.4.0
- ubuntu jammy: libfreefare-doc 0.4.0-2.1build1 Β· LGPL-3.0-or-later
- ubuntu noble: libfreefare-doc 0.4.0-2.3build2 Β· LGPL-3.0-or-later
- ubuntu questing: libfreefare-doc 0.4.0-2.3build2
- ubuntu resolute: libfreefare-doc 0.4.0-2.3build3 Β· LGPL-3.0-or-later
- ubuntu stonking: libfreefare-doc 0.4.0-2.4build1 Β· LGPL-3.0-or-later
- Copyright (C) 2010 Romain Tartiere
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms