1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-09-21 15:01:41 +02:00

scd: Change parameters of readkey fucntion pointer.

* scd/app-common.h (APP_READKEY_FLAG_ADVANCED): New.
(struct app_ctx_s): Replace param advanced by flags in readkey.
Change all users.
This commit is contained in:
Werner Koch 2021-02-19 10:10:00 +01:00
parent 669786cf64
commit 41979ed730
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
4 changed files with 10 additions and 7 deletions

View File

@ -38,6 +38,7 @@
/* Flags used with app_readkey. */ /* Flags used with app_readkey. */
#define APP_READKEY_FLAG_INFO 1 /* Send also a KEYPAIRINFO line. */ #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. */ /* Bit flags set by the decipher function into R_INFO. */
#define APP_DECIPHER_INFO_NOPAD 1 /* Padding has been removed. */ #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, gpg_error_t (*readcert) (app_t app, const char *certid,
unsigned char **cert, size_t *certlen); unsigned char **cert, size_t *certlen);
gpg_error_t (*readkey) (app_t app, ctrl_t ctrl, 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); unsigned char **pk, size_t *pklen);
gpg_error_t (*getattr) (app_t app, ctrl_t ctrl, const char *name); 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, gpg_error_t (*setattr) (app_t app, ctrl_t ctrl, const char *name,

View File

@ -608,7 +608,7 @@ do_readcert (app_t app, const char *certid,
certificate parsing code in commands.c:cmd_readkey. For internal certificate parsing code in commands.c:cmd_readkey. For internal
use PK and PKLEN may be NULL to just check for an existing key. */ use PK and PKLEN may be NULL to just check for an existing key. */
static gpg_error_t 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) unsigned char **pk, size_t *pklen)
{ {
gpg_error_t err; gpg_error_t err;
@ -618,7 +618,7 @@ do_readkey (app_t app, ctrl_t ctrl, int advanced, const char *keyid,
(void)ctrl; (void)ctrl;
if (advanced) if ((flags & APP_READKEY_FLAG_ADVANCED))
return GPG_ERR_NOT_SUPPORTED; return GPG_ERR_NOT_SUPPORTED;
/* We use a generic name to retrieve PK.AUT.IFD-SPK. */ /* We use a generic name to retrieve PK.AUT.IFD-SPK. */
@ -693,7 +693,7 @@ do_writekey (app_t app, ctrl_t ctrl,
else else
return gpg_error (GPG_ERR_INV_ID); 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); return gpg_error (GPG_ERR_EEXIST);
/* Parse the S-expression. */ /* Parse the S-expression. */

View File

@ -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 buffer. On error PK and PKLEN are not changed and an error code is
returned. */ returned. */
static gpg_error_t 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) unsigned char **pk, size_t *pklen)
{ {
gpg_error_t err; gpg_error_t err;
@ -2003,7 +2003,7 @@ do_readkey (app_t app, ctrl_t ctrl, int advanced, const char *keyid,
if (!buf) if (!buf)
return gpg_error (GPG_ERR_NO_PUBKEY); return gpg_error (GPG_ERR_NO_PUBKEY);
if (advanced) if ((flags & APP_READKEY_FLAG_ADVANCED))
{ {
gcry_sexp_t s_key; gcry_sexp_t s_key;

View File

@ -865,7 +865,9 @@ app_readkey (app_t app, ctrl_t ctrl, int advanced, const char *keyid,
err = lock_app (app, ctrl); err = lock_app (app, ctrl);
if (err) if (err)
return 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); unlock_app (app);
return err; return err;
} }