How to encrypt Sector 1 Data Values?

Forum / MIFARE SDK / How to encrypt Sector 1 Data Values?

  • 16. May 2016 at 7:08
    Hi,
    I have a mifare 1k card. I already set my Sector Trailer Keys.
    With Key A and B I can read my data from card. And with Key B I can write my data into the card.
    Now I need some encryption method to encrypt my data values. My data values is 16 characters so the encryption method output must also be 16 characters. How can I do that.

    Example:
    I need my data [1234567890123456 ] to encrypt with and shows like this: [As34FGdd961RtYh4 ]

    1 3 [-------KEY A-------] [Access Bits] [-------KEY B-------] Sector Trailer
    2 [1234567890123456 ] Data (16 characters)
    1 [1234 ] Data (16 characters)
    0 [GOLD ] Data (16 characters)

    Kind Regards,
    + 0  |  - 0

    Re: How to encrypt Sector 1 Data Values?

    16. May 2016 at 20:19
    Hi,

    Each block Mifare Classic 1KB, has 16 bytes long (128 bits), so that it is possible to use any method for convenience 128 bit encryption.

    Among the most used you could do with 3DES or AES, but I would be inclined to use AES. These algorithms allow use as Data multiples of 16 bytes in length and the key should be 16 bytes in length.

    You should only be used as Data encryption block of 16 bytes and should preferably use a key that is diversified by the uid and block number. This will see different cards in different data for the same message.

    With this you could encrypt each block separately or a better option might be you encrypt the 3 blocks with AES, but in CBC mode where encryption is chained.

    I hope to help you with what you request.
    + 0  |  - 0

    Re: How to encrypt Sector 1 Data Values?

    17. May 2016 at 6:24
    Hi gpagliaroli,

    Thank you for suggestion. In card data written phase I use C# and I am sure I can find short tutorial or example for AES encryption. But in my Pos terminal is embedded Linux and I use QT develop an application using C++. Does AES works on an embedded Linux terminal? Or do you know any information about AES with using QT on embedded terminals?

    Kind Regards

    + 1  |  - 0

    Re: How to encrypt Sector 1 Data Values?

    19. May 2016 at 15:49

    I have not used QT, but searching the internet can find several examples.
    A special feature is that AES is a highly optimized and fast to implement encryption and there are routines for such small microcontrollers as 8-bit algorithm.
    I hope I have helped you.
    + 0  |  - 0
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.