1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

gpg: Let --card--status create a shadow key (card key stub).

* agent/command.c (cmd_learn): Add option --sendinfo.
* agent/learncard.c (agent_handle_learn): Add arg "send" andsend
certifciate only if that is set.
* g10/call-agent.c (agent_scd_learn): Use --sendinfo.  Make INFO
optional.
(agent_learn): Remove.
* g10/keygen.c (gen_card_key): Replace agent_learn by agent_scd_learn.
--

The requirement of using --card-status on the first use of card on a
new box is a bit annoying but the alternative of always checking
whether a card is available before a decryption starts does not sound
promising either.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2014-12-12 12:35:45 +01:00
parent 193815030d
commit f3f9f9b284
6 changed files with 26 additions and 40 deletions

View file

@ -655,6 +655,7 @@ agent_scd_learn (struct agent_card_info_s *info)
{
int rc;
struct default_inq_parm_s parm;
struct agent_card_info_s dummyinfo;
memset (&parm, 0, sizeof parm);
@ -674,42 +675,25 @@ agent_scd_learn (struct agent_card_info_s *info)
if (rc)
return rc;
if (!info)
info = &dummyinfo;
parm.ctx = agent_ctx;
memset (info, 0, sizeof *info);
rc = assuan_transact (agent_ctx, "SCD LEARN --force",
rc = assuan_transact (agent_ctx, "LEARN --sendinfo",
dummy_data_cb, NULL, default_inq_cb, &parm,
learn_status_cb, info);
/* Also try to get the key attributes. */
if (!rc)
agent_scd_getattr ("KEY-ATTR", info);
if (info == &dummyinfo)
agent_release_card_info (info);
return rc;
}
/* Call the agent to learn about the current smartcard. This is
currently only used to have the agent create the shadow key. */
gpg_error_t
agent_learn (void)
{
gpg_error_t err;
struct default_inq_parm_s parm;
memset (&parm, 0, sizeof parm);
err = start_agent (NULL, 1);
if (err)
return err;
parm.ctx = agent_ctx;
err = assuan_transact (agent_ctx, "LEARN",
dummy_data_cb, NULL, default_inq_cb, &parm,
NULL, NULL);
return err;
}
int
agent_keytocard (const char *hexgrip, int keyno, int force,
const char *serialno, const char *timestamp)

View file

@ -78,9 +78,6 @@ void agent_release_card_info (struct agent_card_info_s *info);
/* Return card info. */
int agent_scd_learn (struct agent_card_info_s *info);
/* Let the agent learn about the current card. */
gpg_error_t agent_learn (void);
/* Update INFO with the attribute NAME. */
int agent_scd_getattr (const char *name, struct agent_card_info_s *info);

View file

@ -4447,7 +4447,7 @@ gen_card_key (int algo, int keyno, int is_primary, kbnode_t pub_root,
/* Send the learn command so that the agent creates a shadow key for
card key. We need to do that now so that we are able to create
the self-signatures. */
err = agent_learn ();
err = agent_scd_learn (NULL);
if (err)
{
/* Oops: Card removed during generation. */