iso channel auth with des/2dea/3tdea/aes works

This commit is contained in:
merlokk 2021-07-31 11:58:33 +03:00
commit 91f000ad33

View file

@ -1293,9 +1293,8 @@ static int DesfireAuthenticateISO(DesfireContext *dctx, DesfireSecureChannel sec
memcpy(&both[rndlen], piccrnd, rndlen); memcpy(&both[rndlen], piccrnd, rndlen);
// encode // encode
uint8_t IV[16] = {0}; DesfireClearIV(dctx);
if (aes_encode(IV, dctx->key, both, both, rndlen * 2)) DesfireCryptoEncDec(dctx, false, both, rndlen * 2, both, true); // error 303
return 303;
// external authenticate // external authenticate
res = DesfireISOExternalAuth(dctx, true, dctx->keyNum, dctx->keyType, both); res = DesfireISOExternalAuth(dctx, true, dctx->keyNum, dctx->keyType, both);
@ -1314,8 +1313,7 @@ static int DesfireAuthenticateISO(DesfireContext *dctx, DesfireSecureChannel sec
// decode rnddata // decode rnddata
uint8_t piccrnd2[64] = {0}; uint8_t piccrnd2[64] = {0};
if (aes_decode(IV, dctx->key, rnddata, piccrnd2, rndlen * 2)) DesfireCryptoEncDec(dctx, false, rnddata, rndlen * 2, piccrnd2, false); // error 307
return 307;
// check // check
if (memcmp(hostrnd2, &piccrnd2[rndlen], rndlen) != 0) if (memcmp(hostrnd2, &piccrnd2[rndlen], rndlen) != 0)