The MIFARE CLASSIC WRITE instructions writes data onto a Mifare Classic card (e.g. Mifare 1K or Mifare 4K). It is also suitable to write data from a Mifare Plus card, provided that the card is in Security Level 1.

The difference with the UPDATE BINARY instruction lies in the simplified implementation of the Mifare Classic authentication scheme (CRYPTO1). With UPDATE BINARY, the authentication must be performed beforehand and explicitly using the GENERAL AUTHENTICATE instruction with a key previously provided thanks to the LOAD KEY instruction.

On the other hand, MIFARE CLASSIC WRITE provides two interesting shortcuts:

  • In “try all keys” mode, the authentication is either performed automatically by the SpringCore device, trying all the known key one after the other until success. This frees the application from the burden of trying every key one after the other.
  • In “use this key” mode, the applications provides the (expected) value of the key within the instruction. This is the same as LOAD KEY / GENERAL AUTHENTICATE / READ BINARY but in a single call.

Command format

‘Try all keys’ mode

Field Value Remark
P1 00
P2 Block number
Lc Length of DataIn Possible values are 10, 30 or F0 only
DataIn Data to write onto the card Can’t be empty
Le absent

‘Use this key’ mode

Field Value Remark
P1 00
P2 Block Number
Lc Length of DataIn Possible values are 10, 30 or F0 only
DataIn Data to write onto the card (16, 48 or 240 bytes)
Key Value (6 bytes)
Can’t be empty
Le absent

In this mode the application specifies the value of the key.

The device tries to get authenticate with the supplied key with a type B authentication. Only if it fails it tries type A authentication.

Note: this is the opposite order as for MIFARE CLASSIC READ since in most of the implementations, the A key gives read-only access and the B key gives read-write access.

About the size of the Data

This instruction is able to write either 1 block (16 bytes), 1 sector (3 blocks) or 1 large sector (15 blocks). This instruction can not cross the sector boundaries, hence the limited range for Lc.



Field Value
SW 9000

Typical status words upon error

SW Explanation
6F01 The card has been removed / communication error
6F04 Authentication failed / no suitable key
6F0F Authentication OK but block not writable