Reply To: Cannot create DESFire EV1 aplication with AES key

Forum MIFARE SDK Cannot create DESFire EV1 aplication with AES key Reply To: Cannot create DESFire EV1 aplication with AES key

Re: Cannot create DESFire EV1 aplication with AES key

13. July 2016 at 13:56
Below is sample i created according to your instructions (except PICC Master key is changed before creating new application) and it does not work. Authentication for new application fails. Does some workable sample exist which uses AES keys?
Please NOTE: if I don't change auth type from default to AES then it work fine. My question is EXACTLY about AES keys in application.


byte appKeySettings1 = card.formatApplicationKeySettingOne((byte)1,
IDESFireEV1.KSONE_APP_MKEY_CHANGABLE, IDESFireEV1.KSONE_CONFIG_CHANGABLE, IDESFireEV1.KSONE_FILE_DEL_NO_MKEY, IDESFireEV1.KSONE_GET_NO_MKEY);
byte appKeySettings2 = card.formatApplicationKeySettingTwo((byte)2, IDESFireEV1.KSTWO_AES, false);

card.selectApplication(0);
card.authenticate(DESFireEV1.AuthType.Native, Sam.NxpKey.DEF_KEY.ordinal(), (byte) 0, 0, IKeyConstants.DIV_OPTION_NODIVERSIFICATION, null);
card.changeKey(0, Sam.NxpKey.DEF_KEY.ordinal(), (byte) 0, Sam.NxpKey.PICC_KEY.ordinal(), (byte) 0, DESFireEV1.KeyType.AES, IKeyConstants.DIV_OPTION_NODIVERSIFICATION, IKeyConstants.DIV_OPTION_NODIVERSIFICATION, null);

card.authenticate(DESFireEV1.AuthType.AES, Sam.NxpKey.PICC_KEY.ordinal(), (byte) 0, 0, IKeyConstants.DIV_OPTION_NODIVERSIFICATION, null);

card.createApplication(AID, appKeySettings1, appKeySettings2);

card.selectApplication(AID);

card.createFile(0, new DESFireFile.StdDataFileSettings(DESFireEV1.CommunicationType.Plain, 0, 0, 1, 1, 8));

// Next line fails both with AuthType.Native and AuthType.AES
card.authenticate(DESFireEV1.AuthType.Native, Sam.NxpKey.DEF_KEY.ordinal(), (byte)0, 0, IKeyConstants.DIV_OPTION_NODIVERSIFICATION, null);

card.changeKey(0, Sam.NxpKey.DEF_KEY.ordinal(), (byte)0, Sam.NxpKey.AP_KEY.ordinal(), (byte)0, DESFireEV1.KeyType.AES, IKeyConstants.DIV_OPTION_NODIVERSIFICATION, IKeyConstants.DIV_OPTION_NODIVERSIFICATION, null);
card.authenticate(DESFireEV1.AuthType.AES, Sam.NxpKey.AP_KEY.ordinal(), (byte)0, 0, IKeyConstants.DIV_OPTION_NODIVERSIFICATION, null);

card.authenticate(DESFireEV1.AuthType.Native, Sam.NxpKey.DEF_KEY.ordinal(), (byte)0, 1, IKeyConstants.DIV_OPTION_NODIVERSIFICATION, null);
card.changeKey(1, Sam.NxpKey.DEF_KEY.ordinal(), (byte)0, Sam.NxpKey.AP_KEY.ordinal(), (byte)0, DESFireEV1.KeyType.AES, IKeyConstants.DIV_OPTION_NODIVERSIFICATION, IKeyConstants.DIV_OPTION_NODIVERSIFICATION, null);



+ 0  |  - 0