Cleanup: rename EVP_MD_CTX_(create|init|destroy) to EVP_MD_CTX_(new|reset|free)
authorRichard Levitte <levitte@openssl.org>
Tue, 1 Dec 2015 23:26:19 +0000 (00:26 +0100)
committerRichard Levitte <levitte@openssl.org>
Mon, 7 Dec 2015 16:39:23 +0000 (17:39 +0100)
Looking over names, it seems like we usually use names ending with
_new and _free as object constructors and destructors.  Also, since
EVP_MD_CTX_init is now used to reset a EVP_MD_CTX, it might as well be
named accordingly.

Reviewed-by: Rich Salz <rsalz@openssl.org>
crypto/evp/digest.c
include/openssl/evp.h
util/libeay.num

index ec05930f862b2a7df6b27c1ac7cabc0d8502b745..0b1af6f3c6c2ff7ba18501554aa2550cd431ae2e 100644 (file)
 #include "evp_locl.h"
 
 /* This call frees resources associated with the context */
-int EVP_MD_CTX_init(EVP_MD_CTX *ctx)
+int EVP_MD_CTX_reset(EVP_MD_CTX *ctx)
 {
     if (ctx == NULL)
         return 1;
@@ -150,20 +150,20 @@ int EVP_MD_CTX_init(EVP_MD_CTX *ctx)
     return 1;
 }
 
-EVP_MD_CTX *EVP_MD_CTX_create(void)
+EVP_MD_CTX *EVP_MD_CTX_new(void)
 {
     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
 }
 
-void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx)
+void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
 {
-    EVP_MD_CTX_init(ctx);
+    EVP_MD_CTX_reset(ctx);
     OPENSSL_free(ctx);
 }
 
 int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
 {
-    EVP_MD_CTX_init(ctx);
+    EVP_MD_CTX_reset(ctx);
     return EVP_DigestInit_ex(ctx, type, NULL);
 }
 
@@ -262,7 +262,7 @@ int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
 {
     int ret;
     ret = EVP_DigestFinal_ex(ctx, md, size);
-    EVP_MD_CTX_init(ctx);
+    EVP_MD_CTX_reset(ctx);
     return ret;
 }
 
@@ -285,7 +285,7 @@ int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
 
 int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in)
 {
-    EVP_MD_CTX_init(out);
+    EVP_MD_CTX_reset(out);
     return EVP_MD_CTX_copy_ex(out, in);
 }
 
@@ -309,7 +309,7 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
         EVP_MD_CTX_set_flags(out, EVP_MD_CTX_FLAG_REUSE);
     } else
         tmp_buf = NULL;
-    EVP_MD_CTX_init(out);
+    EVP_MD_CTX_reset(out);
     memcpy(out, in, sizeof(*out));
 
     if (in->md_data && out->digest->ctx_size) {
@@ -330,7 +330,7 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
     if (in->pctx) {
         out->pctx = EVP_PKEY_CTX_dup(in->pctx);
         if (!out->pctx) {
-            EVP_MD_CTX_init(out);
+            EVP_MD_CTX_reset(out);
             return 0;
         }
     }
index ecf951f115553793a09be23ddbb10c36ff2d5508..e7b187ddd979496db21fa21e2777eefc35bdb7c8 100644 (file)
@@ -571,10 +571,10 @@ void BIO_set_md(BIO *, const EVP_MD *md);
 # define EVP_delete_digest_alias(alias) \
         OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);
 
-int EVP_MD_CTX_init(EVP_MD_CTX *ctx);
 int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
-EVP_MD_CTX *EVP_MD_CTX_create(void);
-void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
+EVP_MD_CTX *EVP_MD_CTX_new(void);
+int EVP_MD_CTX_reset(EVP_MD_CTX *ctx);
+void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
 /*__owur*/ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);
 void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
 void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
index f6bbf06311d373a3853acdbdd8fc56922cf9415a..72eedad881b4d0b38e59d0593808611a160ff6f5 100755 (executable)
@@ -2066,7 +2066,7 @@ KRB5_APREQBODY_new                      2626      NOEXIST::FUNCTION:
 X509V3_EXT_REQ_add_nconf                2627   EXIST::FUNCTION:
 ENGINE_ctrl_cmd_string                  2628   EXIST::FUNCTION:ENGINE
 i2d_OCSP_RESPDATA                       2629   EXIST::FUNCTION:
-EVP_MD_CTX_init                         2630   EXIST::FUNCTION:
+EVP_MD_CTX_reset                        2630   EXIST::FUNCTION:
 EXTENDED_KEY_USAGE_free                 2631   EXIST::FUNCTION:
 PKCS7_ATTR_SIGN_it                      2632   EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
 PKCS7_ATTR_SIGN_it                      2632   EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
@@ -2162,7 +2162,7 @@ ENGINE_load_builtin_engines             2708      EXIST::FUNCTION:ENGINE
 i2d_OCSP_ONEREQ                         2709   EXIST::FUNCTION:
 OCSP_REQUEST_add_ext                    2710   EXIST::FUNCTION:
 OCSP_RESPBYTES_new                      2711   EXIST::FUNCTION:
-EVP_MD_CTX_create                       2712   EXIST::FUNCTION:
+EVP_MD_CTX_new                          2712   EXIST::FUNCTION:
 OCSP_resp_find_status                   2713   EXIST::FUNCTION:
 X509_ALGOR_it                           2714   EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
 X509_ALGOR_it                           2714   EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
@@ -2427,7 +2427,7 @@ BASIC_CONSTRAINTS_it                    2922      EXIST:!EXPORT_VAR_AS_FUNCTION:VARIA
 BASIC_CONSTRAINTS_it                    2922   EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
 BN_mod_add_quick                        2923   EXIST::FUNCTION:
 EC_POINT_new                            2924   EXIST::FUNCTION:EC
-EVP_MD_CTX_destroy                      2925   EXIST::FUNCTION:
+EVP_MD_CTX_free                         2925   EXIST::FUNCTION:
 OCSP_RESPBYTES_free                     2926   EXIST::FUNCTION:
 EVP_aes_128_cbc                         2927   EXIST::FUNCTION:AES
 OCSP_SINGLERESP_get1_ext_d2i            2928   EXIST::FUNCTION: