- case 1:
- // if ( SendDesfireCommand(AUTHENTICATE, &keyno, resp) > 0 ){
- // // fick nonce från kortet
- // }
+ case 1:{
+ uint8_t keybytes[8];
+ if (datain[1] == 0xff){
+ memcpy(keybytes,null_key_data8,8);
+ } else{
+ memcpy(keybytes, datain+1, datalen);
+ }
+
+ cmd[0] = AUTHENTICATE;
+ cmd[1] = 0x00; //keynumber
+ len = DesfireAPDU(cmd, 2, resp);
+ if ( !len ) {
+ if (MF_DBGLEVEL >= 1) {
+ DbpString("Authentication failed. Card timeout.");
+ }
+ OnError();
+ return;
+ }
+
+ memcpy( encRndB, resp+3, 8);
+
+ des_dec(&decRndB, &encRndB, &keybytes);
+ Dbprintf("RandB: %02x%02x%02x%02x%02x%02x%02x%02x",decRndB[0],decRndB[1],decRndB[2],decRndB[3],decRndB[4],decRndB[5],decRndB[6],decRndB[7]);
+
+ }