DESFire I can create application, read* write etc but i can NOT ChangeKey
the "TDES worked example"
has Key 1C94D15B507F8C2C6DD3C3BEF2C8FA75
data F1E3D1C7B1A3918F
output of 35E431B4BE541C0A
- this cannot be any possible TDES, so I guess there's an iv (which the worked exampe doesnt mention)
chained iv is typically the tail of the most recent crypto OR crc operation
Any hints ? I've tried a few
Change Key Same key and Changekey Different Auth key both fail
ChangeKey 911E INTEGRITY_ERROR CRC or MAC does not match dataPadding bytes not valid
//▼▼▼▼▼▼▼▼
void changeKeySame(byte keyNum, byte[] newkey16, byte[] AID, byte[] amkdata) // key to change = Authorisation key
{ // not working...
// keyNum = key to change Must be 0 (if Keysettng b7 = 0) key16 = new key data amkdata = old data
byte[] bHead = Uti.asHex("90C4 00 00 19");
byte[] bChangeKey = new byte[31]; //5 + 1 + 24 + 1
System.arraycopy(bHead,0,bChangeKey,0,5);
bChangeKey[5] = keyNum;
selectApplication(AID); // OK
mk24 = Uti.triple(amkdata); // 24 from 16
byte[] Sess = authenticateDES(mk24,keyNum);
byte[] data24 = new byte[24];
byte[] crc16a = Uti.CRC16(newkey16); // tested against worked examples
System.arraycopy(newkey16, 0,data24, 0,16);
System.arraycopy(crc16a, 0,data24,16, 2);
byte[] ivz = {0,0,0,0, 0,0,0,0 };
byte[] decData = Uti.decrypt(Sess,ivz, data24); // ivz no good
System.arraycopy(decData,0,bChangeKey,6,24);
CommandAPDU aChangeKey = new CommandAPDU(bChangeKey);
ResponseAPDU respa = null;
try {
respa = term.Cardch.transmit(aChangeKey); // -> Card
}
catch (javax.smartcardio.CardException cex)
{
print("\n ChangeKey " + cex.getMessage());
}
catch (java.lang.IllegalArgumentException dex)
{
print("\n ChangeKey " + dex.getMessage());
}
print("\n ChangeKeySame " + Uti.erctrans(respa.getSW()) + "<<<" + Uti.asString(respa.getData()) + ">>>"); //▼▼▼▼▼▼▼▼
}