-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Description
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()
Line 130 in 32bfa2e
| cipher = EVP_get_cipherbyname(prog); |
resp. EVP_get_digestbyname()
Line 97 in 32bfa2e
| 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:
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.ctoapps/dgst.creplacingOBJ_NAME_TYPE_CIPHER_METHwithOBJ_NAME_TYPE_MD_METH. - Copy
show_ciphers()toshow_digests()and adjust it accordingly. - Add a
-listoption for enc and dgst, but keep the-ciphersoption. - Update the documentation