mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
agent: Ask specific SERIALNO for pksign/pkdecrypt.
* agent/call-scd.c (agent_card_serialno): Add DEMAND argument. * agent/command-ssh.c (card_key_available): Follow the change. * agent/learncard.c (agent_handle_learn): Likewise. * agent/divert-scd.c (ask_for_card): Use DEMAND argument. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
2e6f1c99d4
commit
0801f49b0d
@ -532,7 +532,7 @@ int agent_card_learn (ctrl_t ctrl,
|
||||
void (*sinfo_cb)(void*, const char *,
|
||||
size_t, const char *),
|
||||
void *sinfo_cb_arg);
|
||||
int agent_card_serialno (ctrl_t ctrl, char **r_serialno);
|
||||
int agent_card_serialno (ctrl_t ctrl, char **r_serialno, const char *demand);
|
||||
int agent_card_pksign (ctrl_t ctrl,
|
||||
const char *keyid,
|
||||
int (*getpin_cb)(void *, const char *, char*, size_t),
|
||||
|
@ -679,16 +679,22 @@ get_serialno_cb (void *opaque, const char *line)
|
||||
/* Return the serial number of the card or an appropriate error. The
|
||||
serial number is returned as a hexstring. */
|
||||
int
|
||||
agent_card_serialno (ctrl_t ctrl, char **r_serialno)
|
||||
agent_card_serialno (ctrl_t ctrl, char **r_serialno, const char *demand)
|
||||
{
|
||||
int rc;
|
||||
char *serialno = NULL;
|
||||
char line[ASSUAN_LINELENGTH];
|
||||
|
||||
rc = start_scd (ctrl);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
rc = assuan_transact (ctrl->scd_local->ctx, "SERIALNO",
|
||||
if (!demand)
|
||||
strcpy (line, "SERIALNO");
|
||||
else
|
||||
snprintf (line, DIM(line), "SERIALNO --demand=%s", demand);
|
||||
|
||||
rc = assuan_transact (ctrl->scd_local->ctx, line,
|
||||
NULL, NULL, NULL, NULL,
|
||||
get_serialno_cb, &serialno);
|
||||
if (rc)
|
||||
|
@ -2408,7 +2408,7 @@ card_key_available (ctrl_t ctrl, gcry_sexp_t *r_pk, char **cardsn)
|
||||
if ( gpg_err_code (err) == GPG_ERR_CARD_REMOVED )
|
||||
{
|
||||
/* Ask for the serial number to reset the card. */
|
||||
err = agent_card_serialno (ctrl, &serialno);
|
||||
err = agent_card_serialno (ctrl, &serialno, NULL);
|
||||
if (err)
|
||||
{
|
||||
if (opt.verbose)
|
||||
|
@ -58,7 +58,7 @@ ask_for_card (ctrl_t ctrl, const unsigned char *shadow_info, char **r_kid)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
rc = agent_card_serialno (ctrl, &serialno);
|
||||
rc = agent_card_serialno (ctrl, &serialno, want_sn);
|
||||
if (!rc)
|
||||
{
|
||||
log_debug ("detected card with S/N %s\n", serialno);
|
||||
@ -72,11 +72,17 @@ ask_for_card (ctrl_t ctrl, const unsigned char *shadow_info, char **r_kid)
|
||||
return 0; /* yes, we have the correct card */
|
||||
}
|
||||
}
|
||||
else if (gpg_err_code (rc) == GPG_ERR_ENODEV)
|
||||
{
|
||||
log_debug ("no device present\n");
|
||||
rc = 0;
|
||||
no_card = 1;
|
||||
}
|
||||
else if (gpg_err_code (rc) == GPG_ERR_CARD_NOT_PRESENT)
|
||||
{
|
||||
log_debug ("no card present\n");
|
||||
rc = 0;
|
||||
no_card = 1;
|
||||
no_card = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -330,7 +330,7 @@ agent_handle_learn (ctrl_t ctrl, int send, void *assuan_context, int force)
|
||||
cparm.ctrl = ctrl;
|
||||
|
||||
/* Check whether a card is present and get the serial number */
|
||||
rc = agent_card_serialno (ctrl, &serialno);
|
||||
rc = agent_card_serialno (ctrl, &serialno, NULL);
|
||||
if (rc)
|
||||
goto leave;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user