diff --git a/scd/app-common.h b/scd/app-common.h index e862753cf..f16c24087 100644 --- a/scd/app-common.h +++ b/scd/app-common.h @@ -38,6 +38,7 @@ /* Flags used with app_readkey. */ #define APP_READKEY_FLAG_INFO 1 /* Send also a KEYPAIRINFO line. */ +#define APP_READKEY_FLAG_ADVANCED 2 /* (gnupg 2.2 only) */ /* Bit flags set by the decipher function into R_INFO. */ #define APP_DECIPHER_INFO_NOPAD 1 /* Padding has been removed. */ @@ -121,7 +122,7 @@ struct app_ctx_s { gpg_error_t (*readcert) (app_t app, const char *certid, unsigned char **cert, size_t *certlen); gpg_error_t (*readkey) (app_t app, ctrl_t ctrl, - int advanced, const char *certid, + const char *certid, unsigned int flags, unsigned char **pk, size_t *pklen); gpg_error_t (*getattr) (app_t app, ctrl_t ctrl, const char *name); gpg_error_t (*setattr) (app_t app, ctrl_t ctrl, const char *name, diff --git a/scd/app-nks.c b/scd/app-nks.c index 451ff8f01..3cbf1e414 100644 --- a/scd/app-nks.c +++ b/scd/app-nks.c @@ -608,7 +608,7 @@ do_readcert (app_t app, const char *certid, certificate parsing code in commands.c:cmd_readkey. For internal use PK and PKLEN may be NULL to just check for an existing key. */ static gpg_error_t -do_readkey (app_t app, ctrl_t ctrl, int advanced, const char *keyid, +do_readkey (app_t app, ctrl_t ctrl, const char *keyid, unsigned int flags, unsigned char **pk, size_t *pklen) { gpg_error_t err; @@ -618,7 +618,7 @@ do_readkey (app_t app, ctrl_t ctrl, int advanced, const char *keyid, (void)ctrl; - if (advanced) + if ((flags & APP_READKEY_FLAG_ADVANCED)) return GPG_ERR_NOT_SUPPORTED; /* We use a generic name to retrieve PK.AUT.IFD-SPK. */ @@ -693,7 +693,7 @@ do_writekey (app_t app, ctrl_t ctrl, else return gpg_error (GPG_ERR_INV_ID); - if (!force && !do_readkey (app, ctrl, 0, keyid, NULL, NULL)) + if (!force && !do_readkey (app, ctrl, keyid, 0, NULL, NULL)) return gpg_error (GPG_ERR_EEXIST); /* Parse the S-expression. */ diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c index b1121723b..5a7361f73 100644 --- a/scd/app-openpgp.c +++ b/scd/app-openpgp.c @@ -1977,7 +1977,7 @@ do_learn_status (app_t app, ctrl_t ctrl, unsigned int flags) buffer. On error PK and PKLEN are not changed and an error code is returned. */ static gpg_error_t -do_readkey (app_t app, ctrl_t ctrl, int advanced, const char *keyid, +do_readkey (app_t app, ctrl_t ctrl, const char *keyid, unsigned int flags, unsigned char **pk, size_t *pklen) { gpg_error_t err; @@ -2003,7 +2003,7 @@ do_readkey (app_t app, ctrl_t ctrl, int advanced, const char *keyid, if (!buf) return gpg_error (GPG_ERR_NO_PUBKEY); - if (advanced) + if ((flags & APP_READKEY_FLAG_ADVANCED)) { gcry_sexp_t s_key; diff --git a/scd/app.c b/scd/app.c index ba8db10af..b1bc35f53 100644 --- a/scd/app.c +++ b/scd/app.c @@ -865,7 +865,9 @@ app_readkey (app_t app, ctrl_t ctrl, int advanced, const char *keyid, err = lock_app (app, ctrl); if (err) return err; - err= app->fnc.readkey (app, ctrl, advanced, keyid, pk, pklen); + err= app->fnc.readkey (app, ctrl, keyid, + advanced? APP_READKEY_FLAG_ADVANCED : 0, + pk, pklen); unlock_app (app); return err; }