diff --git a/src/openpgp/cmd_get_data.c b/src/openpgp/cmd_get_data.c index 81ef49c..651ff75 100644 --- a/src/openpgp/cmd_get_data.c +++ b/src/openpgp/cmd_get_data.c @@ -29,7 +29,14 @@ int cmd_get_data(void) { uint16_t requested_fid = fid; file_t *ef; if (!(ef = file_search_by_fid(fid, NULL, SPECIFY_EF))) { - return SW_REFERENCE_NOT_FOUND(); + return SW_WRONG_P1P2(); + } + + if (fid == EF_RESET_CODE || + ((file_get_type(ef) & FILE_TYPE_INTERNAL_EF) && + fid != EF_PRIV_DO_1 && fid != EF_PRIV_DO_2 && + fid != EF_PRIV_DO_3 && fid != EF_PRIV_DO_4)) { + return SW_WRONG_P1P2(); } if (fid == EF_PRIV_DO_3) { if (!has_pw2) { diff --git a/src/openpgp/cmd_select.c b/src/openpgp/cmd_select.c index 16e1f64..b26f0b9 100644 --- a/src/openpgp/cmd_select.c +++ b/src/openpgp/cmd_select.c @@ -73,6 +73,9 @@ int cmd_select(void) { } } } + if (p1 <= 0x02 && pe && (file_get_type(pe) & FILE_TYPE_INTERNAL_EF)) { + return SW_REFERENCE_NOT_FOUND(); + } if ((p2 & 0xfc) == 0x00 || (p2 & 0xfc) == 0x04) { if ((p2 & 0xfc) == 0x04) { file_process_fci(pe, 0);