diff options
| author | Werner Koch <[email protected]> | 2019-06-25 06:30:04 +0000 |
|---|---|---|
| committer | Werner Koch <[email protected]> | 2019-06-25 07:21:14 +0000 |
| commit | d803b3bb3c084b6bce4d2bd161db50dc45442e5b (patch) | |
| tree | f316cf0e99db9629dc24de46212efe5e69fc7408 /scd/command.c | |
| parent | spelling: Fix "synchronize" (diff) | |
| download | gnupg-d803b3bb3c084b6bce4d2bd161db50dc45442e5b.tar.gz gnupg-d803b3bb3c084b6bce4d2bd161db50dc45442e5b.zip | |
scd: Add an re-select mechanism to switch apps.
* scd/app-common.h (struct app_ctx_s): Add func ptr 'reselect'.
* scd/app-piv.c (do_reselect): New.
(app_select_piv): Move AID constant to file scope.
* scd/app-openpgp.c (do_reselect): New.
(app_select_openpgp): Move AID constant to file scope.
* scd/app.c (apptype_from_name): New.
(check_application_conflict): Check against all apps of the card.
Always set current_apptype.
(select_additional_application): New.
(maybe_switch_app): New.
(app_write_learn_status, app_readcert, app_readkey, app_getattr)
(app_setattr, app_sign, app_auth, app_decipher, app_writecert)
(app_writekey, app_genkey, app_change_pin, app_check_pin): Use it here.
(app_do_with_keygrip): Force reselect on success.
(app_new_register): Move setting of CURRENT_APPTYPE to ...
(select_application): here so that it will be set to the requested
card.
* scd/command.c (open_card_with_request): Select additional
application if possible.
--
Noet that we will likely need to rework this even more so to get well
defined semantics for card access.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'scd/command.c')
| -rw-r--r-- | scd/command.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/scd/command.c b/scd/command.c index 3156aa9ef..2b851c5fd 100644 --- a/scd/command.c +++ b/scd/command.c @@ -231,9 +231,16 @@ open_card_with_request (ctrl_t ctrl, /* If we are already initialized for one specific application we need to check that the client didn't requested a specific application different from the one in use before we continue. */ - /* FIXME: Extend to allow switching between apps. */ if (apptypestr && ctrl->card_ctx) - return check_application_conflict (ctrl->card_ctx, apptypestr); + { + err = check_application_conflict (ctrl->card_ctx, apptypestr); + if (gpg_err_code (err) == GPG_ERR_FALSE) + { + /* Different application but switching is supported. */ + err = select_additional_application (ctrl, apptypestr); + } + return err; + } /* Re-scan USB devices. Release CARD, before the scan. */ /* FIXME: Is a card_unref sufficient or do we need to deallocate? */ @@ -2084,7 +2091,6 @@ scd_clear_current_app (card_t card) } } - /* Send a line with status information via assuan and escape all given buffers. The variable elements are pairs of (char *, size_t), terminated with a (NULL, 0). */ |
