Search code examples
smartcardmifare

How to change master key of DESfire cards?What is deciphered key?


I want to change the master key of a DESfire card. I read mifare DESFire datasheet already, but as I am new in this field, I couldn't understand it.

It is explained how to Change the Key at page 37 of above document.

Can anybody give me an example or a step by step tutorial for changing keys? (Including associated APDU commands)

What is deciphered key that is mentioned in the document? Shall I decipher my new key and then use it in the command? If so, how do I decipher key data?


Solution

  • Your decipheredKey is CBC-mode decrypted value of the new key with a zero initial vector.

    This is a Mifare DESFire feature: terminal always decrypts (even to hide plaintext!) and the DESFire card always encrypts. It is based on fact, that decryption and encryption using symmetric ciphers like DES, 3DES or AES are inverse functions, which can be both used both for hiding and revealing plaintext.

    It helps to improve performance - DESFire card does not have to switch the cipher mode from encryption to decryption with each APDU.

    See page 12 of your document.