Fix login session persistence. It is handled when the card reader disconnects, instead of when applet is selected (only the first time).

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2022-03-06 01:50:34 +01:00
parent bf2624cd88
commit e36c80761e
No known key found for this signature in database
GPG Key ID: C0095B7870A4CCD3
2 changed files with 13 additions and 2 deletions

View File

@ -1567,8 +1567,11 @@ void card_thread()
goto done;
#endif
}
else if (m == EV_EXIT)
else if (m == EV_EXIT) {
if (current_app && current_app->unload)
current_app->unload();
break;
}
process_apdu();

View File

@ -22,11 +22,13 @@ static uint8_t tmp_dkek[IV_SIZE+32];
static int sc_hsm_process_apdu();
static void init_sc_hsm();
static int sc_hsm_unload();
app_t *sc_hsm_select_aid(app_t *a) {
if (!memcmp(apdu.cmd_apdu_data, sc_hsm_aid+1, MIN(apdu.cmd_apdu_data_len,sc_hsm_aid[0]))) {
a->aid = sc_hsm_aid;
a->process_apdu = sc_hsm_process_apdu;
a->unload = sc_hsm_unload;
init_sc_hsm();
return a;
}
@ -40,6 +42,13 @@ void __attribute__ ((constructor)) sc_hsm_ctor() {
void init_sc_hsm() {
scan_flash();
has_session_pin = has_session_sopin = false;
isUserAuthenticated = false;
}
int sc_hsm_unload() {
has_session_pin = has_session_sopin = false;
isUserAuthenticated = false;
return HSM_OK;
}
static int encrypt(const uint8_t *key, const uint8_t *iv, uint8_t *data, int len)
@ -100,7 +109,6 @@ void select_file(file_t *pe) {
}
if (currentEF == file_openpgp || currentEF == file_sc_hsm) {
selected_applet = currentEF;
isUserAuthenticated = false;
}
}
static int cmd_select() {