Forum Replies Created
-
Hi TapLinx Support,
I also have issue with changing application master key. Here is my code snippet.
/*******
The issue here is that I cannot
1. changeKey with KeyType.AES128
2. authenticate with IDESFireEV1.AuthType.AES
*******/
// Create Application
/**
* 16 bytes 2KTDES Key.
*/
public static final byte[] DEFAULT_KEY_2KTDES_16_KEY = {
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00};
/**
* TEST_APP_KEY_1_AES128 16 bytes
*/
public static final byte[] TEST_APP_KEY_1_AES128_KEY = {
(byte) 0x04, (byte) 0x01, (byte) 0x04, (byte) 0x01,
(byte) 0x03, (byte) 0x02, (byte) 0x03, (byte) 0x02,
(byte) 0x02, (byte) 0x03, (byte) 0x02, (byte) 0x03,
(byte) 0x01, (byte) 0x04, (byte) 0x01, (byte) 0x04};
public static final byte[] TEST_APP_KEY_2_AES128_KEY = {
(byte) 0x01, (byte) 0x04, (byte) 0x01, (byte) 0x04,
(byte) 0x02, (byte) 0x03, (byte) 0x02, (byte) 0x03,
(byte) 0x03, (byte) 0x02, (byte) 0x03, (byte) 0x02,
(byte) 0x04, (byte) 0x01, (byte) 0x04, (byte) 0x01};
// first authenticate PICC with MasterKEY
// ....
// Then create application
private int DEFAULT_APP_ID = 1
EV1ApplicationKeySettings.Builder appBuilder = new EV1ApplicationKeySettings.Builder();
appBuilder = appBuilder.setAppKeyChangeAccessRight((byte) 0x00);
appBuilder = appBuilder.setAppKeySettingsChangeable(true);
// if setAppMasterKeyChangeable to false, How to I change default key?
appBuilder = appBuilder.setAppMasterKeyChangeable(true);
appBuilder = appBuilder.setAuthenticationRequiredForDirectoryConfigurationData(false);
appBuilder = appBuilder.setAuthenticationRequiredForFileManagement(false);
// THREEDES have to select at first. AES128 won't work!
// AES128 does not work???
appBuilder = appBuilder.setKeyTypeOfApplicationKeys(KeyType.THREEDES);
appBuilder = appBuilder.setMaxNumberOfApplicationKeys(14);
// THREEDES have to select at first. AES128 won't work
// AES128 does not work???
EV1ApplicationKeySettings simpleAppKeysettings = appBuilder
.setAppKeySettingsChangeable(true)
.setAppMasterKeyChangeable(true)
.setAuthenticationRequiredForFileManagement(true)
.setAuthenticationRequiredForDirectoryConfigurationData(true)
.setKeyTypeOfApplicationKeys(KeyType.THREEDES)
.build();
iDESFireEV1.createApplication(DEFAULT_APP_ID, simpleAppKeysettings);
iDESFireEV1.selectApplication(DEFAULT_APP_ID);
// SUCCESS
// CREATE FILE
// WRITE TO FILE. READ FROM FILE ALSO WORK....
//# AUTH WITH DEFAULT APP KEY
final Key t2KTDES_KEY = new SecretKeySpec(DEFAULT_KEY_2KTDES_16_KEY, "DESede");
KeyData t2KTDESKeyData = new KeyData();
t2KTDESKeyData.setKey(t2KTDES_KEY);
iDESFireEV1.authenticate(0, IDESFireEV1.AuthType.Native, KeyType.THREEDES, t2KTDESKeyData);
// AES128 KEY 1
final Key TEST_APP_KEY_1_AES128 = new SecretKeySpec(TEST_APP_KEY_1_AES128_KEY, "AES");
KeyData TEST_APP_KEY_1_AES128_KeyData = new KeyData();
TEST_APP_KEY_1_AES128_KeyData.setKey(TEST_APP_KEY_1_AES128);
// AES128 KEY 2
final Key TEST_APP_KEY_2_AES128 = new SecretKeySpec(TEST_APP_KEY_2_AES128_KEY, "AES");
KeyData TEST_APP_KEY_2_AES128_KeyData = new KeyData();
TEST_APP_KEY_2_AES128_KeyData.setKey(TEST_APP_KEY_2_AES128);
//# CHANGE DEFAULT APP KEY TO AES128 !
iDESFireEV1.changeKey(0, KeyType.THREEDES,
DEFAULT_KEY_2KTDES_16,
TEST_APP_KEY_1_AES128, (byte) 0x01);
Log.d(TAG, "!!! CHANGED APP MASTER KEY TO AES TEST_APP_KEY_1_AES128 !!!");
iDESFireEV1.authenticate(0, IDESFireEV1.AuthType.Native, KeyType.AES128, TEST_APP_KEY_1_AES128_KeyData);
Log.d(TAG, "authenticate APP WITH MASTER KEY TEST_APP_KEY_1_AES128 !");
// SUCCESS. NO ERROR
// authenticate with NEW KEY with KeyType.AES128 work
iDESFireEV1.authenticate(0, IDESFireEV1.AuthType.Native, KeyType.AES128,
TEST_APP_KEY_1_AES128_KeyData);
Log.d(TAG, "authenticate with TEST_APP_KEY_1_AES128_KeyData !");
//# change APP AES key to another AES128
iDESFireEV1.changeKey(0, KeyType.THREEDES,
TEST_APP_KEY_1_AES128,
TEST_APP_KEY_2_AES128, (byte) 0x02);
// authenticate with TEST_APP_KEY_2_AES128
iDESFireEV1.authenticate(0, IDESFireEV1.AuthType.Native, KeyType.AES128, TEST_APP_KEY_2_AES128_KeyData);
// SUCCESS
/*******
The issue here is that I cannot
1. changeKey with KeyType.AES128
2. authenticate with IDESFireEV1.AuthType.AES
*******/
+ 0 | - 0
Re: Reply To: desFireEV1.changeKey fail
30. April 2017 at 8:26 in reply to: desFireEV1.changeKey failBug in my code. I found it. Thanks.
+ 0 | - 0
Re: Reply To: desFireEV1.changeKey fail
30. April 2017 at 8:06 in reply to: desFireEV1.changeKey failAfter I lost a few charges, I think I understand how to change Master Key and Application Key.
But I still would like to confirm one more thing.
What KeyType would you use to change from NEW_KEY_AES TO ANOTHER_NEW_KEY_AES.
If I use KeyType.AES128, I can no longer authenticate with either new key or old key.
Possible bug?
+ 0 | - 0
Re: Reply To: desFireEV1.changeKey fail
24. April 2017 at 3:18 in reply to: desFireEV1.changeKey failIn this case, you should show how to change DEFAULT KEY TO AES in your example. Can you show me how?
If I need data sheet to understand, SDK should clearly mention about it in my opinion. Otherwise, it is waste of time for developers.
Mike
+ 0 | - 0
Re: Reply To: desFireEV1.changeKey fail
17. April 2017 at 4:20 in reply to: desFireEV1.changeKey failAfter changeKey, getKeyVersion always return 0xFF. WHY?
+ 0 | - 0
Re: Reply To: desFireEV1.changeKey fail
17. April 2017 at 4:00 in reply to: desFireEV1.changeKey failHi,
I was able to change the key once using with KeyType.TWO_KEY_THREEDES 16 byte.
1. Never able to change the key with 24 byte.
public static final byte[] DEFAULT_KEY_2KTDES_16 = {
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00};
final Key AUTH_KEY = new SecretKeySpec(DEFAULT_KEY_2KTDES_16, "DESede");
iDESFireEV1.changeKey(0, KeyType.THREEDES, DEFAULT_KEY_2KTDES_16,
SampleAppKeys.TEST_MASTER_KEY_2_2KTDES_16, (byte) 0);
2. I am able to authenticate with a new key after changeKey.
3. I want to change MasterKey again. From DEFAULT_KEY_2KTDES_16 to a new keyType with THREEDES OR KTHREE_KEY_THREEDES OR AES128.
NEVER SUCCESS.
Error:
W/System.err: com.nxp.nfclib.exceptions.InvalidResponseLengthException: Integrity Error
+ 0 | - 0
Re: Reply To: desFireEV1.changeKey fail
17. April 2017 at 3:17 in reply to: desFireEV1.changeKey failEven I use your code snippet, I am still having Integrity Error.
W/System.err: com.nxp.nfclib.exceptions.InvalidResponseLengthException: Integrity Error
W/System.err: at com.nxp.nfclib.desfire.If.ॱ(:4399)
W/System.err: at com.nxp.nfclib.desfire.If.ˊ(:4440)
W/System.err: at com.nxp.nfclib.desfire.If.ˏ(:1346)
W/System.err: at com.nxp.nfclib.desfire.If.ˏ(:1440)
W/System.err: at com.nxp.nfclib.desfire.If.changeKey(:1459)
W/System.err: at com.xxx.xxx.MainActivity.doDESFireEV1(MainActivity.java:116)
W/System.err: at com.xxx.xxx.MainActivity.onNewIntent(MainActivity.java:195)
W/System.err: at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1167)
W/System.err: at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2651)
W/System.err: at android.app.ActivityThread.performNewIntents(ActivityThread.java:2664)
W/System.err: at android.app.ActivityThread.handleNewIntent(ActivityThread.java:2673)
W/System.err: at android.app.ActivityThread.access$1700(ActivityThread.java:174)
W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1392)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err: at android.os.Looper.loop(Looper.java:146)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5731)
W/System.err: at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err: at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
W/System.err: at dalvik.system.NativeStart.main(Native Method)
E/com.xxx.xxx.MainActivity: InvalidResponseLengthException: Integrity Error
+ 0 | - 0
Re: Reply To: desFireEV1.changeKey fail
17. April 2017 at 3:06 in reply to: desFireEV1.changeKey failHi @TapLinx Support,
Is it possible to change DEFAULT MASTER KEY which is all zero to KeyType.AES128 ?
If so, can you provide code snippet?
I am getting integrity error.
+ 0 | - 0
Having issue with Changing masterKey. I can format the card but cannot change Master KEY.
public static final byte[] DEFAULT_KEY_2KTDES = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00};
/**
* 16 bytes AES128 Key.
*/
public static final byte[] TEST_MASTER_KEY_AES128 = {
(byte) 0x04, (byte) 0x01, (byte) 0x04, (byte) 0x01,
(byte) 0x03, (byte) 0x02, (byte) 0x03, (byte) 0x02,
(byte) 0x02, (byte) 0x03, (byte) 0x02, (byte) 0x03,
(byte) 0x01, (byte) 0x04, (byte) 0x01, (byte) 0x04};
iDESFireEV1.selectApplication(0x00);
final Key AUTH_KEY = new SecretKeySpec(DEFAULT_KEY_2KTDES, "DESede");
KeyData keyData = new KeyData();
keyData.setKey(AUTH_KEY);
iDESFireEV1.authenticate(0, IDESFireEV1.AuthType.Native, KeyType.TWO_KEY_THREEDES, keyData);
iDESFireEV1.changeKey(0, KeyType.AES128, DEFAULT_KEY_2KTDES,
TEST_MASTER_KEY_AES128, (byte) 0x00);
Error:
W/System.err: com.nxp.nfclib.exceptions.InvalidResponseLengthException: Integrity Error
+ 0 | - 0
Re: Reply To: Set keys and do authentication to DESFire using MIFARE advanced SDK
17. April 2017 at 2:46 in reply to: Set keys and do authentication to DESFire using MIFARE advanced SDKHaving issue with Changing masterKey. I can format the card but cannot change Master KEY.
public static final byte[] DEFAULT_KEY_2KTDES = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00};
/**
* 16 bytes AES128 Key.
*/
public static final byte[] TEST_MASTER_KEY_AES128 = {
(byte) 0x04, (byte) 0x01, (byte) 0x04, (byte) 0x01,
(byte) 0x03, (byte) 0x02, (byte) 0x03, (byte) 0x02,
(byte) 0x02, (byte) 0x03, (byte) 0x02, (byte) 0x03,
(byte) 0x01, (byte) 0x04, (byte) 0x01, (byte) 0x04};
iDESFireEV1.selectApplication(0x00);
final Key AUTH_KEY = new SecretKeySpec(DEFAULT_KEY_2KTDES, "DESede");
KeyData keyData = new KeyData();
keyData.setKey(AUTH_KEY);
iDESFireEV1.authenticate(0, IDESFireEV1.AuthType.Native, KeyType.TWO_KEY_THREEDES, keyData);
iDESFireEV1.changeKey(0, KeyType.AES128, DEFAULT_KEY_2KTDES,
TEST_MASTER_KEY_AES128, (byte) 0x00);
Error:
W/System.err: com.nxp.nfclib.exceptions.InvalidResponseLengthException: Integrity Error
+ 0 | - 0
Re: Reply To: Trying to use Enciphered DESFire file
30. March 2017 at 5:59 in reply to: Trying to use Enciphered DESFire fileHi TapLinx Support,
It took me a few hours to find out that commitTransaction() have to be called. API doc should be updated.
Many Thanks
+ 0 | - 0
Re: Reply To: Looking for partner or consultant for a Micropayment Project
30. March 2017 at 5:34 in reply to: Looking for partner or consultant for a Micropayment Project@Emad Ghosheh
Email me @ mike.aungsan [@] gmail . com
+ 0 | - 0
Re: Reply To: Problem initialising key set in MIRAFE DESFire EV2
20. March 2017 at 5:10 in reply to: Problem initialising key set in MIRAFE DESFire EV2Hi Diego Palomar, Do you solve the problem? What SDK do you use?
+ 0 | - 0
-
AuthorPosts
Viewing 13 posts - 1 through 13 (of 13 total)