From e1631f510882c9e7600d42ed789462a8e6c91ce7 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Tue, 25 Jul 2017 18:36:04 +0100 Subject: Add list -public-key-methods Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/4015) --- apps/openssl.c | 24 +++++++++++++++++++++++- doc/man1/list.pod | 6 ++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/apps/openssl.c b/apps/openssl.c index 866c00e90b..0518ee6787 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -51,6 +51,7 @@ static LHASH_OF(FUNCTION) *prog_init(void); static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]); static void list_pkey(void); +static void list_pkey_meth(void); static void list_type(FUNC_TYPE ft); static void list_disabled(void); char *default_config_file = NULL; @@ -308,7 +309,7 @@ typedef enum HELPLIST_CHOICE { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS, - OPT_PK_ALGORITHMS, OPT_DISABLED, OPT_MISSING_HELP + OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_DISABLED, OPT_MISSING_HELP } HELPLIST_CHOICE; const OPTIONS list_options[] = { @@ -323,6 +324,8 @@ const OPTIONS list_options[] = { "List of cipher algorithms"}, {"public-key-algorithms", OPT_PK_ALGORITHMS, '-', "List of public key algorithms"}, + {"public-key-methods", OPT_PK_METHOD, '-', + "List of public key methods"}, {"disabled", OPT_DISABLED, '-', "List of disabled features"}, {"missing-help", OPT_MISSING_HELP, '-', @@ -364,6 +367,9 @@ int list_main(int argc, char **argv) case OPT_PK_ALGORITHMS: list_pkey(); break; + case OPT_PK_METHOD: + list_pkey_meth(); + break; case OPT_DISABLED: list_disabled(); break; @@ -540,6 +546,22 @@ static void list_pkey(void) } } +static void list_pkey_meth(void) +{ + size_t i; + size_t meth_count = EVP_PKEY_meth_get_count(); + + for (i = 0; i < meth_count; i++) { + const EVP_PKEY_METHOD *pmeth = EVP_PKEY_meth_get0(i); + int pkey_id, pkey_flags; + + EVP_PKEY_meth_get0_info(&pkey_id, &pkey_flags, pmeth); + BIO_printf(bio_out, "%s\n", OBJ_nid2ln(pkey_id)); + BIO_printf(bio_out, "\tType: %s Algorithm\n", + pkey_flags & ASN1_PKEY_DYNAMIC ? "External" : "Builtin"); + } +} + static int function_cmp(const FUNCTION * a, const FUNCTION * b) { return strncmp(a->name, b->name, 8); diff --git a/doc/man1/list.pod b/doc/man1/list.pod index d227e374fa..3a40b4d89d 100644 --- a/doc/man1/list.pod +++ b/doc/man1/list.pod @@ -14,6 +14,7 @@ B [B<-cipher-commands>] [B<-cipher-algorithms>] [B<-public-key-algorithms>] +[B<-public-key-methods>] [B<-disabled>] =head1 DESCRIPTION @@ -62,6 +63,11 @@ then B is an alias for the official algorithm name, B. Display a list of public key algorithms, with each algorithm as a block of multiple lines, all but the first are indented. +=item B<-public-key-methods> + +Display a list of public key method OIDs: this also includes public key methods +without an associated ASN.1 method, for example, KDF algorithms. + =item B<-disabled> Display a list of disabled features, those that were compiled out -- cgit v1.2.3