mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-18 14:17:03 +01:00
scd:openpgp: Let the genkey function also accept a full keyref.
* scd/app-openpgp.c (send_key_attr): Use log_assert. (do_genkey): Allow prefix. -- It is more uniform to always use full keyref (e.g. "OPENPGP.1") instead of just the key number. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
332a72f734
commit
fb6ff7ead7
@ -2171,7 +2171,7 @@ static struct gnupg_compliance_option compliance_options[] =
|
|||||||
static void
|
static void
|
||||||
set_compliance_option (enum cmd_and_opt_values option)
|
set_compliance_option (enum cmd_and_opt_values option)
|
||||||
{
|
{
|
||||||
opt.flags.rfc4880bis = 0; /* Clear becuase it is initially set. */
|
opt.flags.rfc4880bis = 0; /* Clear because it is initially set. */
|
||||||
|
|
||||||
switch (option)
|
switch (option)
|
||||||
{
|
{
|
||||||
|
@ -955,8 +955,12 @@ send_key_attr (ctrl_t ctrl, app_t app, const char *keyword, int keyno)
|
|||||||
{
|
{
|
||||||
char buffer[200];
|
char buffer[200];
|
||||||
|
|
||||||
assert (keyno >=0 && keyno < DIM(app->app_local->keyattr));
|
log_assert (keyno >=0 && keyno < DIM(app->app_local->keyattr));
|
||||||
|
|
||||||
|
/* Note that the code in gpg-card supports prefixing the key number
|
||||||
|
* with "OPENPGP." but older code does not yet support this. There
|
||||||
|
* is also a discrepancy with the algorithm numbers: We should use
|
||||||
|
* the gcrypt numbers but the current code assumes OpenPGP numbers. */
|
||||||
if (app->app_local->keyattr[keyno].key_type == KEY_TYPE_RSA)
|
if (app->app_local->keyattr[keyno].key_type == KEY_TYPE_RSA)
|
||||||
snprintf (buffer, sizeof buffer, "%d 1 rsa%u %u %d",
|
snprintf (buffer, sizeof buffer, "%d 1 rsa%u %u %d",
|
||||||
keyno+1,
|
keyno+1,
|
||||||
@ -4311,7 +4315,7 @@ do_genkey (app_t app, ctrl_t ctrl, const char *keynostr, const char *keytype,
|
|||||||
const unsigned char *keydata;
|
const unsigned char *keydata;
|
||||||
size_t buflen, keydatalen;
|
size_t buflen, keydatalen;
|
||||||
u32 created_at;
|
u32 created_at;
|
||||||
int keyno = atoi (keynostr) - 1;
|
int keyno;
|
||||||
int force = (flags & 1);
|
int force = (flags & 1);
|
||||||
time_t start_at;
|
time_t start_at;
|
||||||
int exmode = 0;
|
int exmode = 0;
|
||||||
@ -4319,7 +4323,12 @@ do_genkey (app_t app, ctrl_t ctrl, const char *keynostr, const char *keytype,
|
|||||||
|
|
||||||
(void)keytype; /* Ignored for OpenPGP cards. */
|
(void)keytype; /* Ignored for OpenPGP cards. */
|
||||||
|
|
||||||
if (keyno < 0 || keyno > 2)
|
/* Strip the OpenPGP prefix which is for historical reasons optional. */
|
||||||
|
if (!ascii_strncasecmp (keynostr, "OPENPGP.", 8))
|
||||||
|
keynostr += 8;
|
||||||
|
|
||||||
|
keyno = atoi (keynostr) - 1;
|
||||||
|
if (!digitp (keynostr) || keyno < 0 || keyno > 2)
|
||||||
return gpg_error (GPG_ERR_INV_ID);
|
return gpg_error (GPG_ERR_INV_ID);
|
||||||
|
|
||||||
/* We flush the cache to increase the traffic before a key
|
/* We flush the cache to increase the traffic before a key
|
||||||
|
Loading…
x
Reference in New Issue
Block a user