mifare_classic_connect(3) mifare_classic_authenticate

Other Alias

mifare_classic_disconnect

LIBRARY

Mifare card manipulation library (libfreefare, -lfreefare)

SYNOPSIS

In freefare.h Ft int Fn mifare_classic_connect MifareTag tag Ft int Fn mifare_classic_disconnect MifareTag tag Ft int Fn mifare_classic_authenticate MifareTag tag const MifareClassicBlockNumber block const MifareClassicKey key const MifareClassicKeyType key_type Ft int Fn mifare_classic_read MifareTag tag const MifareClassicBlockNumber block MifareClassicBlock *data Ft int Fn mifare_classic_init_value MifareTag tag const MifareClassicBlockNumber block const int32_t value const MifareClassicBlockNumber adr Ft int Fn mifare_classic_read_value MifareTag tag const MifareClassicBlockNumber block int32_t *value MifareClassicBlockNumber *adr Ft int Fn mifare_classic_write MifareTag tag const MifareClassicBlockNumber block const MifareClassicBlock data Ft int Fn mifare_classic_increment MifareTag tag const MifareClassicBlockNumber block const uint32_t amount Ft int Fn mifare_classic_decrement MifareTag tag const MifareClassicBlockNumber block const uint32_t amount Ft int Fn mifare_classic_restore MifareTag tag const MifareClassicBlockNumber block Ft int Fn mifare_classic_transfer MifareTag tag const MifareClassicBlockNumber block Ft int Fn mifare_classic_get_trailer_block_permission MifareTag tag const MifareClassicBlockNumber block const uint16_t permission const MifareClassicKeyType key_type Ft int Fn mifare_classic_get_data_block_permission MifareTag tag const MifareClassicBlockNumber block const unsigned char permission const MifareClassicKeyType key_type Ft int Fn mifare_classic_format_sector MifareTag tag const MifareClassicSectorNumber sector 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 Ft MifareClassicSectorNumber Fn mifare_classic_block_sector MifareClassicBlockNumber block Ft MifareClassicBlockNumber Fn mifare_classic_sector_first_block MifareClassicSectorNumber sector Ft size_t Fn mifare_classic_sector_block_count MifareClassicSectorNumber sector Ft MifareClassicBlockNumber Fn mifare_classic_sector_last_block MifareClassicSectorNumber sector

DESCRIPTION

The Fn mifare_classic_* set of functions allow manipulation of both Mifare Classic 1k and Mifare Classic 4k cards.

A given Vt tag is activated using Fn mifare_classic_connect , deactivation is performed with Fn mifare_classic_disconnect .

After a successful connection, an authentication for a Vt block using a Vt key of type Vt key_type (either MFC_KEY_A or MFC_KEY_B using Fn mifare_classic_authenticate is required for further operation.

Once successfuly authenticated, Vt data of a Vt block can be read using Fn mifare_classic_read and written using Fn mifare_classic_write .

Value-blocks can be easily accessed using the Fn mifare_classic_read_value and Fn mifare_classic_init_value functions. Additional functions are available for such Vt blocks : Fn mifare_classic_increment and Fn mifare_classic_decrement increment or decrement the value of the provided Vt block by Vt amount and store the result in the target's internal data register. The value in this register can also be loaded with the value from another Vt block using Fn mifare_classic_restore . Writing back the value of the target's internal data register to a Vt block is requested using Fn mifare_classic_transfer .

Permissions for a data Vt block can be fetched using Fn mifare_classic_get_data_block_permission . The access Vt permission to be checkf for key Vt key_type is one of MCAB_R MCAB_W MCAB_I or MCAB_D respectively for read, write, increment and decrement permissions.

Fn mifare_classic_get_trailer_block_permission acts like Fn mifare_classic_get_data_block_permission but the available Vt permissions are MCAB_READ_KEYA MCAB_READ_KEYB MCAB_READ_ACCESS_BITS MCAB_WRITE_ACCESS_BITS MCAB_READ_KEYB and MCAB_WRITE_KEYB

A whole sector can be reset to factory defaults using Fn mifare_classic_format_sector .

The Fn mifare_classic_trailer_block is a convenience function for building a trailer block Vt block given a A key Vt key_a ; access bits for the blocks of the sector Vt ab_0 , Vt ab_1 and Vt ab_2 ; and a B key Vt key_b .

The Fn mifare_classic_block_sector , function returns the number of the sector holding block

The Fn mifare_classic_sector_first_block , Fn mifare_classic_sector_block_count , Fn mifare_classic_sector_last_block or the complement of the Fn mifare_classic_block_sector function and return various block-level information about the provided sector

RETURN VALUES

Unless stated otherwise, all functions return a value greater than or equal to 0 on success or -1 on failure.

AUTHORS

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