From: Blaine Forbort Date: Sun, 21 Dec 2014 03:25:31 +0000 (-0800) Subject: code to check RndA' from PICC was unreachable X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/06732632308cb40fba0cde7ad87bf455a2d42e50 code to check RndA' from PICC was unreachable --- diff --git a/armsrc/mifaredesfire.c b/armsrc/mifaredesfire.c index 0a3fdc34..e5a2289b 100644 --- a/armsrc/mifaredesfire.c +++ b/armsrc/mifaredesfire.c @@ -294,6 +294,18 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain desfirekey_t skey = &sessionKey; Desfire_session_key_new( RndA, RndB , key, skey ); //print_result("SESSION : ", skey->data, 8); + + memcpy(encRndA, resp+3, 8); + des_dec(&encRndA, &encRndA, key->data); + rol(decRndA,8); + for (int x = 0; x < 8; x++) { + if (decRndA[x] != encRndA[x]) { + DbpString("Authetication failed. Cannot varify PICC."); + OnError(); + return; + } + } + OnSuccess(); cmd_send(CMD_ACK,1,0,0,skey->data,8); @@ -303,18 +315,6 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain return; } - memcpy(encRndA, resp+3, 8); - des_dec(&encRndA, &encRndA, key->data); - rol(decRndA,8); - for (int x = 0; x < 8; x++) { - if (decRndA[x] != encRndA[x]) { - DbpString("Authetication failed. Cannot varify PICC."); - OnError(); - return; - } - } - - } } break;