aboutsummaryrefslogtreecommitdiffstats
path: root/agent
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2014-12-12 11:35:45 +0000
committerWerner Koch <[email protected]>2014-12-12 11:47:28 +0000
commitf3f9f9b2844c35f7942ee904d5222523615cdad4 (patch)
treedcf872de1625703b30a8fbf0758291553fb2767b /agent
parentgpg: Fix possible read of unallocated memory (diff)
downloadgnupg-f3f9f9b2844c35f7942ee904d5222523615cdad4.tar.gz
gnupg-f3f9f9b2844c35f7942ee904d5222523615cdad4.zip
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 <[email protected]>
Diffstat (limited to 'agent')
-rw-r--r--agent/agent.h2
-rw-r--r--agent/command.c15
-rw-r--r--agent/learncard.c12
3 files changed, 17 insertions, 12 deletions
diff --git a/agent/agent.h b/agent/agent.h
index 0c83b274d..a1663cd56 100644
--- a/agent/agent.h
+++ b/agent/agent.h
@@ -492,7 +492,7 @@ int agent_card_scd (ctrl_t ctrl, const char *cmdline,
/*-- learncard.c --*/
-int agent_handle_learn (ctrl_t ctrl, void *assuan_context);
+int agent_handle_learn (ctrl_t ctrl, int send, void *assuan_context);
#endif /*AGENT_H*/
diff --git a/agent/command.c b/agent/command.c
index 3e8066381..c875f5516 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -1619,21 +1619,26 @@ cmd_get_confirmation (assuan_context_t ctx, char *line)
static const char hlp_learn[] =
- "LEARN [--send]\n"
+ "LEARN [--send][--sendinfo]\n"
"\n"
"Learn something about the currently inserted smartcard. With\n"
- "--send the new certificates are send back.";
+ "--sendinfo information about the card is returned; with --send\n"
+ "the available certificates are returned as D lines.";
static gpg_error_t
cmd_learn (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
- int rc;
+ gpg_error_t err;
+ int send, sendinfo;
+
+ send = has_option (line, "--send");
+ sendinfo = send? 1 : has_option (line, "--sendinfo");
if (ctrl->restricted)
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
- rc = agent_handle_learn (ctrl, has_option (line, "--send")? ctx : NULL);
- return leave_cmd (ctx, rc);
+ err = agent_handle_learn (ctrl, send, sendinfo? ctx : NULL);
+ return leave_cmd (ctx, err);
}
diff --git a/agent/learncard.c b/agent/learncard.c
index c60b3f48d..62569ceff 100644
--- a/agent/learncard.c
+++ b/agent/learncard.c
@@ -296,10 +296,10 @@ send_cert_back (ctrl_t ctrl, const char *id, void *assuan_context)
return 0;
}
-/* Perform the learn operation. If ASSUAN_CONTEXT is not NULL all new
- certificates are send back via Assuan. */
+/* Perform the learn operation. If ASSUAN_CONTEXT is not NULL and
+ SEND is true all new certificates are send back via Assuan. */
int
-agent_handle_learn (ctrl_t ctrl, void *assuan_context)
+agent_handle_learn (ctrl_t ctrl, int send, void *assuan_context)
{
int rc;
@@ -369,7 +369,7 @@ agent_handle_learn (ctrl_t ctrl, void *assuan_context)
log_info (" id: %s (type=%d)\n",
citem->id, citem->type);
- if (assuan_context)
+ if (assuan_context && send)
{
rc = send_cert_back (ctrl, citem->id, assuan_context);
if (rc)
@@ -439,9 +439,9 @@ agent_handle_learn (ctrl_t ctrl, void *assuan_context)
}
if (opt.verbose)
- log_info ("stored\n");
+ log_info (" id: %s - shadow key created\n", item->id);
- if (assuan_context)
+ if (assuan_context && send)
{
CERTINFO citem;