Skip to content

Feature: add -list option to openssl enc and openssl dgst #9893

@mspncp

Description

@mspncp

Feature Request

Please add an option -list to both the openssl enc and openssl dgst command.

This is a good first issue, so the following gives an outline of what needs to be done.

This issue was inspired by issue #9880.

Introduction

Both the openssl enc and the openssl dgst command allow to use a supported algorithm in one of the following two ways: Either use the algorithm name as an option argument

openssl dgst -whirlpool some-file.txt

or using the algorithm name as command name itself:

openssl whirlpool some-file.txt

What cipher resp. digest is allowable, depends on whether the function EVP_get_cipherbyname()

cipher = EVP_get_cipherbyname(prog);

resp. EVP_get_digestbyname()

md = EVP_get_digestbyname(prog);

finds a matching entry.

Implementation Details

openssl enc

The openssl enc command already has an option to list all supported ciphers, it is called -ciphers, not -list:

~/src/openssl-1.1.1$ openssl enc -ciphers
Supported ciphers:
-aes-128-cbc               -aes-128-cfb               -aes-128-cfb1             
-aes-128-cfb8              -aes-128-ctr               -aes-128-ecb              
-aes-128-ofb               -aes-192-cbc               -aes-192-cfb
...

In the case of the openssl enc command, the option to list all ciphers is implemented here:

openssl/apps/enc.c

Lines 149 to 155 in 32bfa2e

case OPT_LIST:
BIO_printf(bio_out, "Supported ciphers:\n");
dec.bio = bio_out;
dec.n = 0;
OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH,
show_ciphers, &dec);
BIO_printf(bio_out, "\n");

For consistency, both commands should support the -list option, but the previous name needs to be kept for compatibility reasons.

openssl dgst

For openssl dgst, the option can be implemented analogously. Here is an outline of what's to be done:

  • Copy the relevant code from apps/enc.c to apps/dgst.c replacing OBJ_NAME_TYPE_CIPHER_METH with OBJ_NAME_TYPE_MD_METH.
  • Copy show_ciphers() to show_digests() and adjust it accordingly.
  • Add a -list option for enc and dgst, but keep the -ciphers option.
  • Update the documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    branch: 1.1.1Applies to OpenSSL_1_1_1-stable branch (EOL)branch: masterApplies to master branchgood first issueBite size change that could be a good starthelp wantedissue: feature requestThe issue was opened to request a feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions