我们正试图更改 desfire ev 1 中的 PICC 主密钥,我们目前所遵循的如下所列
We are using this key for initial authenthication
val KEY_2TDEA: ByteArray = byteArrayOf(
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte(),
0x00.toByte()
)
We are using this key in change key function to later on authenthicate with this key
val NEW_KEY_2TDEA_BYTES: ByteArray = byteArrayOf(
0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F, 0x70, 0x81,
0x92, 0xA3, 0xB4, 0xC5, 0xD6, 0xE7, 0xF8, 0x09,
0x10, 0x21, 0x32, 0x43, 0x54, 0x65, 0x76, 0x87
)
我们遵循的准则 !
selectApplicationByIndex(0)desFireEV1.authenticate(
ACCESS_KEY,
IDESFireEV1.AuthType.Native,
KeyType.THREEDES,
objKEY_2TDEA
)
val appsetbuilder = EV1ApplicationKeySettings.Builder()
val appsettings = appsetbuilder.setAppKeySettingsChangeable(
true
).setAppMasterKeyChangeable(true)
.setAuthenticationRequiredForFileManagement(false)
.setAuthenticationRequiredForDirectoryConfigurationData(
false
).setKeyTypeOfApplicationKeys(
KeyType.TWO_KEY_THREEDES
).build()
desFireEV1.createApplication(appAID, appsettings)
selectApplicationByAID(appAID)
desFireEV1.authenticate(
0,
IDESFireEV1.AuthType.Native,
KeyType.TWO_KEY_THREEDES,
objKEY_2TDEA
)
//THIS METHOD CRASHED with this error "com.nxp.nfclib.exceptions.PICCException: Length Error SW2 = 126"
desFireEV1.changeKey(
0,
KeyType.TWO_KEY_THREEDES,
NEW_KEY_2TDEA_BYTES,
KEY_2TDEA,
0x00.toByte()
)
desFireEV1.commitTransaction()
selectApplicationByAID(appAID)
//this will aithenthciate with new key which has been changed after keyChange setting which we understand
desFireEV1.authenticate(
0,
IDESFireEV1.AuthType.Native,
KeyType.TWO_KEY_THREEDES,
newMasterKey
)
现在我的问题是,为什么更改密钥方法会出现定义错误 SW2 = 126 而崩溃?
AN12757 第 6 章密钥管理中提到了详细步骤。
您可以在安全下载区下载。