From f9da935c3eb302e75a80def51128fb6f669661d7 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 4 Nov 2016 13:45:57 +0900 Subject: scd: Add --advanced option for READKEY. * scd/command.c (cmd_readkey) : Support ADVANCED arg. * scd/app.c (app_readcert): Add ADVANCED arg. * scd/app-openpgp.c (do_readkey): Implement ADVANCED arg. * scd/app-nks.c (do_readkey): Error return with GPG_ERR_NOT_SUPPORTED. -- "SCD READKEY --advanced OPENPGP.3" returns key in advanced format. With this suport, poldi-ctrl will be no longer needed. Signed-off-by: NIIBE Yutaka --- scd/command.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'scd/command.c') diff --git a/scd/command.c b/scd/command.c index 9d978ab48..edea01c1e 100644 --- a/scd/command.c +++ b/scd/command.c @@ -729,17 +729,19 @@ cmd_readcert (assuan_context_t ctx, char *line) static const char hlp_readkey[] = - "READKEY \n" + "READKEY [--advanced] \n" "\n" "Return the public key for the given cert or key ID as a standard\n" "S-expression.\n" + "In --advanced mode it returns the S-expression in advanced format.\n" "\n" - "Note, that this function may even be used on a locked card."; + "Note that this function may even be used on a locked card."; static gpg_error_t cmd_readkey (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); int rc; + int advanced = 0; unsigned char *cert = NULL; size_t ncert, n; ksba_cert_t kc = NULL; @@ -750,11 +752,16 @@ cmd_readkey (assuan_context_t ctx, char *line) if ((rc = open_card (ctrl, NULL))) return rc; + if (has_option (line, "--advanced")) + advanced = 1; + + line = skip_options (line); + line = xstrdup (line); /* Need a copy of the line. */ /* If the application supports the READKEY function we use that. Otherwise we use the old way by extracting it from the certificate. */ - rc = app_readkey (ctrl->app_ctx, line, &pk, &pklen); + rc = app_readkey (ctrl->app_ctx, advanced, line, &pk, &pklen); if (!rc) { /* Yeah, got that key - send it back. */ rc = assuan_send_data (ctx, pk, pklen); -- cgit v1.2.3