mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-18 14:17:03 +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 *,
|
void (*sinfo_cb)(void*, const char *,
|
||||||
size_t, const char *),
|
size_t, const char *),
|
||||||
void *sinfo_cb_arg);
|
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,
|
int agent_card_pksign (ctrl_t ctrl,
|
||||||
const char *keyid,
|
const char *keyid,
|
||||||
int (*getpin_cb)(void *, const char *, char*, size_t),
|
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
|
/* Return the serial number of the card or an appropriate error. The
|
||||||
serial number is returned as a hexstring. */
|
serial number is returned as a hexstring. */
|
||||||
int
|
int
|
||||||
agent_card_serialno (ctrl_t ctrl, char **r_serialno)
|
agent_card_serialno (ctrl_t ctrl, char **r_serialno, const char *demand)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
char *serialno = NULL;
|
char *serialno = NULL;
|
||||||
|
char line[ASSUAN_LINELENGTH];
|
||||||
|
|
||||||
rc = start_scd (ctrl);
|
rc = start_scd (ctrl);
|
||||||
if (rc)
|
if (rc)
|
||||||
return 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,
|
NULL, NULL, NULL, NULL,
|
||||||
get_serialno_cb, &serialno);
|
get_serialno_cb, &serialno);
|
||||||
if (rc)
|
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 )
|
if ( gpg_err_code (err) == GPG_ERR_CARD_REMOVED )
|
||||||
{
|
{
|
||||||
/* Ask for the serial number to reset the card. */
|
/* 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 (err)
|
||||||
{
|
{
|
||||||
if (opt.verbose)
|
if (opt.verbose)
|
||||||
|
@ -58,7 +58,7 @@ ask_for_card (ctrl_t ctrl, const unsigned char *shadow_info, char **r_kid)
|
|||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
rc = agent_card_serialno (ctrl, &serialno);
|
rc = agent_card_serialno (ctrl, &serialno, want_sn);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
{
|
{
|
||||||
log_debug ("detected card with S/N %s\n", serialno);
|
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 */
|
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)
|
else if (gpg_err_code (rc) == GPG_ERR_CARD_NOT_PRESENT)
|
||||||
{
|
{
|
||||||
log_debug ("no card present\n");
|
log_debug ("no card present\n");
|
||||||
rc = 0;
|
rc = 0;
|
||||||
no_card = 1;
|
no_card = 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -330,7 +330,7 @@ agent_handle_learn (ctrl_t ctrl, int send, void *assuan_context, int force)
|
|||||||
cparm.ctrl = ctrl;
|
cparm.ctrl = ctrl;
|
||||||
|
|
||||||
/* Check whether a card is present and get the serial number */
|
/* 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)
|
if (rc)
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user