@@ -534,17 +534,17 @@ static int piv_general_authenticate(const CAPDU *capdu, RAPDU *rapdu) {
534
534
if (* DATA != 0x7C ) EXCEPT (SW_WRONG_DATA );
535
535
536
536
const char * key_path = get_key_path (P2 );
537
- if (key_path == NULL ) EXCEPT (SW_WRONG_P1P2 );
537
+ if (key_path == NULL ) {
538
+ DBG_MSG ("Invalid key ref\n" );
539
+ EXCEPT (SW_REFERENCE_DATA_NOT_FOUND );
540
+ }
538
541
539
542
ck_key_t key ;
540
543
if (P2 == 0x9B ) { // Card admin
541
544
if (P1 != ALG_DEFAULT && P1 != ALG_TDEA_3KEY ) {
542
545
DBG_MSG ("Invalid P1/P2 for card admin key\n" );
543
546
EXCEPT (SW_WRONG_P1P2 );
544
547
}
545
- } else if (P2 != 0x9A && P2 != 0x9C && P2 != 0x9D && P2 != 0x9E && P2 != 0x82 && P2 != 0x83 ) {
546
- DBG_MSG ("Invalid key ref\n" );
547
- EXCEPT (SW_REFERENCE_DATA_NOT_FOUND );
548
548
}
549
549
if (ck_read_key_metadata (key_path , & key .meta ) < 0 ) return -1 ;
550
550
DBG_KEY_META (& key .meta );
@@ -884,13 +884,16 @@ static int piv_generate_asymmetric_key_pair(const CAPDU *capdu, RAPDU *rapdu) {
884
884
DBG_MSG ("Wrong length\n" );
885
885
EXCEPT (SW_WRONG_LENGTH );
886
886
}
887
- if (P1 != 0x00 || (P2 != 0x9A && P2 != 0x9C && P2 != 0x9D && P2 != 0x9E && P2 != 0x82 && P2 != 0x83 ) || DATA [0 ] != 0xAC || DATA [2 ] != 0x80 ||
888
- DATA [3 ] != 0x01 ) {
887
+ if (P1 != 0x00 || DATA [0 ] != 0xAC || DATA [2 ] != 0x80 || DATA [3 ] != 0x01 ) {
889
888
DBG_MSG ("Wrong P1/P2 or tags\n" );
890
889
EXCEPT (SW_WRONG_DATA );
891
890
}
892
891
893
892
const char * key_path = get_key_path (P2 );
893
+ if (key_path == NULL ) {
894
+ DBG_MSG ("Invalid key ref\n" );
895
+ EXCEPT (SW_REFERENCE_DATA_NOT_FOUND );
896
+ }
894
897
ck_key_t key ;
895
898
if (ck_read_key (key_path , & key ) < 0 ) return -1 ;
896
899
0 commit comments