Mifare authentication string

Forum / MIFARE general topics and applications / Mifare authentication string

  • 2. August 2017 at 9:24
    Hello,
    I'm having a small problem understanding a code, and i couldn't find the answer... And i want to understand how it works.

    The problem so far:
    The lack of resources forced me to do the following procedure.
    I want to write an authentication code in sector12, with a key ( A or B ). the key i wrote with Mifare classic tool, which i dumped with an android phone to a mifare card classic of 1k, but i am having trouble sending through the serial port, the authentication string which is in byte... and i have no clue on how to send it, all i know is that i have to send i'm guessing 7 groups of bytes ?!?!

    Can someone tell me how should it look like ?

    And how do i send the "read" command for the block 0 and/or 1 of that sector ?

    thanks

    + 0  |  - 0

    Re: Mifare authentication string

    2. August 2017 at 13:17
    Hi,

    When you write “I want to write an authentication code in sector12” then this are private data and has nothing to do with the authentication to the MIFARE Classic. Generally, if you want to write or read from sectors 0, 1, 2 or 3, you have to authenticate first to one of this sectors. E.g.: Authenticate to sector 0, then read from sector 0 (or 1, 2 or 3).

    The blank card has default keys (0xFFFFFFFFFFFF). The last action you should do is to authenticate with the default key and write a new key value to the sector trailer. All further accesses must use the new key value for authentication.

    Regards,
    The TapLinx team

    + 0  |  - 0

    Re: Mifare authentication string

    2. August 2017 at 13:48
    Ok, in agreement here, but in C# the code for doing the authentication is a tad different, What bytes do i need to send to the serial interface to log in ?

    i always get 01 00 15 01 09 76 D0 ... reading all the manuals , i can't get for the likes of it any date out of this...

    The code is below

    public void AuthSector12()
    {
    try
    {
    byte[] array = new byte[]
    {
    // what do i put here ?
    };

    SerialPort1.Write(array, 0, 8);
    Thread.Sleep(25);
    string text = "";
    int bytesToRead = SerialPort1.BytesToRead;
    byte[] array2 = new byte[bytesToRead];
    SerialPort1.Read(array2, 0, bytesToRead);
    for (int i = 0; i < bytesToRead; i++)
    {
    uint num = Convert.ToUInt32(array2);
    text = text + string.Format("{0:x2}", num).ToUpper() + " ";
    }
    }
    catch (Exception)
    {
    }
    }
    + 0  |  - 0

    Re: Mifare authentication string

    3. August 2017 at 1:38
    Hi,

    Authenticating with MIFARE Classic is a process comprised by three stages.
    1. You should SELECT the Card in RF field from the reader
    2. AUTHENTICATING TO A SECTOR (16 in a 1K MIFARE Classic Card) with a properly key (The so called "transport key" by default, is 0xff ff ff ff ff ff -six bytes long-)
    3. READING AND/OR WRITING FROM/TO A REGISTER of 16 Bytes (3 effective register for data by sector, except the sector 0, which has 2 effective records, because the firs one is a read only Manufacturer Block; and one sector trailer record, in which the secrets key and the sector access conditions bits resides).

    NOTE1: The authentication process should be done every time you need change from one sector to another.
    NOTE2: The select process should be done every time the authentication process fails.
    NOTE3: Each reader has its own command syntax.

    To write an interfase you should have acces: to the reader commands protocol, to the command set of the reader, and of course, the datasheet of the Card. (A good staring point is the MF1 IC S50 Functional specifications).

    Regards,
    Claudio


    + 0  |  - 0

    Re: Mifare authentication string

    3. August 2017 at 7:23
    Thanks Claudio,
    I'll start with the Functional Specs you told me, and i will contact the producer of reader, to help me with the commands.

    + 0  |  - 0

    Re: Mifare authentication string

    3. August 2017 at 10:48
    Hi,

    First of all: excellent answer Claudio!

    Generally the byte commands you sent are translated in the NFC interface driver. Every reader manufacturer do it in its own way. In most cases you also need the user manual of the reader manufacturer to check how the APDU command are wrapped.

    The TapLinx team

    + 0  |  - 0
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.