Accept key number from command line

This commit is contained in:
Blaine Forbort 2014-12-19 21:37:06 -08:00
commit 6534821365

View file

@ -226,7 +226,7 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain
} }
cmd[0] = AUTHENTICATE; cmd[0] = AUTHENTICATE;
cmd[1] = 0x00; //keynumber cmd[1] = keyno; //keynumber
len = DesfireAPDU(cmd, 2, resp); len = DesfireAPDU(cmd, 2, resp);
if ( !len ) { if ( !len ) {
if (MF_DBGLEVEL >= 1) { if (MF_DBGLEVEL >= 1) {
@ -236,6 +236,13 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain
return; return;
} }
if ( resp[2] == 0xaf ){
} else {
DbpString("Authetication failed. Invalid key number.");
OnError();
return;
}
memcpy( encRndB, resp+3, 8); memcpy( encRndB, resp+3, 8);
des_dec(&decRndB, &encRndB, &keybytes); des_dec(&decRndB, &encRndB, &keybytes);
@ -277,7 +284,7 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain
return; return;
} }
// TOD: Optionally, confirm ek0RndA' = RndA' to varify PICC // TODO: Optionally, confirm ek0RndA' = RndA' to varify PICC
} }
break; break;