aboutsummaryrefslogtreecommitdiffstats
path: root/scd/command.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2003-10-21 17:12:50 +0000
committerWerner Koch <[email protected]>2003-10-21 17:12:50 +0000
commit21be16dba911a3ebe530e37f3479690798cc8a01 (patch)
tree1e3bf026522ea34274d702b8d39968334ea3329c /scd/command.c
parent* card-util.c (card_edit): New command "passwd". Add logic to (diff)
downloadgnupg-21be16dba911a3ebe530e37f3479690798cc8a01.tar.gz
gnupg-21be16dba911a3ebe530e37f3479690798cc8a01.zip
* command.c (cmd_checkpin): New.
(register_commands): Add command CHECKPIN. * app.c (app_check_pin): New. * app-openpgp.c (check_against_given_fingerprint): New. Factored out that code elsewhere. (do_check_pin): New.
Diffstat (limited to 'scd/command.c')
-rw-r--r--scd/command.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/scd/command.c b/scd/command.c
index fc5efa708..8808b10e9 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -923,6 +923,41 @@ cmd_passwd (ASSUAN_CONTEXT ctx, char *line)
}
+/* CHECKPIN <hexified_id>
+
+ */
+static int
+cmd_checkpin (ASSUAN_CONTEXT ctx, char *line)
+{
+ CTRL ctrl = assuan_get_pointer (ctx);
+ int rc;
+ char *keyidstr;
+
+ if ((rc = open_card (ctrl)))
+ return rc;
+
+ if (!ctrl->app_ctx)
+ return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);
+
+ /* We have to use a copy of the key ID because the function may use
+ the pin_cb which in turn uses the assuan line buffer and thus
+ overwriting the original line with the keyid. */
+ keyidstr = xtrystrdup (line);
+ if (!keyidstr)
+ return ASSUAN_Out_Of_Core;
+
+ rc = app_check_pin (ctrl->app_ctx,
+ keyidstr,
+ pin_cb, ctx);
+ xfree (keyidstr);
+ if (rc)
+ log_error ("app_check_pin failed: %s\n", gpg_strerror (rc));
+
+ return map_to_assuan_status (rc);
+}
+
+
+
/* Tell the assuan library about our commands */
@@ -948,6 +983,7 @@ register_commands (ASSUAN_CONTEXT ctx)
{ "GENKEY", cmd_genkey },
{ "RANDOM", cmd_random },
{ "PASSWD", cmd_passwd },
+ { "CHECKPIN", cmd_checkpin },
{ NULL }
};
int i, rc;