diff options
author | NIIBE Yutaka <[email protected]> | 2021-07-06 05:52:29 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2021-07-06 05:52:29 +0000 |
commit | 044e5a3c3801fde7fa3b26986825377016e73103 (patch) | |
tree | 45e26e9ad43d1a12a5fce7942ebc981a1ccb4638 /scd/app-piv.c | |
parent | artwork: Explain the license for the logo (diff) | |
download | gnupg-044e5a3c3801fde7fa3b26986825377016e73103.tar.gz gnupg-044e5a3c3801fde7fa3b26986825377016e73103.zip |
scd: Detect external interference when PCSC_SHARED.
* scd/app-common.h (check_aid): New method.
* scd/app-openpgp.c (do_check_aid): New.
* scd/app-piv.c (do_check_aid): New.
* scd/app.c (check_external_interference): New.
(maybe_switch_app): Check interference to determine switching is
needed.
--
GnuPG-bug-id: 5484
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'scd/app-piv.c')
-rw-r--r-- | scd/app-piv.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/scd/app-piv.c b/scd/app-piv.c index 143cc047a..0d0863d57 100644 --- a/scd/app-piv.c +++ b/scd/app-piv.c @@ -3609,6 +3609,18 @@ do_reselect (app_t app, ctrl_t ctrl) } +/* Check if AID is the correct one. */ +static gpg_error_t +do_check_aid (app_t app, ctrl_t ctrl, const unsigned char *aid, size_t aidlen) +{ + if (aidlen >= sizeof piv_aid + && memcmp (aid, piv_aid, sizeof piv_aid) == 0) + return 0; + + return gpg_error (GPG_ERR_WRONG_CARD); +} + + /* Select the PIV application on the card in SLOT. This function must * be used before any other PIV application functions. */ gpg_error_t @@ -3713,6 +3725,7 @@ app_select_piv (app_t app) app->fnc.change_pin = do_change_chv; app->fnc.check_pin = do_check_chv; app->fnc.with_keygrip = do_with_keygrip; + app->fnc.check_aid = do_check_aid; leave: |