From 044e5a3c3801fde7fa3b26986825377016e73103 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 6 Jul 2021 14:52:29 +0900 Subject: 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 --- scd/app-openpgp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'scd/app-openpgp.c') diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c index feea1905b..1fa865f69 100644 --- a/scd/app-openpgp.c +++ b/scd/app-openpgp.c @@ -6134,6 +6134,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 openpgp_aid + && memcmp (aid, openpgp_aid, sizeof openpgp_aid) == 0) + return 0; + + return gpg_error (GPG_ERR_WRONG_CARD); +} + + /* Select the OpenPGP application on the card in SLOT. This function must be used before any other OpenPGP application functions. */ gpg_error_t @@ -6322,6 +6334,7 @@ app_select_openpgp (app_t app) app->fnc.change_pin = do_change_pin; app->fnc.check_pin = do_check_pin; app->fnc.with_keygrip = do_with_keygrip; + app->fnc.check_aid = do_check_aid; } leave: -- cgit v1.2.3