From e95ebe421e2c2a2a23649b8aea2729fa5ad2aea1 Mon Sep 17 00:00:00 2001 From: Frank Morgner Date: Sun, 14 Jan 2024 01:47:13 +0100 Subject: [PATCH] pkcs11-tool added documentation about --key-type fixes https://github.com/OpenSC/OpenSC/issues/1928 --- doc/tools/pkcs11-tool.1.xml | 2 +- src/tools/pkcs11-tool.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/tools/pkcs11-tool.1.xml b/doc/tools/pkcs11-tool.1.xml index a06e309e57f..445ef96c1d4 100644 --- a/doc/tools/pkcs11-tool.1.xml +++ b/doc/tools/pkcs11-tool.1.xml @@ -148,7 +148,7 @@ Specify the type and length (bytes if symmetric) of the key to create, for example RSA:1024, EC:prime256v1, GOSTR3410-2012-256:B, - DES:8, DES3:24, AES:16 or GENERIC:64. + DES:8, DES3:24, AES:16 or GENERIC:64. If the key type was incompletely specified, possible values are listed. diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c index 4fac835ad2e..9f51f1806f2 100644 --- a/src/tools/pkcs11-tool.c +++ b/src/tools/pkcs11-tool.c @@ -2913,8 +2913,13 @@ static int gen_keypair(CK_SLOT_ID slot, CK_SESSION_HANDLE session, if (!strcmp(ec_curve_infos[ii].oid, type + 3)) break; } - if (!ec_curve_infos[ii].name) - util_fatal("Unknown EC key params '%s'", type + 3); + if (!ec_curve_infos[ii].name) { + fprintf(stderr, "EC key parameters may be specified by their canonic name or object identifier. Possible values are:\n"); + for (ii=0; ec_curve_infos[ii].name; ii++) { + fprintf(stderr, "%s (%s)\n", ec_curve_infos[ii].name, ec_curve_infos[ii].oid); + } + util_fatal("Unknown EC key parameter '%s'", type + 3); + } switch (ec_curve_infos[ii].mechanism) { case CKM_EC_EDWARDS_KEY_PAIR_GEN: