APPS: Replace the use of OBJ_nid2ln() with name or description calls

With new provided algorithms added, we'd rather rely on the names and
descriptions that we get from the providers.

Specifically with the 'openssl list' command, we now display the
description of all algorithms.  For '-public-key-algorithms', we
additionally print key type information a bit more like we do for
legacy methods.

We also add descriptions to all our keymgmt functions, because the
built in EVP_PKEY_ASN1_METHODs had them.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14656)
This commit is contained in:
Richard Levitte 2021-03-16 14:45:07 +01:00
parent 0388823329
commit baf02793fc
3 changed files with 118 additions and 39 deletions

View File

@ -96,15 +96,19 @@ static void list_ciphers(void)
print_names(bio_out, names);
BIO_printf(bio_out, " @ %s\n",
OSSL_PROVIDER_name(EVP_CIPHER_provider(c)));
OSSL_PROVIDER_name(EVP_CIPHER_provider(c)));
if (verbose) {
const char *desc = EVP_CIPHER_description(c);
if (desc != NULL)
BIO_printf(bio_out, " description: %s\n", desc);
print_param_types("retrievable algorithm parameters",
EVP_CIPHER_gettable_params(c), 4);
EVP_CIPHER_gettable_params(c), 4);
print_param_types("retrievable operation parameters",
EVP_CIPHER_gettable_ctx_params(c), 4);
EVP_CIPHER_gettable_ctx_params(c), 4);
print_param_types("settable operation parameters",
EVP_CIPHER_settable_ctx_params(c), 4);
EVP_CIPHER_settable_ctx_params(c), 4);
}
}
sk_OPENSSL_CSTRING_free(names);
@ -176,6 +180,10 @@ static void list_digests(void)
BIO_printf(bio_out, " @ %s\n", OSSL_PROVIDER_name(EVP_MD_provider(m)));
if (verbose) {
const char *desc = EVP_MD_description(m);
if (desc != NULL)
BIO_printf(bio_out, " description: %s\n", desc);
print_param_types("retrievable algorithm parameters",
EVP_MD_gettable_params(m), 4);
print_param_types("retrievable operation parameters",
@ -236,6 +244,10 @@ static void list_macs(void)
BIO_printf(bio_out, " @ %s\n", OSSL_PROVIDER_name(EVP_MAC_provider(m)));
if (verbose) {
const char *desc = EVP_MAC_description(m);
if (desc != NULL)
BIO_printf(bio_out, " description: %s\n", desc);
print_param_types("retrievable algorithm parameters",
EVP_MAC_gettable_params(m), 4);
print_param_types("retrievable operation parameters",
@ -299,6 +311,10 @@ static void list_kdfs(void)
BIO_printf(bio_out, " @ %s\n", OSSL_PROVIDER_name(EVP_KDF_provider(k)));
if (verbose) {
const char *desc = EVP_KDF_description(k);
if (desc != NULL)
BIO_printf(bio_out, " description: %s\n", desc);
print_param_types("retrievable algorithm parameters",
EVP_KDF_gettable_params(k), 4);
print_param_types("retrievable operation parameters",
@ -358,6 +374,10 @@ static void list_random_generators(void)
BIO_printf(bio_out, " @ %s\n", OSSL_PROVIDER_name(EVP_RAND_provider(m)));
if (verbose) {
const char *desc = EVP_RAND_description(m);
if (desc != NULL)
BIO_printf(bio_out, " description: %s\n", desc);
print_param_types("retrievable algorithm parameters",
EVP_RAND_gettable_params(m), 4);
print_param_types("retrievable operation parameters",
@ -491,6 +511,10 @@ static void list_encoders(void)
OSSL_ENCODER_properties(k));
if (verbose) {
const char *desc = OSSL_ENCODER_description(k);
if (desc != NULL)
BIO_printf(bio_out, " description: %s\n", desc);
print_param_types("settable operation parameters",
OSSL_ENCODER_settable_ctx_params(k), 4);
}
@ -555,6 +579,10 @@ static void list_decoders(void)
OSSL_DECODER_properties(k));
if (verbose) {
const char *desc = OSSL_DECODER_description(k);
if (desc != NULL)
BIO_printf(bio_out, " description: %s\n", desc);
print_param_types("settable operation parameters",
OSSL_DECODER_settable_ctx_params(k), 4);
}
@ -601,9 +629,17 @@ static void list_keymanagers(void)
names = sk_OPENSSL_CSTRING_new(name_cmp);
if (names != NULL && EVP_KEYMGMT_names_do_all(k, collect_names, names)) {
BIO_printf(bio_out, " ");
print_names(bio_out, names);
const char *desc = EVP_KEYMGMT_description(k);
BIO_printf(bio_out, " Name: ");
if (desc != NULL)
BIO_printf(bio_out, "%s", desc);
else
BIO_printf(bio_out, "%s", sk_OPENSSL_CSTRING_value(names, 0));
BIO_printf(bio_out, "\n");
BIO_printf(bio_out, " Type: Provider Algorithm\n");
BIO_printf(bio_out, " IDs: ");
print_names(bio_out, names);
BIO_printf(bio_out, " @ %s\n",
OSSL_PROVIDER_name(EVP_KEYMGMT_provider(k)));
@ -666,6 +702,10 @@ static void list_signatures(void)
OSSL_PROVIDER_name(EVP_SIGNATURE_provider(k)));
if (verbose) {
const char *desc = EVP_SIGNATURE_description(k);
if (desc != NULL)
BIO_printf(bio_out, " description: %s\n", desc);
print_param_types("settable operation parameters",
EVP_SIGNATURE_settable_ctx_params(k), 4);
print_param_types("retrievable operation parameters",
@ -723,6 +763,10 @@ static void list_kems(void)
BIO_printf(bio_out, " @ %s\n", OSSL_PROVIDER_name(EVP_KEM_provider(k)));
if (verbose) {
const char *desc = EVP_KEM_description(k);
if (desc != NULL)
BIO_printf(bio_out, " description: %s\n", desc);
print_param_types("settable operation parameters",
EVP_KEM_settable_ctx_params(k), 4);
print_param_types("retrievable operation parameters",
@ -783,6 +827,10 @@ static void list_asymciphers(void)
OSSL_PROVIDER_name(EVP_ASYM_CIPHER_provider(k)));
if (verbose) {
const char *desc = EVP_ASYM_CIPHER_description(k);
if (desc != NULL)
BIO_printf(bio_out, " description: %s\n", desc);
print_param_types("settable operation parameters",
EVP_ASYM_CIPHER_settable_ctx_params(k), 4);
print_param_types("retrievable operation parameters",
@ -841,6 +889,10 @@ static void list_keyexchanges(void)
OSSL_PROVIDER_name(EVP_KEYEXCH_provider(k)));
if (verbose) {
const char *desc = EVP_KEYEXCH_description(k);
if (desc != NULL)
BIO_printf(bio_out, " description: %s\n", desc);
print_param_types("settable operation parameters",
EVP_KEYEXCH_settable_ctx_params(k), 4);
print_param_types("retrievable operation parameters",

View File

@ -408,35 +408,52 @@ static const OSSL_ALGORITHM deflt_asym_kem[] = {
static const OSSL_ALGORITHM deflt_keymgmt[] = {
#ifndef OPENSSL_NO_DH
{ "DH:dhKeyAgreement", "provider=default", ossl_dh_keymgmt_functions },
{ "DH:dhKeyAgreement", "provider=default", ossl_dh_keymgmt_functions,
"OpenSSL PKCS#3 DH implementation" },
{ "DHX:X9.42 DH:dhpublicnumber", "provider=default",
ossl_dhx_keymgmt_functions },
ossl_dhx_keymgmt_functions, "OpenSSL X9.42 DH implementation" },
#endif
#ifndef OPENSSL_NO_DSA
{ "DSA:dsaEncryption", "provider=default", ossl_dsa_keymgmt_functions },
{ "DSA:dsaEncryption", "provider=default", ossl_dsa_keymgmt_functions,
"OpenSSL DSA implementation" },
#endif
{ "RSA:rsaEncryption", "provider=default", ossl_rsa_keymgmt_functions },
{ "RSA-PSS:RSASSA-PSS", "provider=default", ossl_rsapss_keymgmt_functions },
{ "RSA:rsaEncryption", "provider=default", ossl_rsa_keymgmt_functions,
"OpenSSL RSA implementation" },
{ "RSA-PSS:RSASSA-PSS", "provider=default", ossl_rsapss_keymgmt_functions,
"OpenSSL RSA-PSS implementation" },
#ifndef OPENSSL_NO_EC
{ "EC:id-ecPublicKey", "provider=default", ossl_ec_keymgmt_functions },
{ "X25519", "provider=default", ossl_x25519_keymgmt_functions },
{ "X448", "provider=default", ossl_x448_keymgmt_functions },
{ "ED25519", "provider=default", ossl_ed25519_keymgmt_functions },
{ "ED448", "provider=default", ossl_ed448_keymgmt_functions },
{ "EC:id-ecPublicKey", "provider=default", ossl_ec_keymgmt_functions,
"OpenSSL EC implementation" },
{ "X25519", "provider=default", ossl_x25519_keymgmt_functions,
"OpenSSL X25519 implementation" },
{ "X448", "provider=default", ossl_x448_keymgmt_functions,
"OpenSSL X448 implementation" },
{ "ED25519", "provider=default", ossl_ed25519_keymgmt_functions,
"OpenSSL ED25519 implementation" },
{ "ED448", "provider=default", ossl_ed448_keymgmt_functions,
"OpenSSL ED448 implementation" },
#endif
{ "TLS1-PRF", "provider=default", ossl_kdf_keymgmt_functions },
{ "HKDF", "provider=default", ossl_kdf_keymgmt_functions },
{ "SCRYPT:id-scrypt", "provider=default", ossl_kdf_keymgmt_functions },
{ "HMAC", "provider=default", ossl_mac_legacy_keymgmt_functions },
{ "SIPHASH", "provider=default", ossl_mac_legacy_keymgmt_functions },
{ "TLS1-PRF", "provider=default", ossl_kdf_keymgmt_functions,
"OpenSSL TLS1-PRF via EVP_PKEY implementation" },
{ "HKDF", "provider=default", ossl_kdf_keymgmt_functions,
"OpenSSL HKDF via EVP_PKEY implementation" },
{ "SCRYPT:id-scrypt", "provider=default", ossl_kdf_keymgmt_functions,
"OpenSSL SCRYPT via EVP_PKEY implementation" },
{ "HMAC", "provider=default", ossl_mac_legacy_keymgmt_functions,
"OpenSSL HMAC via EVP_PKEY implementation" },
{ "SIPHASH", "provider=default", ossl_mac_legacy_keymgmt_functions,
"OpenSSL SIPHASH via EVP_PKEY implementation" },
#ifndef OPENSSL_NO_POLY1305
{ "POLY1305", "provider=default", ossl_mac_legacy_keymgmt_functions },
{ "POLY1305", "provider=default", ossl_mac_legacy_keymgmt_functions,
"OpenSSL POLY1305 via EVP_PKEY implementation" },
#endif
#ifndef OPENSSL_NO_CMAC
{ "CMAC", "provider=default", ossl_cossl_mac_legacy_keymgmt_functions },
{ "CMAC", "provider=default", ossl_cossl_mac_legacy_keymgmt_functions,
"OpenSSL CMAC via EVP_PKEY implementation" },
#endif
#ifndef OPENSSL_NO_SM2
{ "SM2", "provider=default", ossl_sm2_keymgmt_functions },
{ "SM2", "provider=default", ossl_sm2_keymgmt_functions,
"OpenSSL SM2 implementation" },
#endif
{ NULL, NULL, NULL }
};

View File

@ -394,30 +394,40 @@ static const OSSL_ALGORITHM fips_asym_kem[] = {
static const OSSL_ALGORITHM fips_keymgmt[] = {
#ifndef OPENSSL_NO_DH
{ "DH:dhKeyAgreement", FIPS_DEFAULT_PROPERTIES, ossl_dh_keymgmt_functions },
{ "DH:dhKeyAgreement", FIPS_DEFAULT_PROPERTIES, ossl_dh_keymgmt_functions,
"OpenSSL PKCS#3 DH FIPS implementation" },
{ "DHX:X9.42 DH:dhpublicnumber", FIPS_DEFAULT_PROPERTIES,
ossl_dhx_keymgmt_functions },
ossl_dhx_keymgmt_functions, "OpenSSL X9.42 DH FIPS implementation" },
#endif
#ifndef OPENSSL_NO_DSA
{ "DSA", FIPS_DEFAULT_PROPERTIES, ossl_dsa_keymgmt_functions },
{ "DSA", FIPS_DEFAULT_PROPERTIES, ossl_dsa_keymgmt_functions,
"OpenSSL DSA FIPS implementation" },
#endif
{ "RSA:rsaEncryption", FIPS_DEFAULT_PROPERTIES,
ossl_rsa_keymgmt_functions },
ossl_rsa_keymgmt_functions, "OpenSSL RSA FIPS implementation" },
{ "RSA-PSS:RSASSA-PSS", FIPS_DEFAULT_PROPERTIES,
ossl_rsapss_keymgmt_functions },
ossl_rsapss_keymgmt_functions, "OpenSSL RSA-PSS FIPS implementation" },
#ifndef OPENSSL_NO_EC
{ "EC:id-ecPublicKey", FIPS_DEFAULT_PROPERTIES, ossl_ec_keymgmt_functions },
{ "X25519", FIPS_DEFAULT_PROPERTIES, ossl_x25519_keymgmt_functions },
{ "X448", FIPS_DEFAULT_PROPERTIES, ossl_x448_keymgmt_functions },
{ "ED25519", FIPS_DEFAULT_PROPERTIES, ossl_ed25519_keymgmt_functions },
{ "ED448", FIPS_DEFAULT_PROPERTIES, ossl_ed448_keymgmt_functions },
{ "EC:id-ecPublicKey", FIPS_DEFAULT_PROPERTIES, ossl_ec_keymgmt_functions,
"OpenSSL EC FIPS implementation" },
{ "X25519", FIPS_DEFAULT_PROPERTIES, ossl_x25519_keymgmt_functions,
"OpenSSL X25519 FIPS implementation" },
{ "X448", FIPS_DEFAULT_PROPERTIES, ossl_x448_keymgmt_functions,
"OpenSSL X448 FIPS implementation" },
{ "ED25519", FIPS_DEFAULT_PROPERTIES, ossl_ed25519_keymgmt_functions,
"OpenSSL ED25519 FIPS implementation" },
{ "ED448", FIPS_DEFAULT_PROPERTIES, ossl_ed448_keymgmt_functions,
"OpenSSL ED448 FIPS implementation" },
#endif
{ "TLS1-PRF", FIPS_DEFAULT_PROPERTIES, ossl_kdf_keymgmt_functions },
{ "HKDF", FIPS_DEFAULT_PROPERTIES, ossl_kdf_keymgmt_functions },
{ "HMAC", FIPS_DEFAULT_PROPERTIES, ossl_mac_legacy_keymgmt_functions },
{ "TLS1-PRF", FIPS_DEFAULT_PROPERTIES, ossl_kdf_keymgmt_functions,
"OpenSSL TLS1-PRF via EVP_PKEY FIPS implementation" },
{ "HKDF", FIPS_DEFAULT_PROPERTIES, ossl_kdf_keymgmt_functions,
"OpenSSL HKDF via EVP_PKEY FIPS implementation" },
{ "HMAC", FIPS_DEFAULT_PROPERTIES, ossl_mac_legacy_keymgmt_functions,
"OpenSSL HMAC via EVP_PKEY FIPS implementation" },
#ifndef OPENSSL_NO_CMAC
{ "CMAC", FIPS_DEFAULT_PROPERTIES,
ossl_cossl_mac_legacy_keymgmt_functions },
{ "CMAC", FIPS_DEFAULT_PROPERTIES, ossl_cossl_mac_legacy_keymgmt_functions,
"OpenSSL CMAC via EVP_PKEY FIPS implementation" },
#endif
{ NULL, NULL, NULL }
};