2003-08-05 19:11:04 +02:00
|
|
|
/* app-common.h - Common declarations for all card applications
|
2008-09-23 11:57:45 +02:00
|
|
|
* Copyright (C) 2003, 2005, 2008 Free Software Foundation, Inc.
|
2003-08-05 19:11:04 +02:00
|
|
|
*
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
*
|
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-04 21:49:40 +02:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-08-05 19:11:04 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-11-05 12:02:19 +01:00
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2004-10-14 11:12:36 +02:00
|
|
|
*
|
|
|
|
* $Id$
|
2003-08-05 19:11:04 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GNUPG_SCD_APP_COMMON_H
|
|
|
|
#define GNUPG_SCD_APP_COMMON_H
|
|
|
|
|
2016-12-28 04:29:17 +01:00
|
|
|
#include <npth.h>
|
|
|
|
#include <ksba.h>
|
2004-03-16 19:59:21 +01:00
|
|
|
|
2019-02-06 12:24:30 +01:00
|
|
|
/* Flags used with app_change_pin. */
|
2019-01-21 14:06:51 +01:00
|
|
|
#define APP_CHANGE_FLAG_RESET 1 /* PIN Reset mode. */
|
|
|
|
#define APP_CHANGE_FLAG_NULLPIN 2 /* NULL PIN mode. */
|
|
|
|
#define APP_CHANGE_FLAG_CLEAR 4 /* Clear the given PIN. */
|
2008-06-24 18:00:29 +02:00
|
|
|
|
2019-02-06 12:24:30 +01:00
|
|
|
/* Flags used with app_genkey. */
|
|
|
|
#define APP_GENKEY_FLAG_FORCE 1 /* Force overwriting existing key. */
|
|
|
|
|
2019-03-05 15:49:20 +01:00
|
|
|
/* Flags used with app_writekey. */
|
|
|
|
#define APP_WRITEKEY_FLAG_FORCE 1 /* Force overwriting existing key. */
|
|
|
|
|
2019-04-03 17:31:09 +02:00
|
|
|
/* Flags used with app_readkey. */
|
|
|
|
#define APP_READKEY_FLAG_INFO 1 /* Send also a KEYPAIRINFO line. */
|
|
|
|
|
2019-09-04 10:43:18 +02:00
|
|
|
/* Flags set by the decipher function into R_INFO. */
|
2013-08-26 17:29:54 +02:00
|
|
|
#define APP_DECIPHER_INFO_NOPAD 1 /* Padding has been removed. */
|
|
|
|
|
2019-09-04 10:43:18 +02:00
|
|
|
/* Flags used by the app_write_learn_status. */
|
|
|
|
#define APP_LEARN_FLAG_KEYPAIRINFO 1 /* Return only keypair infos. */
|
2019-09-04 12:08:07 +02:00
|
|
|
#define APP_LEARN_FLAG_MULTI 2 /* Return info for all apps. */
|
2021-05-11 09:04:19 +02:00
|
|
|
#define APP_LEARN_FLAG_REREAD 4 /* Re-read infos from the token. */
|
2019-09-04 12:08:07 +02:00
|
|
|
|
2008-06-24 18:00:29 +02:00
|
|
|
|
2019-06-19 14:30:16 +02:00
|
|
|
/* List of supported card types. Generic is the usual ISO7817-4
|
|
|
|
* compliant card. More specific card or token versions can be given
|
|
|
|
* here. Use strcardtype() to map them to a string. */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
CARDTYPE_GENERIC = 0,
|
2020-08-27 07:32:04 +02:00
|
|
|
CARDTYPE_GNUK,
|
|
|
|
CARDTYPE_YUBIKEY,
|
|
|
|
CARDTYPE_ZEITCONTROL
|
2019-06-19 14:30:16 +02:00
|
|
|
|
|
|
|
} cardtype_t;
|
|
|
|
|
|
|
|
/* List of supported card applications. The source code for each
|
|
|
|
* application can usually be found in an app-NAME.c file. Use
|
|
|
|
* strapptype() to map them to a string. */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
APPTYPE_NONE = 0,
|
|
|
|
APPTYPE_UNDEFINED,
|
|
|
|
APPTYPE_OPENPGP,
|
|
|
|
APPTYPE_PIV,
|
|
|
|
APPTYPE_NKS,
|
|
|
|
APPTYPE_P15,
|
|
|
|
APPTYPE_GELDKARTE,
|
|
|
|
APPTYPE_DINSIG,
|
|
|
|
APPTYPE_SC_HSM
|
|
|
|
} apptype_t;
|
|
|
|
|
|
|
|
|
2019-06-21 10:23:35 +02:00
|
|
|
/* Forward declarations. */
|
|
|
|
struct card_ctx_s;
|
|
|
|
struct app_ctx_s;
|
2004-04-26 20:28:06 +02:00
|
|
|
struct app_local_s; /* Defined by all app-*.c. */
|
|
|
|
|
2019-06-19 08:50:40 +02:00
|
|
|
|
2019-06-21 10:23:35 +02:00
|
|
|
typedef struct card_ctx_s *card_t;
|
|
|
|
typedef struct app_ctx_s *app_t;
|
|
|
|
|
2019-06-19 08:50:40 +02:00
|
|
|
/* The object describing a card. */
|
|
|
|
struct card_ctx_s {
|
2019-06-21 10:23:35 +02:00
|
|
|
card_t next;
|
2016-12-28 04:29:17 +01:00
|
|
|
|
|
|
|
npth_mutex_t lock;
|
|
|
|
|
2019-06-19 08:50:40 +02:00
|
|
|
/* Number of connections currently using this application context. */
|
2009-03-24 12:40:57 +01:00
|
|
|
unsigned int ref_count;
|
2005-06-03 15:57:24 +02:00
|
|
|
|
2009-03-24 12:40:57 +01:00
|
|
|
/* Used reader slot. */
|
2011-02-04 12:57:53 +01:00
|
|
|
int slot;
|
2005-05-20 22:39:36 +02:00
|
|
|
|
2019-06-19 14:30:16 +02:00
|
|
|
cardtype_t cardtype; /* The token's type. */
|
2019-03-05 17:17:39 +01:00
|
|
|
unsigned int cardversion;/* Firmware version of the token or 0. */
|
2019-06-19 08:50:40 +02:00
|
|
|
|
2016-12-28 04:29:17 +01:00
|
|
|
unsigned int card_status;
|
2019-06-19 08:50:40 +02:00
|
|
|
|
|
|
|
/* The serial number is associated with the card and not with a
|
|
|
|
* specific app. If a card uses different serial numbers for its
|
|
|
|
* applications, our code picks the serial number of a specific
|
|
|
|
* application and uses that. */
|
|
|
|
unsigned char *serialno; /* Serialnumber in raw form, allocated. */
|
|
|
|
size_t serialnolen; /* Length in octets of serialnumber. */
|
|
|
|
|
|
|
|
/* A linked list of applications used on this card. The app at the
|
|
|
|
* head of the list is the currently active app; To work with the
|
|
|
|
* other apps, switching to that app might be needed. Switching will
|
|
|
|
* put the active app at the head of the list. */
|
|
|
|
app_t app;
|
|
|
|
|
|
|
|
/* Various flags. */
|
2017-02-17 03:50:40 +01:00
|
|
|
unsigned int reset_requested:1;
|
2017-01-27 16:18:11 +01:00
|
|
|
unsigned int periodical_check_needed:1;
|
2019-06-19 08:50:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* The object describing a card's applications. A card may have
|
Spelling cleanup.
No functional changes, just fixing minor spelling issues.
---
Most of these were identified from the command line by running:
codespell \
--ignore-words-list fpr,stati,keyserver,keyservers,asign,cas,iff,ifset \
--skip '*.po,ChangeLog*,help.*.txt,*.jpg,*.eps,*.pdf,*.png,*.gpg,*.asc' \
doc g13 g10 kbx agent artwork scd tests tools am common dirmngr sm \
NEWS README README.maint TODO
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2020-02-18 15:34:42 +01:00
|
|
|
* several applications and it is usually required to explicitly
|
2019-06-19 08:50:40 +02:00
|
|
|
* switch between applications. */
|
|
|
|
struct app_ctx_s {
|
2019-06-21 10:23:35 +02:00
|
|
|
app_t next;
|
2019-06-19 08:50:40 +02:00
|
|
|
|
|
|
|
card_t card; /* Link back to the card. */
|
|
|
|
|
2019-06-19 14:30:16 +02:00
|
|
|
apptype_t apptype; /* The type of the application. */
|
2019-06-19 08:50:40 +02:00
|
|
|
unsigned int appversion; /* Version of the application or 0. */
|
2015-04-14 07:17:03 +02:00
|
|
|
unsigned int did_chv1:1;
|
|
|
|
unsigned int force_chv1:1; /* True if the card does not cache CHV1. */
|
|
|
|
unsigned int did_chv2:1;
|
|
|
|
unsigned int did_chv3:1;
|
2021-04-01 10:31:52 +02:00
|
|
|
unsigned int need_reset:1; /* Do't allow any functions but deinit. */
|
2004-04-26 20:28:06 +02:00
|
|
|
struct app_local_s *app_local; /* Local to the application. */
|
2003-08-05 19:11:04 +02:00
|
|
|
struct {
|
2004-04-26 20:28:06 +02:00
|
|
|
void (*deinit) (app_t app);
|
2020-01-07 18:45:33 +01:00
|
|
|
gpg_error_t (*prep_reselect) (app_t app, ctrl_t ctrl);
|
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 <wk@gnupg.org>
2019-06-25 08:30:04 +02:00
|
|
|
gpg_error_t (*reselect) (app_t app, ctrl_t ctrl);
|
2009-03-18 12:18:56 +01:00
|
|
|
gpg_error_t (*learn_status) (app_t app, ctrl_t ctrl, unsigned int flags);
|
2005-05-18 12:48:06 +02:00
|
|
|
gpg_error_t (*readcert) (app_t app, const char *certid,
|
2004-01-27 17:40:42 +01:00
|
|
|
unsigned char **cert, size_t *certlen);
|
2019-04-03 17:31:09 +02:00
|
|
|
gpg_error_t (*readkey) (app_t app, ctrl_t ctrl,
|
|
|
|
const char *certid, unsigned int flags,
|
|
|
|
unsigned char **pk, size_t *pklen);
|
2005-05-18 12:48:06 +02:00
|
|
|
gpg_error_t (*getattr) (app_t app, ctrl_t ctrl, const char *name);
|
2020-01-07 18:45:33 +01:00
|
|
|
gpg_error_t (*setattr) (app_t app, ctrl_t ctrl, const char *name,
|
2005-05-18 12:48:06 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-08-05 19:11:04 +02:00
|
|
|
void *pincb_arg,
|
|
|
|
const unsigned char *value, size_t valuelen);
|
2020-01-07 18:45:33 +01:00
|
|
|
gpg_error_t (*sign) (app_t app, ctrl_t ctrl,
|
2003-08-05 19:11:04 +02:00
|
|
|
const char *keyidstr, int hashalgo,
|
2005-05-18 12:48:06 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-08-05 19:11:04 +02:00
|
|
|
void *pincb_arg,
|
|
|
|
const void *indata, size_t indatalen,
|
|
|
|
unsigned char **outdata, size_t *outdatalen );
|
2020-01-07 18:45:33 +01:00
|
|
|
gpg_error_t (*auth) (app_t app, ctrl_t ctrl, const char *keyidstr,
|
2005-05-18 12:48:06 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-08-05 19:11:04 +02:00
|
|
|
void *pincb_arg,
|
|
|
|
const void *indata, size_t indatalen,
|
|
|
|
unsigned char **outdata, size_t *outdatalen);
|
2020-01-07 18:45:33 +01:00
|
|
|
gpg_error_t (*decipher) (app_t app, ctrl_t ctrl, const char *keyidstr,
|
2013-08-26 17:29:54 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
|
|
|
void *pincb_arg,
|
|
|
|
const void *indata, size_t indatalen,
|
|
|
|
unsigned char **outdata, size_t *outdatalen,
|
|
|
|
unsigned int *r_info);
|
2008-09-23 11:57:45 +02:00
|
|
|
gpg_error_t (*writecert) (app_t app, ctrl_t ctrl,
|
|
|
|
const char *certid,
|
|
|
|
gpg_error_t (*pincb)(void*,const char *,char **),
|
|
|
|
void *pincb_arg,
|
|
|
|
const unsigned char *data, size_t datalen);
|
2005-05-20 22:39:36 +02:00
|
|
|
gpg_error_t (*writekey) (app_t app, ctrl_t ctrl,
|
2008-09-23 11:57:45 +02:00
|
|
|
const char *keyid, unsigned int flags,
|
2005-05-20 22:39:36 +02:00
|
|
|
gpg_error_t (*pincb)(void*,const char *,char **),
|
|
|
|
void *pincb_arg,
|
|
|
|
const unsigned char *pk, size_t pklen);
|
2005-05-18 12:48:06 +02:00
|
|
|
gpg_error_t (*genkey) (app_t app, ctrl_t ctrl,
|
2019-02-06 14:07:42 +01:00
|
|
|
const char *keyref, const char *keytype,
|
|
|
|
unsigned int flags, time_t createtime,
|
2007-07-05 18:58:19 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
|
|
|
void *pincb_arg);
|
2005-05-18 12:48:06 +02:00
|
|
|
gpg_error_t (*change_pin) (app_t app, ctrl_t ctrl,
|
2008-06-24 18:00:29 +02:00
|
|
|
const char *chvnostr, unsigned int flags,
|
2005-05-18 12:48:06 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-08-05 19:11:04 +02:00
|
|
|
void *pincb_arg);
|
2020-01-07 18:45:33 +01:00
|
|
|
gpg_error_t (*check_pin) (app_t app, ctrl_t ctrl, const char *keyidstr,
|
2005-05-18 12:48:06 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-10-21 19:12:50 +02:00
|
|
|
void *pincb_arg);
|
2019-06-17 14:35:21 +02:00
|
|
|
gpg_error_t (*with_keygrip) (app_t app, ctrl_t ctrl, int action,
|
2019-12-19 09:30:59 +01:00
|
|
|
const char *keygrip_str, int capability);
|
2021-07-06 07:52:29 +02:00
|
|
|
gpg_error_t (*check_aid) (app_t app, ctrl_t ctrl,
|
|
|
|
const unsigned char *aid, size_t aidlen);
|
2003-08-05 19:11:04 +02:00
|
|
|
} fnc;
|
|
|
|
};
|
|
|
|
|
2019-06-17 14:35:21 +02:00
|
|
|
|
|
|
|
/* Action values for app_do_with_keygrip. */
|
2019-04-25 07:49:49 +02:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
KEYGRIP_ACTION_SEND_DATA,
|
|
|
|
KEYGRIP_ACTION_WRITE_STATUS,
|
|
|
|
KEYGRIP_ACTION_LOOKUP
|
|
|
|
};
|
|
|
|
|
2019-06-17 14:35:21 +02:00
|
|
|
|
2019-06-19 08:50:40 +02:00
|
|
|
/* Helper to get the slot from an APP object. */
|
|
|
|
static inline int
|
|
|
|
app_get_slot (app_t app)
|
|
|
|
{
|
|
|
|
if (app && app->card)
|
|
|
|
return app->card->slot;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-19 10:15:54 +01:00
|
|
|
/* Macro to access members in app->card. We use this macro because in
|
|
|
|
* 2.2 many members are stored directly in app_t and this way we can
|
|
|
|
* easier backport stuff. */
|
|
|
|
#define APP_CARD(a) ((a)->card)
|
|
|
|
|
|
|
|
|
2004-03-16 19:59:21 +01:00
|
|
|
/*-- app-help.c --*/
|
2009-05-08 17:07:45 +02:00
|
|
|
unsigned int app_help_count_bits (const unsigned char *a, size_t len);
|
2019-04-03 17:31:09 +02:00
|
|
|
gpg_error_t app_help_get_keygrip_string_pk (const void *pk, size_t pklen,
|
2020-03-31 19:55:15 +02:00
|
|
|
char *hexkeygrip,
|
2020-05-05 08:07:11 +02:00
|
|
|
gcry_sexp_t *r_pkey,
|
2020-09-21 14:47:53 +02:00
|
|
|
int *r_algo, char **r_algostr);
|
2020-03-31 19:55:15 +02:00
|
|
|
gpg_error_t app_help_get_keygrip_string (ksba_cert_t cert, char *hexkeygrip,
|
2020-05-05 08:07:11 +02:00
|
|
|
gcry_sexp_t *r_pkey, int *r_algo);
|
2019-02-26 16:42:50 +01:00
|
|
|
gpg_error_t app_help_pubkey_from_cert (const void *cert, size_t certlen,
|
|
|
|
unsigned char **r_pk, size_t *r_pklen);
|
2004-03-16 19:59:21 +01:00
|
|
|
size_t app_help_read_length_of_cert (int slot, int fid, size_t *r_certoff);
|
|
|
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
/*-- app.c --*/
|
2019-06-19 14:30:16 +02:00
|
|
|
const char *strcardtype (cardtype_t t);
|
|
|
|
const char *strapptype (apptype_t t);
|
|
|
|
|
2019-03-28 17:05:20 +01:00
|
|
|
void app_update_priority_list (const char *arg);
|
2019-06-25 09:23:38 +02:00
|
|
|
gpg_error_t app_send_card_list (ctrl_t ctrl);
|
2020-01-16 19:42:16 +01:00
|
|
|
gpg_error_t app_send_active_apps (card_t card, ctrl_t ctrl);
|
2020-11-24 18:02:05 +01:00
|
|
|
char *card_get_serialno (card_t card);
|
2017-01-18 07:48:50 +01:00
|
|
|
char *app_get_serialno (app_t app);
|
2020-11-24 18:02:05 +01:00
|
|
|
char *card_get_dispserialno (card_t card, int nofallback);
|
|
|
|
char *app_get_dispserialno (app_t app, int nofallback);
|
scd: Support multiple readers by CCID driver.
* scd/apdu.c (new_reader_slot): Lock is now in apdu_dev_list_start.
(close_pcsc_reader_direct, close_ccid_reader): RDRNAME is handled...
(apdu_close_reader): ... by this function now.
(apdu_prepare_exit): Likewise.
(open_ccid_reader): Open with dev_list.
(apdu_dev_list_start, apdu_dev_list_finish): New.
(apdu_open_one_reader): New.
(apdu_open_reader): Support multiple readers.
* scd/app.c (select_application): With SCAN, opening all readers
available, and register as new APP.
(app_write_learn_status): app->ref_count == 0 is valid for APP which is
not yet used.
(app_list_start, app_list_finish): New.
* scd/ccid-driver.c (struct ccid_driver_s): Remove RID and BCD_DEVICE.
Add BAI.
(parse_ccid_descriptor): BCD_DEVICE is now on the arguments.
(ccid_dev_scan, ccid_dev_scan_finish): New.
(ccid_get_BAI, ccid_compare_BAI, ccid_open_usb_reader): New.
(ccid_open_reader): Support multiple readers.
(ccid_set_progress_cb, ccid_close_reader): No RID any more.
--
With this change, multiple readers/tokens are supported by the internal
CCID driver of GnuPG. Until the changes of upper layers (scdaemon,
gpg-agent, and gpg front end), only a single reader is used, though.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-01-06 01:14:13 +01:00
|
|
|
|
2005-06-03 15:57:24 +02:00
|
|
|
void app_dump_state (void);
|
2008-11-03 20:09:34 +01:00
|
|
|
void application_notify_card_reset (int slot);
|
2019-06-25 09:48:18 +02:00
|
|
|
gpg_error_t check_application_conflict (card_t card, const char *name,
|
|
|
|
const unsigned char *serialno_bin,
|
|
|
|
size_t serialno_bin_len);
|
scd: Fix access to list of cards (3/3).
* scd/app-common.h (card_reset): Simplify more.
(select_additional_application): Supply CARD.
(card_ref, card_unref): Remove.
(card_get, card_put): New.
* scd/app.c (card_reset): No locking/unlocking inside.
(app_switch_current_card): Fix comment.
(select_additional_application): No locking/unlocking inside.
(do_with_keygrip): New, unlocked version.
(card_get): New, with support of KEYGRIP.
(card_unref): Remove.
(card_put): New.
(app_write_learn_status, app_readcert: No locking/unlocking inside.
(app_readkey, app_getattr, app_setattr, app_sign, app_auth): Likewise.
(app_decipher, app_writecert, app_writekey): Likewise.
(app_genkey, app_get_challenge, app_change_pin): Likewise.
(app_check_pin, app_switch_active_app): Likewise.
* scd/command.c (do_reset): Use card_get/card_put.
(open_card_with_request): Use card_get/card_put, return CARD locked.
(cmd_serialno): Follow the change of open_card_with_request.
(cmd_switchapp): Use card_get/card_put.
(cmd_learn, cmd_readcert, cmd_readkey, cmd_pksign): Likewise.
(cmd_pkauth, cmd_pkdecrypt, cmd_getattr): Likewise.
(cmd_setattr, cmd_writecert, cmd_writekey): Likewise.
(cmd_genkey, cmd_random, cmd_passwd): Likewise.
(cmd_checkpin, cmd_getinfo, cmd_restart): Likewise.
(cmd_disconnect, cmd_apdu, cmd_devinfo): Likewise.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2021-07-21 10:08:40 +02:00
|
|
|
gpg_error_t card_reset (card_t card);
|
2021-07-21 08:34:34 +02:00
|
|
|
gpg_error_t select_application (ctrl_t ctrl, const char *name,
|
scd: Add --demand option for SERIALNO.
* scd/app.c (select_application): Add SERIALNO_BIN and SERIALNO_BIN_LEN
arguments. Return matched APP with a serial number when specified.
* scd/command.c (open_card): Modify for the implicit open only.
(open_card_with_request): New for explicit open and support match with a
serial number.
(cmd_serialno): Support --demand option.
(cmd_learn, cmd_readcert, cmd_readkey, cmd_pksign, cmd_pkauth)
(cmd_pkdecrypt, cmd_getattr, cmd_setattr, cmd_writecert, cmd_writekey)
(cmd_genkey, cmd_random, cmd_passwd, cmd_checkpin, cmd_apdu): Follow
the change of open_card.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-01-16 02:26:16 +01:00
|
|
|
int scan, const unsigned char *serialno_bin,
|
|
|
|
size_t serialno_bin_len);
|
scd: Fix access to list of cards (3/3).
* scd/app-common.h (card_reset): Simplify more.
(select_additional_application): Supply CARD.
(card_ref, card_unref): Remove.
(card_get, card_put): New.
* scd/app.c (card_reset): No locking/unlocking inside.
(app_switch_current_card): Fix comment.
(select_additional_application): No locking/unlocking inside.
(do_with_keygrip): New, unlocked version.
(card_get): New, with support of KEYGRIP.
(card_unref): Remove.
(card_put): New.
(app_write_learn_status, app_readcert: No locking/unlocking inside.
(app_readkey, app_getattr, app_setattr, app_sign, app_auth): Likewise.
(app_decipher, app_writecert, app_writekey): Likewise.
(app_genkey, app_get_challenge, app_change_pin): Likewise.
(app_check_pin, app_switch_active_app): Likewise.
* scd/command.c (do_reset): Use card_get/card_put.
(open_card_with_request): Use card_get/card_put, return CARD locked.
(cmd_serialno): Follow the change of open_card_with_request.
(cmd_switchapp): Use card_get/card_put.
(cmd_learn, cmd_readcert, cmd_readkey, cmd_pksign): Likewise.
(cmd_pkauth, cmd_pkdecrypt, cmd_getattr): Likewise.
(cmd_setattr, cmd_writecert, cmd_writekey): Likewise.
(cmd_genkey, cmd_random, cmd_passwd): Likewise.
(cmd_checkpin, cmd_getinfo, cmd_restart): Likewise.
(cmd_disconnect, cmd_apdu, cmd_devinfo): Likewise.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2021-07-21 10:08:40 +02:00
|
|
|
gpg_error_t select_additional_application (card_t card,
|
|
|
|
ctrl_t ctrl, const char *name);
|
2020-01-16 19:42:16 +01:00
|
|
|
|
|
|
|
gpg_error_t app_switch_current_card (ctrl_t ctrl,
|
|
|
|
const unsigned char *serialno,
|
|
|
|
size_t serialnolen);
|
|
|
|
gpg_error_t app_switch_active_app (card_t card, ctrl_t ctrl,
|
|
|
|
const char *appname);
|
|
|
|
|
2009-02-27 15:36:59 +01:00
|
|
|
char *get_supported_applications (void);
|
2019-06-17 16:19:22 +02:00
|
|
|
|
scd: Fix access to list of cards (3/3).
* scd/app-common.h (card_reset): Simplify more.
(select_additional_application): Supply CARD.
(card_ref, card_unref): Remove.
(card_get, card_put): New.
* scd/app.c (card_reset): No locking/unlocking inside.
(app_switch_current_card): Fix comment.
(select_additional_application): No locking/unlocking inside.
(do_with_keygrip): New, unlocked version.
(card_get): New, with support of KEYGRIP.
(card_unref): Remove.
(card_put): New.
(app_write_learn_status, app_readcert: No locking/unlocking inside.
(app_readkey, app_getattr, app_setattr, app_sign, app_auth): Likewise.
(app_decipher, app_writecert, app_writekey): Likewise.
(app_genkey, app_get_challenge, app_change_pin): Likewise.
(app_check_pin, app_switch_active_app): Likewise.
* scd/command.c (do_reset): Use card_get/card_put.
(open_card_with_request): Use card_get/card_put, return CARD locked.
(cmd_serialno): Follow the change of open_card_with_request.
(cmd_switchapp): Use card_get/card_put.
(cmd_learn, cmd_readcert, cmd_readkey, cmd_pksign): Likewise.
(cmd_pkauth, cmd_pkdecrypt, cmd_getattr): Likewise.
(cmd_setattr, cmd_writecert, cmd_writekey): Likewise.
(cmd_genkey, cmd_random, cmd_passwd): Likewise.
(cmd_checkpin, cmd_getinfo, cmd_restart): Likewise.
(cmd_disconnect, cmd_apdu, cmd_devinfo): Likewise.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2021-07-21 10:08:40 +02:00
|
|
|
card_t card_get (ctrl_t ctrl, const char *keygrip);
|
|
|
|
void card_put (card_t card);
|
2019-06-19 08:50:40 +02:00
|
|
|
void card_unref_locked (card_t card);
|
2019-06-17 16:19:22 +02:00
|
|
|
|
2019-06-19 08:50:40 +02:00
|
|
|
gpg_error_t app_munge_serialno (card_t card);
|
|
|
|
gpg_error_t app_write_learn_status (card_t card, ctrl_t ctrl,
|
2009-03-18 12:18:56 +01:00
|
|
|
unsigned int flags);
|
2019-06-19 08:50:40 +02:00
|
|
|
gpg_error_t app_readcert (card_t card, ctrl_t ctrl, const char *certid,
|
2004-01-27 17:40:42 +01:00
|
|
|
unsigned char **cert, size_t *certlen);
|
2019-06-19 08:50:40 +02:00
|
|
|
gpg_error_t app_readkey (card_t card, ctrl_t ctrl,
|
2019-04-03 17:31:09 +02:00
|
|
|
const char *keyid, unsigned int flags,
|
|
|
|
unsigned char **pk, size_t *pklen);
|
2019-06-19 08:50:40 +02:00
|
|
|
gpg_error_t app_getattr (card_t card, ctrl_t ctrl, const char *name);
|
|
|
|
gpg_error_t app_setattr (card_t card, ctrl_t ctrl, const char *name,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
|
|
|
void *pincb_arg,
|
|
|
|
const unsigned char *value, size_t valuelen);
|
|
|
|
gpg_error_t app_sign (card_t card, ctrl_t ctrl,
|
|
|
|
const char *keyidstr, int hashalgo,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
|
|
|
void *pincb_arg,
|
|
|
|
const void *indata, size_t indatalen,
|
|
|
|
unsigned char **outdata, size_t *outdatalen);
|
|
|
|
gpg_error_t app_auth (card_t card, ctrl_t ctrl, const char *keyidstr,
|
2013-08-26 17:29:54 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
|
|
|
void *pincb_arg,
|
|
|
|
const void *indata, size_t indatalen,
|
|
|
|
unsigned char **outdata, size_t *outdatalen);
|
2019-06-19 08:50:40 +02:00
|
|
|
gpg_error_t app_decipher (card_t card, ctrl_t ctrl, const char *keyidstr,
|
2013-08-26 17:29:54 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
|
|
|
void *pincb_arg,
|
|
|
|
const void *indata, size_t indatalen,
|
|
|
|
unsigned char **outdata, size_t *outdatalen,
|
|
|
|
unsigned int *r_info);
|
2019-06-19 08:50:40 +02:00
|
|
|
gpg_error_t app_writecert (card_t card, ctrl_t ctrl,
|
2008-09-23 11:57:45 +02:00
|
|
|
const char *certidstr,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
|
|
|
void *pincb_arg,
|
|
|
|
const unsigned char *keydata, size_t keydatalen);
|
2019-06-19 08:50:40 +02:00
|
|
|
gpg_error_t app_writekey (card_t card, ctrl_t ctrl,
|
2005-05-20 22:39:36 +02:00
|
|
|
const char *keyidstr, unsigned int flags,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
|
|
|
void *pincb_arg,
|
|
|
|
const unsigned char *keydata, size_t keydatalen);
|
2019-06-19 08:50:40 +02:00
|
|
|
gpg_error_t app_genkey (card_t card, ctrl_t ctrl,
|
2019-02-06 14:07:42 +01:00
|
|
|
const char *keynostr, const char *keytype,
|
|
|
|
unsigned int flags, time_t createtime,
|
2007-07-05 18:58:19 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
|
|
|
void *pincb_arg);
|
2019-06-19 08:50:40 +02:00
|
|
|
gpg_error_t app_get_challenge (card_t card, ctrl_t ctrl, size_t nbytes,
|
2005-05-18 12:48:06 +02:00
|
|
|
unsigned char *buffer);
|
2019-06-19 08:50:40 +02:00
|
|
|
gpg_error_t app_change_pin (card_t card, ctrl_t ctrl,
|
2019-02-06 12:24:30 +01:00
|
|
|
const char *chvnostr, unsigned int flags,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
|
|
|
void *pincb_arg);
|
2019-06-19 08:50:40 +02:00
|
|
|
gpg_error_t app_check_pin (card_t card, ctrl_t ctrl, const char *keyidstr,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
|
|
|
void *pincb_arg);
|
2019-12-19 09:30:59 +01:00
|
|
|
card_t app_do_with_keygrip (ctrl_t ctrl, int action, const char *keygrip_str,
|
|
|
|
int capability);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*-- app-openpgp.c --*/
|
2005-05-18 12:48:06 +02:00
|
|
|
gpg_error_t app_select_openpgp (app_t app);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
2004-01-27 17:40:42 +01:00
|
|
|
/*-- app-nks.c --*/
|
2005-05-18 12:48:06 +02:00
|
|
|
gpg_error_t app_select_nks (app_t app);
|
2004-01-27 17:40:42 +01:00
|
|
|
|
|
|
|
/*-- app-dinsig.c --*/
|
2005-05-18 12:48:06 +02:00
|
|
|
gpg_error_t app_select_dinsig (app_t app);
|
2004-01-27 17:40:42 +01:00
|
|
|
|
2004-09-09 09:28:47 +02:00
|
|
|
/*-- app-p15.c --*/
|
2005-04-27 14:09:21 +02:00
|
|
|
gpg_error_t app_select_p15 (app_t app);
|
2004-09-09 09:28:47 +02:00
|
|
|
|
2009-01-27 12:30:02 +01:00
|
|
|
/*-- app-geldkarte.c --*/
|
|
|
|
gpg_error_t app_select_geldkarte (app_t app);
|
|
|
|
|
2014-07-18 16:20:59 +02:00
|
|
|
/*-- app-sc-hsm.c --*/
|
|
|
|
gpg_error_t app_select_sc_hsm (app_t app);
|
|
|
|
|
2019-01-20 11:45:57 +01:00
|
|
|
/*-- app-piv.c --*/
|
|
|
|
gpg_error_t app_select_piv (app_t app);
|
|
|
|
|
2004-01-27 17:40:42 +01:00
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
#endif /*GNUPG_SCD_APP_COMMON_H*/
|