summaryrefslogtreecommitdiffstats
path: root/apps/list.c
diff options
context:
space:
mode:
authorDmitry Belyavskiy <beldmit@gmail.com>2020-12-11 03:15:09 +0100
committerDmitry Belyavskiy <beldmit@gmail.com>2020-12-15 04:39:58 +0100
commita61fba5da6eec31d7b790602c1e21f06d722cdaa (patch)
tree58dde14d8daf86c0569988071d40517290aa2375 /apps/list.c
parentcb75a155b67942d32b808031199a7c947098e1e6 (diff)
Skip unavailable digests and ciphers in -*-commands
Fixes #13594 Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13669)
Diffstat (limited to 'apps/list.c')
-rw-r--r--apps/list.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/apps/list.c b/apps/list.c
index cf63394107..df25e00363 100644
--- a/apps/list.c
+++ b/apps/list.c
@@ -945,6 +945,38 @@ static void list_options_for_command(const char *command)
BIO_printf(bio_out, "- -\n");
}
+static int is_md_available(const char *name)
+{
+ EVP_MD *md;
+
+ /* Look through providers' digests */
+ ERR_set_mark();
+ md = EVP_MD_fetch(NULL, name, NULL);
+ ERR_pop_to_mark();
+ if (md != NULL) {
+ EVP_MD_free(md);
+ return 1;
+ }
+
+ return (get_digest_from_engine(name) == NULL) ? 0 : 1;
+}
+
+static int is_cipher_available(const char *name)
+{
+ EVP_CIPHER *cipher;
+
+ /* Look through providers' ciphers */
+ ERR_set_mark();
+ cipher = EVP_CIPHER_fetch(NULL, name, NULL);
+ ERR_pop_to_mark();
+ if (cipher != NULL) {
+ EVP_CIPHER_free(cipher);
+ return 1;
+ }
+
+ return (get_cipher_from_engine(name) == NULL) ? 0 : 1;
+}
+
static void list_type(FUNC_TYPE ft, int one)
{
FUNCTION *fp;
@@ -958,6 +990,18 @@ static void list_type(FUNC_TYPE ft, int one)
for (fp = functions; fp->name != NULL; fp++) {
if (fp->type != ft)
continue;
+ switch (ft) {
+ case FT_cipher:
+ if (!is_cipher_available(fp->name))
+ continue;
+ break;
+ case FT_md:
+ if (!is_md_available(fp->name))
+ continue;
+ break;
+ default:
+ break;
+ }
if (one) {
BIO_printf(bio_out, "%s\n", fp->name);
} else {