Avoid going through NID when unnecessary
authorTomas Mraz <tomas@openssl.org>
Fri, 26 Mar 2021 16:57:16 +0000 (17:57 +0100)
committerTomas Mraz <tomas@openssl.org>
Thu, 1 Apr 2021 12:39:54 +0000 (14:39 +0200)
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14703)

apps/ca.c
apps/crl.c
apps/enc.c
apps/speed.c
apps/x509.c
crypto/pem/pem_info.c
crypto/pem/pem_lib.c

index dbb4d15eb8e563d83a3d8a875965976197e17b00..9cec43cf8b9aab6b1b3385a811e8bf384a224015 100755 (executable)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -821,7 +821,7 @@ end_of_options:
         }
         if (verbose)
             BIO_printf(bio_err, "message digest is %s\n",
-                       OBJ_nid2ln(EVP_MD_type(dgst)));
+                       EVP_MD_name(dgst));
         if (policy == NULL
             && (policy = lookup_conf(conf, section, ENV_POLICY)) == NULL)
             goto end;
index e2ed9588e665daeaa534dbd01745bf9b8eab6f85..e8b501a8afb4dbf4a81f13c5f5f3c39482ff06c2 100644 (file)
@@ -347,8 +347,7 @@ int crl_main(int argc, char **argv)
                     BIO_printf(bio_err, "out of memory\n");
                     goto end;
                 }
-                BIO_printf(bio_out, "%s Fingerprint=",
-                           OBJ_nid2sn(EVP_MD_type(digest)));
+                BIO_printf(bio_out, "%s Fingerprint=", EVP_MD_name(digest));
                 for (j = 0; j < (int)n; j++) {
                     BIO_printf(bio_out, "%02X%c", md[j], (j + 1 == (int)n)
                                ? '\n' : ':');
index c5766f05e85eadc9bd2efd89111c0e4a3dea5ff6..498d0d500bc1d5f24ed105268dc239c4e7f237ee 100644 (file)
@@ -360,7 +360,7 @@ int enc_main(int argc, char **argv)
                 char prompt[200];
 
                 BIO_snprintf(prompt, sizeof(prompt), "enter %s %s password:",
-                        OBJ_nid2ln(EVP_CIPHER_nid(cipher)),
+                        EVP_CIPHER_name(cipher),
                         (enc) ? "encryption" : "decryption");
                 strbuf[0] = '\0';
                 i = EVP_read_pw_string((char *)strbuf, SIZE, prompt, enc);
index 727341a1e6052558627e929edf8144e2189c7a9c..25c384d775a55f71885b3ed41718f066512a16cf 100644 (file)
@@ -1758,7 +1758,7 @@ int speed_main(int argc, char **argv)
         } else if (!(EVP_CIPHER_flags(evp_cipher) &
                      EVP_CIPH_FLAG_AEAD_CIPHER)) {
             BIO_printf(bio_err, "%s is not an AEAD cipher\n",
-                       OBJ_nid2ln(EVP_CIPHER_nid(evp_cipher)));
+                       EVP_CIPHER_name(evp_cipher));
             goto end;
         }
     }
@@ -1770,7 +1770,7 @@ int speed_main(int argc, char **argv)
         } else if (!(EVP_CIPHER_flags(evp_cipher) &
                      EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK)) {
             BIO_printf(bio_err, "%s is not a multi-block capable\n",
-                       OBJ_nid2ln(EVP_CIPHER_nid(evp_cipher)));
+                       EVP_CIPHER_name(evp_cipher));
             goto end;
         } else if (async_jobs > 0) {
             BIO_printf(bio_err, "Async mode is not supported with -mb");
@@ -2219,7 +2219,7 @@ int speed_main(int argc, char **argv)
                 goto end;
             }
 
-            names[D_EVP] = OBJ_nid2ln(EVP_CIPHER_nid(evp_cipher));
+            names[D_EVP] = EVP_CIPHER_name(evp_cipher);
 
             if (EVP_CIPHER_mode(evp_cipher) == EVP_CIPH_CCM_MODE) {
                 loopfunc = EVP_Update_loop_ccm;
@@ -3633,7 +3633,7 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher, int lengths_single,
     if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_MAC_KEY,
                              sizeof(no_key), no_key))
         app_bail_out("failed to set AEAD key\n");
-    if ((alg_name = OBJ_nid2ln(EVP_CIPHER_nid(evp_cipher))) == NULL)
+    if ((alg_name = EVP_CIPHER_name(evp_cipher)) == NULL)
         app_bail_out("failed to get cipher name\n");
 
     for (j = 0; j < num; j++) {
index 163c1c8a67ab89a547cb1ca77768f7597b0051ea..abbffe37ab9e303b4a29df0b56fedaf86236c1b1 100644 (file)
@@ -978,7 +978,7 @@ int x509_main(int argc, char **argv)
                 BIO_printf(bio_err, "Out of memory\n");
                 goto end;
             }
-            BIO_printf(out, "%s Fingerprint=", OBJ_nid2sn(EVP_MD_type(fdig)));
+            BIO_printf(out, "%s Fingerprint=", EVP_MD_name(fdig));
             for (j = 0; j < (int)n; j++)
                 BIO_printf(out, "%02X%c", md[j], (j + 1 == (int)n) ? '\n' : ':');
         } else if (i == ocspid) {
index c615d24ed0444932c41e9215b907ceb4e6a0ced8..54e29ab41f2afedec92ca5932633458050225059 100644 (file)
@@ -282,7 +282,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, const X509_INFO *xi, EVP_CIPHER *enc,
     const unsigned char *iv = NULL;
 
     if (enc != NULL) {
-        objstr = OBJ_nid2sn(EVP_CIPHER_nid(enc));
+        objstr = EVP_CIPHER_name(enc);
         if (objstr == NULL
                    /*
                     * Check "Proc-Type: 4,Encrypted\nDEK-Info: objstr,hex-iv\n"
@@ -317,7 +317,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, const X509_INFO *xi, EVP_CIPHER *enc,
              * than what the user has passed us ... as we have to match
              * exactly for some strange reason
              */
-            objstr = OBJ_nid2sn(EVP_CIPHER_nid(xi->enc_cipher.cipher));
+            objstr = EVP_CIPHER_name(xi->enc_cipher.cipher);
             if (objstr == NULL) {
                 ERR_raise(ERR_LIB_PEM, PEM_R_UNSUPPORTED_CIPHER);
                 goto err;
index c8e0b264dacfb9a0eda2c2e2fbe5702356f7473f..16b65fa945b91862103510deaf1908305d716f95 100644 (file)
@@ -323,7 +323,7 @@ int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp,
     unsigned char iv[EVP_MAX_IV_LENGTH];
 
     if (enc != NULL) {
-        objstr = OBJ_nid2sn(EVP_CIPHER_nid(enc));
+        objstr = EVP_CIPHER_name(enc);
         if (objstr == NULL || EVP_CIPHER_iv_length(enc) == 0
                 || EVP_CIPHER_iv_length(enc) > (int)sizeof(iv)
                    /*