mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-11 22:52:47 +01:00
agent: Show "Label:" field of private key when prompt the insertion.
* agent/findkey.c (prompt_for_card): Use "Label:" field. (agent_key_from_file): Use KEYMETA. -- GnuPG-bug-id: 5986 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
6a37240cf2
commit
5986310866
@ -965,26 +965,30 @@ remove_key_file (const unsigned char *grip)
|
|||||||
* Prompt a user the card insertion, when it's not available yet.
|
* Prompt a user the card insertion, when it's not available yet.
|
||||||
*/
|
*/
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
prompt_for_card (ctrl_t ctrl, const unsigned char *shadow_info,
|
prompt_for_card (ctrl_t ctrl, const unsigned char *grip,
|
||||||
const unsigned char *grip)
|
nvc_t keymeta, const unsigned char *shadow_info)
|
||||||
{
|
{
|
||||||
char *serialno;
|
char *serialno;
|
||||||
char *desc;
|
char *desc;
|
||||||
char *want_sn;
|
char *want_sn = NULL;
|
||||||
int len;
|
int len;
|
||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
char hexgrip[41];
|
char hexgrip[41];
|
||||||
|
char *comment_buffer = NULL;
|
||||||
|
const char *comment = NULL;
|
||||||
|
|
||||||
bin2hex (grip, 20, hexgrip);
|
bin2hex (grip, 20, hexgrip);
|
||||||
|
|
||||||
if (shadow_info)
|
if (keymeta && (comment = nvc_get_string (keymeta, "Label:")))
|
||||||
{
|
{
|
||||||
|
if (strchr (comment, '\n')
|
||||||
|
&& (comment_buffer = linefeed_to_percent0A (comment)))
|
||||||
|
comment = comment_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
err = parse_shadow_info (shadow_info, &want_sn, NULL, NULL);
|
err = parse_shadow_info (shadow_info, &want_sn, NULL, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
else
|
|
||||||
want_sn = NULL;
|
|
||||||
|
|
||||||
len = want_sn? strlen (want_sn) : 0;
|
len = want_sn? strlen (want_sn) : 0;
|
||||||
if (len == 32 && !strncmp (want_sn, "D27600012401", 12))
|
if (len == 32 && !strncmp (want_sn, "D27600012401", 12))
|
||||||
@ -1031,23 +1035,20 @@ prompt_for_card (ctrl_t ctrl, const unsigned char *shadow_info,
|
|||||||
err = agent_card_keyinfo (ctrl, hexgrip, 0, &keyinfo);
|
err = agent_card_keyinfo (ctrl, hexgrip, 0, &keyinfo);
|
||||||
if (!err)
|
if (!err)
|
||||||
{
|
{
|
||||||
/* Key for GRIP found, use it directly. */
|
/* Key for GRIP found, use it. */
|
||||||
agent_card_free_keyinfo (keyinfo);
|
agent_card_free_keyinfo (keyinfo);
|
||||||
xfree (want_sn);
|
break;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!want_sn)
|
/* Card is not available. Prompt the insertion. */
|
||||||
; /* No shadow info so we can't ask; ERR is already set. */
|
if (asprintf (&desc,
|
||||||
else if (asprintf (&desc,
|
|
||||||
"%s:%%0A%%0A"
|
"%s:%%0A%%0A"
|
||||||
|
" %s%%0A"
|
||||||
" %s",
|
" %s",
|
||||||
L_("Please insert the card with serial number"),
|
L_("Please insert the card with serial number"),
|
||||||
want_sn) < 0)
|
want_sn ? want_sn : "", comment) < 0)
|
||||||
{
|
|
||||||
err = out_of_core ();
|
err = out_of_core ();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
err = agent_get_confirmation (ctrl, desc, NULL, NULL, 0);
|
err = agent_get_confirmation (ctrl, desc, NULL, NULL, 0);
|
||||||
@ -1059,12 +1060,13 @@ prompt_for_card (ctrl_t ctrl, const unsigned char *shadow_info,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
{
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
xfree (want_sn);
|
xfree (want_sn);
|
||||||
|
gcry_free (comment_buffer);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Return the secret key as an S-Exp in RESULT after locating it using
|
/* Return the secret key as an S-Exp in RESULT after locating it using
|
||||||
@ -1271,7 +1273,8 @@ agent_key_from_file (ctrl_t ctrl, const char *cache_nonce,
|
|||||||
* it's available.
|
* it's available.
|
||||||
*/
|
*/
|
||||||
if (strcmp (shadow_type, "t1-v1") == 0 && !grip)
|
if (strcmp (shadow_type, "t1-v1") == 0 && !grip)
|
||||||
err = prompt_for_card (ctrl, *shadow_info, ctrl->keygrip);
|
err = prompt_for_card (ctrl, ctrl->keygrip,
|
||||||
|
keymeta, *shadow_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user