fix DesfireAuthenticate for d40/ev1 mode
This commit is contained in:
1 parent
6124b49c99
commit
430f82730d
1 file changed
+11
-11
@@ -708,18 +708,18 @@ int DesfireAuthenticate(DesfireContext *dctx, DesfireSecureChannel secureChannel
|
|||||||
uint8_t encRndA[16] = {0x00};
|
uint8_t encRndA[16] = {0x00};
|
||||||
|
|
||||||
// - Encrypt our response
|
// - Encrypt our response
|
||||||
if (dctx->secureChannel == DACd40) {
|
if ((dctx->secureChannel == DACEV1 || dctx->secureChannel == DACd40) && dctx->keyType != T_AES) {
|
||||||
des_decrypt(encRndA, RndA, key->data);
|
if (dctx->keyType == T_DES) {
|
||||||
memcpy(both, encRndA, rndlen);
|
des_decrypt(encRndA, RndA, key->data);
|
||||||
|
memcpy(both, encRndA, rndlen);
|
||||||
|
|
||||||
for (uint32_t x = 0; x < rndlen; x++) {
|
for (uint32_t x = 0; x < rndlen; x++) {
|
||||||
rotRndB[x] = rotRndB[x] ^ encRndA[x];
|
rotRndB[x] = rotRndB[x] ^ encRndA[x];
|
||||||
}
|
}
|
||||||
|
|
||||||
des_decrypt(encRndB, rotRndB, key->data);
|
des_decrypt(encRndB, rotRndB, key->data);
|
||||||
memcpy(both + rndlen, encRndB, rndlen);
|
memcpy(both + rndlen, encRndB, rndlen);
|
||||||
} else if (dctx->secureChannel == DACEV1 && dctx->keyType != T_AES) {
|
} else if (dctx->keyType == T_3DES) {
|
||||||
if (dctx->keyType == T_3DES) {
|
|
||||||
uint8_t tmp[16] = {0x00};
|
uint8_t tmp[16] = {0x00};
|
||||||
memcpy(tmp, RndA, rndlen);
|
memcpy(tmp, RndA, rndlen);
|
||||||
memcpy(tmp + rndlen, rotRndB, rndlen);
|
memcpy(tmp + rndlen, rotRndB, rndlen);
|
||||||
@@ -731,7 +731,7 @@ int DesfireAuthenticate(DesfireContext *dctx, DesfireSecureChannel secureChannel
|
|||||||
if (g_debugMode > 1) {
|
if (g_debugMode > 1) {
|
||||||
PrintAndLogEx(DEBUG, "EncBoth: %s", sprint_hex(both, 16));
|
PrintAndLogEx(DEBUG, "EncBoth: %s", sprint_hex(both, 16));
|
||||||
}
|
}
|
||||||
} else if (dctx->keyType == T_3K3DES) {
|
} else if (dctx->secureChannel == DACEV1 && dctx->keyType == T_3K3DES) {
|
||||||
uint8_t tmp[32] = {0x00};
|
uint8_t tmp[32] = {0x00};
|
||||||
memcpy(tmp, RndA, rndlen);
|
memcpy(tmp, RndA, rndlen);
|
||||||
memcpy(tmp + rndlen, rotRndB, rndlen);
|
memcpy(tmp + rndlen, rotRndB, rndlen);
|
||||||
|
|||||||
Reference in new issue
Block a user