Rename EVP_CIPHER_CTX_cipher_data to EVP_CIPHER_CTX_get_cipher_data
[openssl.git] / crypto / evp / evp_lib.c
index 63226566c22fd26c9aa3d68d4fc3560afa8e4280..bc24d5a7659332e5d04b152e31f3b817a733afb7 100644 (file)
@@ -1,4 +1,3 @@
-/* crypto/evp/evp_lib.c */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -257,16 +256,19 @@ void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data)
     ctx->app_data = data;
 }
 
-void *EVP_CIPHER_CTX_cipher_data(const EVP_CIPHER_CTX *ctx)
+void *EVP_CIPHER_CTX_get_cipher_data(const EVP_CIPHER_CTX *ctx)
 {
     return ctx->cipher_data;
 }
 
-/* FIXME: temporary until EVP_CIPHER goes opaque */
-void EVP_CIPHER_CTX_new_cipher_data(EVP_CIPHER_CTX *ctx, size_t size)
+void *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data)
 {
-    if (ctx->cipher_data == NULL && ctx->cipher->ctx_size == 0)
-        ctx->cipher_data = OPENSSL_zalloc(size);
+    void *old_cipher_data;
+
+    old_cipher_data = ctx->cipher_data;
+    ctx->cipher_data = cipher_data;
+
+    return old_cipher_data;
 }
 
 int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher)
@@ -360,7 +362,8 @@ unsigned long EVP_MD_flags(const EVP_MD *md)
 
 EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type)
 {
-    EVP_MD *md = (EVP_MD *)OPENSSL_zalloc(sizeof(EVP_MD));
+    EVP_MD *md = OPENSSL_zalloc(sizeof(*md));
+
     if (md != NULL) {
         md->type = md_type;
         md->pkey_type = pkey_type;
@@ -370,7 +373,8 @@ EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type)
 EVP_MD *EVP_MD_meth_dup(const EVP_MD *md)
 {
     EVP_MD *to = EVP_MD_meth_new(md->type, md->pkey_type);
-    if (md != NULL)
+
+    if (to != NULL)
         memcpy(to, md, sizeof(*to));
     return to;
 }