@@ -369,13 +369,13 @@ void MifareDES_Auth1(uint8_t *datain) {
369369 if (g_dbglevel >= DBG_ERROR ) {
370370 DbpString ("Authentication failed. Card timeout." );
371371 }
372- OnErrorNG (CMD_HF_DESFIRE_AUTH1 , 3 );
372+ OnErrorNG (CMD_HF_DESFIRE_AUTH1 , PM3_ETIMEOUT );
373373 return ;
374374 }
375375
376376 if (resp [2 ] == (uint8_t )MFDES_ADDITIONAL_FRAME ) {
377377 DbpString ("Authentication failed. Invalid key number." );
378- OnErrorNG (CMD_HF_DESFIRE_AUTH1 , 3 );
378+ OnErrorNG (CMD_HF_DESFIRE_AUTH1 , PM3_EINVARG );
379379 return ;
380380 }
381381
@@ -396,7 +396,7 @@ void MifareDES_Auth1(uint8_t *datain) {
396396 DbpString ("Authentication failed. Length of answer doesn't match algo." );
397397 print_result ("Res-Buffer: " , resp , len );
398398 }
399- OnErrorNG (CMD_HF_DESFIRE_AUTH1 , 3 );
399+ OnErrorNG (CMD_HF_DESFIRE_AUTH1 , PM3_EWRONGANSWER );
400400 return ;
401401 }
402402
@@ -414,7 +414,7 @@ void MifareDES_Auth1(uint8_t *datain) {
414414 if (g_dbglevel >= DBG_EXTENDED ) {
415415 DbpString ("mbedtls_aes_setkey_dec failed" );
416416 }
417- OnErrorNG (CMD_HF_DESFIRE_AUTH1 , 7 );
417+ OnErrorNG (CMD_HF_DESFIRE_AUTH1 , PM3_ECRYPTO );
418418 return ;
419419 }
420420 mbedtls_aes_crypt_cbc (& ctx , MBEDTLS_AES_DECRYPT , 16 , IV , encRndB , RndB );
@@ -472,7 +472,7 @@ void MifareDES_Auth1(uint8_t *datain) {
472472 if (g_dbglevel >= DBG_EXTENDED ) {
473473 DbpString ("mbedtls_aes_setkey_enc failed" );
474474 }
475- OnErrorNG (CMD_HF_DESFIRE_AUTH1 , 7 );
475+ OnErrorNG (CMD_HF_DESFIRE_AUTH1 , PM3_ECRYPTO );
476476 return ;
477477 }
478478 mbedtls_aes_crypt_cbc (& ctx , MBEDTLS_AES_ENCRYPT , 32 , IV , tmp , both );
@@ -499,27 +499,27 @@ void MifareDES_Auth1(uint8_t *datain) {
499499 len = DesfireAPDU (cmd , 1 + bothlen , resp );
500500 }
501501
502- if (! len ) {
502+ if (len == 0 ) {
503503 if (g_dbglevel >= DBG_ERROR ) {
504504 DbpString ("Authentication failed. Card timeout." );
505505 }
506- OnErrorNG (CMD_HF_DESFIRE_AUTH1 , 3 );
506+ OnErrorNG (CMD_HF_DESFIRE_AUTH1 , PM3_ETIMEOUT );
507507 return ;
508508 }
509509
510510 if (payload -> mode != MFDES_AUTH_PICC ) {
511511
512512 if ((resp [len - 4 ] != 0x91 ) || (resp [len - 3 ] != 0x00 )) {
513513 DbpString ("Authentication failed." );
514- OnErrorNG (CMD_HF_DESFIRE_AUTH1 , 6 );
514+ OnErrorNG (CMD_HF_DESFIRE_AUTH1 , PM3_ESOFT );
515515 return ;
516516 }
517517
518518 } else {
519519
520520 if (resp [1 ] != 0x00 ) {
521521 DbpString ("Authentication failed." );
522- OnErrorNG (CMD_HF_DESFIRE_AUTH1 , 6 );
522+ OnErrorNG (CMD_HF_DESFIRE_AUTH1 , PM3_ESOFT );
523523 return ;
524524 }
525525
@@ -555,7 +555,7 @@ void MifareDES_Auth1(uint8_t *datain) {
555555 if (g_dbglevel >= DBG_EXTENDED ) {
556556 DbpString ("mbedtls_aes_setkey_dec failed" );
557557 }
558- OnErrorNG (CMD_HF_DESFIRE_AUTH1 , 7 );
558+ OnErrorNG (CMD_HF_DESFIRE_AUTH1 , PM3_ECRYPTO );
559559 return ;
560560 }
561561 mbedtls_aes_crypt_cbc (& ctx , MBEDTLS_AES_DECRYPT , 16 , IV , encRndA , encRndA );
@@ -571,7 +571,7 @@ void MifareDES_Auth1(uint8_t *datain) {
571571 for (int x = 0 ; x < rndlen ; x ++ ) {
572572 if (RndA [x ] != encRndA [x ]) {
573573 DbpString ("Authentication failed. Cannot verify Session Key." );
574- OnErrorNG (CMD_HF_DESFIRE_AUTH1 , 4 );
574+ OnErrorNG (CMD_HF_DESFIRE_AUTH1 , PM3_ECRYPTO );
575575 return ;
576576 }
577577 }
0 commit comments