From 65348213652320c30ff5dce04374ac58c86b9acc Mon Sep 17 00:00:00 2001 From: Blaine Forbort Date: Fri, 19 Dec 2014 21:37:06 -0800 Subject: [PATCH] Accept key number from command line --- armsrc/mifaredesfire.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/armsrc/mifaredesfire.c b/armsrc/mifaredesfire.c index 66fe00bd..d46d2931 100644 --- a/armsrc/mifaredesfire.c +++ b/armsrc/mifaredesfire.c @@ -226,7 +226,7 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain } cmd[0] = AUTHENTICATE; - cmd[1] = 0x00; //keynumber + cmd[1] = keyno; //keynumber len = DesfireAPDU(cmd, 2, resp); if ( !len ) { if (MF_DBGLEVEL >= 1) { @@ -236,6 +236,13 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain return; } + if ( resp[2] == 0xaf ){ + } else { + DbpString("Authetication failed. Invalid key number."); + OnError(); + return; + } + memcpy( encRndB, resp+3, 8); 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; } - // TOD: Optionally, confirm ek0RndA' = RndA' to varify PICC + // TODO: Optionally, confirm ek0RndA' = RndA' to varify PICC } break; -- 2.39.5