carta
mifare_classic_transfer(3)

mifare_classic_transfer3

Mifare classic manipulation functions

Part of mifare_classic(3).

Usage

int

int

int

int

int

int

int

int

int

int

int

int

int

int

void

MifareClassicSectorNumber

MifareClassicBlockNumber

size_t

MifareClassicBlockNumber

Library

Mifare card manipulation library (libfreefare, -lfreefare)

Overview

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

A given tag is activated using mifare_classic_connect(), deactivation is performed with mifare_classic_disconnect().

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

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

Value-blocks can be easily accessed using the mifare_classic_read_value() and mifare_classic_init_value() functions. Additional functions are available for such blocks: mifare_classic_increment() and mifare_classic_decrement() increment or decrement the value of the provided block by 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 block using mifare_classic_restore(). Writing back the value of the target's internal data register to a block is requested using mifare_classic_transfer().

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

mifare_classic_get_trailer_block_permission() acts like mifare_classic_get_data_block_permission() but the available 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 mifare_classic_format_sector().

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

The mifare_classic_block_sector(), function returns the number of the sector holding block.

The mifare_classic_sector_first_block(), mifare_classic_sector_block_count(), mifare_classic_sector_last_block() or the complement of the 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

Romain Tartiere ⟨[email protected]⟩ Romuald Conty ⟨[email protected]⟩

From libfreefare-doc 0.4.0-2.3 in Debian 13 (Trixie). Parsed by carta from the page's mdoc source.