2194126_en-US

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

2194126_en-US

2194126_en-US

Error SW2 = 126 → means wrong key length or invalid key type during key change.

We are trying to change PICC Master key in desfire ev 1 what we currently follow listed under 

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
)


What we follow in code !

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
)



NOW my question is why changekey method crash with the define error SW2 = 126

Authentication server problemsRe: Error SW2 = 126 → means wrong key length or invalid key type during key change.

There is a detail steps mentioned in the AN12757 Chapter 6 Key Management.

You could download it in Secure Download Area.

desfire_featuresandhints.png 

タグ(1)
評価なし
バージョン履歴
最終更新日:
‎11-21-2025 11:21 PM
更新者: