mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
agent: Allow signing with card key even without a stub key.
* agent/call-scd.c (agent_card_serialno): Allow NULL for R_SERIAL. (struct readkey_status_parm_s): New. (readkey_status_cb): New. (agent_card_readkey): Add optional arg R_KEYREF and change all callers. * agent/findkey.c (key_parms_from_sexp): Allow also a "public-key". * agent/divert-scd.c (ask_for_card): Allow for SHADOW_INFO being NULL. * agent/pksign.c (agent_pksign_do): Fallback to sign with an on-card if there is no stub key yet. Create the stub key. Also fixed a misnaming between s_pkey and s_skey. -- This change allows to create OpenPGP keys directly from a card without first making sure that a stub key exists. It is also the less surprising behaviour. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
8c63430d1a
commit
638526d37f
8 changed files with 172 additions and 32 deletions
|
@ -46,11 +46,16 @@ ask_for_card (ctrl_t ctrl, const unsigned char *shadow_info,
|
|||
*r_kid = NULL;
|
||||
bin2hex (grip, 20, hexgrip);
|
||||
|
||||
err = parse_shadow_info (shadow_info, &want_sn, NULL, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
if (shadow_info)
|
||||
{
|
||||
err = parse_shadow_info (shadow_info, &want_sn, NULL, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
else
|
||||
want_sn = NULL;
|
||||
|
||||
len = strlen (want_sn);
|
||||
len = want_sn? strlen (want_sn) : 0;
|
||||
if (len == 32 && !strncmp (want_sn, "D27600012401", 12))
|
||||
{
|
||||
/* This is an OpenPGP card - reformat */
|
||||
|
@ -90,7 +95,9 @@ ask_for_card (ctrl_t ctrl, const unsigned char *shadow_info,
|
|||
}
|
||||
}
|
||||
|
||||
if (asprintf (&desc,
|
||||
if (!want_sn)
|
||||
; /* No shadow info so we can't ask; ERR is already set. */
|
||||
else if (asprintf (&desc,
|
||||
"%s:%%0A%%0A"
|
||||
" %s",
|
||||
L_("Please insert the card with serial number"),
|
||||
|
@ -407,6 +414,9 @@ getpin_cb (void *opaque, const char *desc_text, const char *info,
|
|||
* smartcard. DESC_TEXT is the original text for a prompt has send by
|
||||
* gpg to gpg-agent.
|
||||
*
|
||||
* Note: If SHADOW_INFO is NULL the user can't be asked to insert the
|
||||
* card, we simply try to use an inserted card with the given keygrip.
|
||||
*
|
||||
* FIXME: Explain the other args. */
|
||||
int
|
||||
divert_pksign (ctrl_t ctrl, const char *desc_text, const unsigned char *grip,
|
||||
|
@ -424,6 +434,8 @@ divert_pksign (ctrl_t ctrl, const char *desc_text, const unsigned char *grip,
|
|||
rc = ask_for_card (ctrl, shadow_info, grip, &kid);
|
||||
if (rc)
|
||||
return rc;
|
||||
/* Note that the KID may be an keyref or a keygrip. The signing
|
||||
* functions handle both. */
|
||||
|
||||
if (algo == MD_USER_TLS_MD5SHA1)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue