aboutsummaryrefslogtreecommitdiffstats
path: root/tools/card-call-scd.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-02-08 10:58:27 +0000
committerWerner Koch <[email protected]>2019-02-08 10:58:27 +0000
commita1cb4a940f308ba21ecc002b044efccf0c547784 (patch)
tree002ea83019180b5c7c33cd251acbb66afef37c6f /tools/card-call-scd.c
parentscd: Allow generating ECC curves on PIV cards. (diff)
downloadgnupg-a1cb4a940f308ba21ecc002b044efccf0c547784.tar.gz
gnupg-a1cb4a940f308ba21ecc002b044efccf0c547784.zip
card: Make "generate" work for PIV cards.
* tools/card-call-scd.c (scd_genkey_cb): Make createtime optional. (scd_genkey_cb): Ditto. Add arg algo. * tools/gpg-card-tool.c (cmd_generate): Add options and factor card specific code out to ... (generate_openpgp, generate_generic): new functions. -- This patch keeps the interactive OpenPGP mode but adds a pure command line mode for other cards; in particular PIV cards. What we still need to do is: a) Add an interactive mode for PIV cards b) Add a command line mode for OpenPGP cards. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'tools/card-call-scd.c')
-rw-r--r--tools/card-call-scd.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/tools/card-call-scd.c b/tools/card-call-scd.c
index 0d6dabf1b..97fb6d9f1 100644
--- a/tools/card-call-scd.c
+++ b/tools/card-call-scd.c
@@ -202,7 +202,7 @@ app_type_string (app_type_t app_type)
case APP_TYPE_OPENPGP: result = "OpenPGP"; break;
case APP_TYPE_NKS: result = "NetKey"; break;
case APP_TYPE_DINSIG: result = "DINSIG"; break;
- case APP_TYPE_P15: result = "PKCS#15"; break;
+ case APP_TYPE_P15: result = "P15"; break;
case APP_TYPE_GELDKARTE: result = "Geldkarte"; break;
case APP_TYPE_SC_HSM: result = "SC-HSM"; break;
case APP_TYPE_PIV: result = "PIV"; break;
@@ -1174,7 +1174,8 @@ scd_genkey_cb (void *opaque, const char *line)
if (keywordlen == 14 && !memcmp (keyword,"KEY-CREATED-AT", keywordlen))
{
- *createtime = (u32)strtoul (line, NULL, 10);
+ if (createtime)
+ *createtime = (u32)strtoul (line, NULL, 10);
}
else if (keywordlen == 8 && !memcmp (keyword, "PROGRESS", keywordlen))
{
@@ -1190,7 +1191,7 @@ scd_genkey_cb (void *opaque, const char *line)
* SCDEAMON. On success, creation time is stored back to
* CREATETIME. */
gpg_error_t
-scd_genkey (int keyno, int force, u32 *createtime)
+scd_genkey (const char *keyref, int force, const char *algo, u32 *createtime)
{
gpg_error_t err;
char line[ASSUAN_LINELENGTH];
@@ -1203,15 +1204,17 @@ scd_genkey (int keyno, int force, u32 *createtime)
if (err)
return err;
- if (*createtime)
+ if (createtime && *createtime)
epoch2isotime (tbuf, *createtime);
else
*tbuf = 0;
- snprintf (line, sizeof line, "SCD GENKEY %s%s %s %d",
+ snprintf (line, sizeof line, "SCD GENKEY %s%s %s %s%s -- %s",
*tbuf? "--timestamp=":"", tbuf,
force? "--force":"",
- keyno);
+ algo? "--algo=":"",
+ algo? algo:"",
+ keyref);
dfltparm.ctx = agent_ctx;
err = assuan_transact (agent_ctx, line,