mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
gpg: Allow decryption w/o public key but with correct card inserted.
* agent/command.c (cmd_readkey): Add option --no-data and special handling for $SIGNKEYID and $AUTHKEYID. * g10/call-agent.c (agent_scd_getattr): Create shadow keys for KEY-FPR output. * g10/skclist.c (enum_secret_keys): Automagically get a missing public key for the current card. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
84c2d97cca
commit
50293ec2eb
3 changed files with 64 additions and 5 deletions
|
@ -1073,8 +1073,8 @@ cmd_genkey (assuan_context_t ctx, char *line)
|
|||
|
||||
|
||||
static const char hlp_readkey[] =
|
||||
"READKEY <hexstring_with_keygrip>\n"
|
||||
" --card <keyid>\n"
|
||||
"READKEY [--no-data] <hexstring_with_keygrip>\n"
|
||||
" --card <keyid>\n"
|
||||
"\n"
|
||||
"Return the public key for the given keygrip or keyid.\n"
|
||||
"With --card, private key file with card information will be created.";
|
||||
|
@ -1087,12 +1087,14 @@ cmd_readkey (assuan_context_t ctx, char *line)
|
|||
gcry_sexp_t s_pkey = NULL;
|
||||
unsigned char *pkbuf = NULL;
|
||||
char *serialno = NULL;
|
||||
char *keyidbuf = NULL;
|
||||
size_t pkbuflen;
|
||||
int opt_card;
|
||||
int opt_card, opt_no_data;
|
||||
|
||||
if (ctrl->restricted)
|
||||
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
||||
|
||||
opt_no_data = has_option (line, "--no-data");
|
||||
opt_card = has_option (line, "--card");
|
||||
line = skip_options (line);
|
||||
|
||||
|
@ -1108,6 +1110,11 @@ cmd_readkey (assuan_context_t ctx, char *line)
|
|||
goto leave;
|
||||
}
|
||||
|
||||
/* Hack to create the shadow key for the OpenPGP standard keys. */
|
||||
if ((!strcmp (keyid, "$SIGNKEYID") || !strcmp (keyid, "$ENCRKEYID"))
|
||||
&& !agent_card_getattr (ctrl, keyid, &keyidbuf, NULL))
|
||||
keyid = keyidbuf;
|
||||
|
||||
rc = agent_card_readkey (ctrl, keyid, &pkbuf, NULL);
|
||||
if (rc)
|
||||
goto leave;
|
||||
|
@ -1133,7 +1140,7 @@ cmd_readkey (assuan_context_t ctx, char *line)
|
|||
goto leave;
|
||||
}
|
||||
|
||||
rc = assuan_send_data (ctx, pkbuf, pkbuflen);
|
||||
rc = opt_no_data? 0 : assuan_send_data (ctx, pkbuf, pkbuflen);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1153,12 +1160,13 @@ cmd_readkey (assuan_context_t ctx, char *line)
|
|||
{
|
||||
pkbuflen = gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON,
|
||||
pkbuf, pkbuflen);
|
||||
rc = assuan_send_data (ctx, pkbuf, pkbuflen);
|
||||
rc = opt_no_data? 0 : assuan_send_data (ctx, pkbuf, pkbuflen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
leave:
|
||||
xfree (keyidbuf);
|
||||
xfree (serialno);
|
||||
xfree (pkbuf);
|
||||
gcry_sexp_release (s_pkey);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue