diff options
author | NIIBE Yutaka <[email protected]> | 2016-12-28 03:29:17 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2016-12-28 03:29:17 +0000 |
commit | 4cc9fc5eb9bd91d943c185d59da4a2b4cb885ee6 (patch) | |
tree | 35e893cdc578bbf33f3e9de350581177392f60a0 /scd/app-common.h | |
parent | scd: Simplify monitoring card removal. (diff) | |
download | gnupg-4cc9fc5eb9bd91d943c185d59da4a2b4cb885ee6.tar.gz gnupg-4cc9fc5eb9bd91d943c185d59da4a2b4cb885ee6.zip |
scd: APP centric approach for device management.
* scd/app.c (lock_app): Rename from lock_reader and use internal field
of APP.
(unlock_app): Likewise.
(app_dump_state): Use APP.
(application_notify_card_reset): Remove.
(check_conflict): Change API for APP, instead of SLOT.
(check_application_conflict): Likewise.
(release_application_internal): New.
(app_reset): New.
(app_new_register): New.
(select_application): Change API for APP, instead of SLOT.
(deallocate_app, release_application): Modify for manage link.
(report_change): New.
(scd_update_reader_status_file): Moved from command.c and
use APP list, instead of VREADER.
(initialize_module_command): Moved from command.c.
* scd/command.c (TEST_CARD_REMOVAL): Remove.
(IS_LOCKED): Simplify.
(vreader_table): Remove.
(vreader_slot, update_card_removed): Remove.
(do_reset): Call app_reset.
(get_current_reader): Remove.
(open_card): Add SCAN arg.
(cmd_serialno): No retry, since retry is done in lower layer in apdu.c.
No do_reset, since it is done in lower layer.
Add clearing card_removed flag.
(cmd_disconnect): Call apdu_disconnect.
(send_client_notifications): Modify for APP.
(update_reader_status_file): Remove.
--
APP is the abstraction of the card application. For management of
cards, it is better to focus on the APP instead of the physical reader.
This change makes support of multiple card/token easier.
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'scd/app-common.h')
-rw-r--r-- | scd/app-common.h | 47 |
1 files changed, 12 insertions, 35 deletions
diff --git a/scd/app-common.h b/scd/app-common.h index 21f659eb6..781bf465c 100644 --- a/scd/app-common.h +++ b/scd/app-common.h @@ -22,13 +22,8 @@ #ifndef GNUPG_SCD_APP_COMMON_H #define GNUPG_SCD_APP_COMMON_H -#if GNUPG_MAJOR_VERSION == 1 -# ifdef ENABLE_AGENT_SUPPORT -# include "assuan.h" -# endif -#else -# include <ksba.h> -#endif +#include <npth.h> +#include <ksba.h> #define APP_CHANGE_FLAG_RESET 1 @@ -41,6 +36,10 @@ struct app_local_s; /* Defined by all app-*.c. */ struct app_ctx_s { + struct app_ctx_s *next; + + npth_mutex_t lock; + /* Number of connections currently using this application context. If this is not 0 the application has been initialized and the function pointers may be used. Note that for unsupported @@ -50,18 +49,12 @@ struct app_ctx_s { /* Used reader slot. */ int slot; - /* If this is used by GnuPG 1.4 we need to know the assuan context - in case we need to divert the operation to an already running - agent. This if ASSUAN_CTX is not NULL we take this as indication - that all operations are diverted to gpg-agent. */ -#if GNUPG_MAJOR_VERSION == 1 - assuan_context_t assuan_ctx; -#endif /*GNUPG_MAJOR_VERSION == 1*/ - unsigned char *serialno; /* Serialnumber in raw form, allocated. */ size_t serialnolen; /* Length in octets of serialnumber. */ const char *apptype; unsigned int card_version; + unsigned int card_status; + unsigned int require_get_status:1; unsigned int did_chv1:1; unsigned int force_chv1:1; /* True if the card does not cache CHV1. */ unsigned int did_chv2:1; @@ -119,20 +112,8 @@ struct app_ctx_s { gpg_error_t (*pincb)(void*, const char *, char **), void *pincb_arg); } fnc; - }; -#if GNUPG_MAJOR_VERSION == 1 -gpg_error_t app_select_openpgp (app_t app); -gpg_error_t app_get_serial_and_stamp (app_t app, char **serial, time_t *stamp); -gpg_error_t app_openpgp_storekey (app_t app, int keyno, - unsigned char *template, size_t template_len, - time_t created_at, - const unsigned char *m, size_t mlen, - const unsigned char *e, size_t elen, - gpg_error_t (*pincb)(void*, const char *, char **), - void *pincb_arg); -#else /*-- app-help.c --*/ unsigned int app_help_count_bits (const unsigned char *a, size_t len); gpg_error_t app_help_get_keygrip_string (ksba_cert_t cert, char *hexkeygrip); @@ -142,10 +123,10 @@ size_t app_help_read_length_of_cert (int slot, int fid, size_t *r_certoff); /*-- app.c --*/ void app_dump_state (void); void application_notify_card_reset (int slot); -gpg_error_t check_application_conflict (ctrl_t ctrl, int slot, - const char *name); -gpg_error_t select_application (ctrl_t ctrl, int slot, const char *name, - app_t *r_app); +gpg_error_t check_application_conflict (const char *name, app_t app); +gpg_error_t app_reset (app_t app, ctrl_t ctrl, int send_reset); +gpg_error_t select_application (ctrl_t ctrl, const char *name, app_t *r_app, + int scan); char *get_supported_applications (void); void release_application (app_t app); gpg_error_t app_munge_serialno (app_t app); @@ -222,8 +203,4 @@ gpg_error_t app_select_geldkarte (app_t app); gpg_error_t app_select_sc_hsm (app_t app); -#endif - - - #endif /*GNUPG_SCD_APP_COMMON_H*/ |