Camellia cipher, contributed by NTT
[openssl.git] / crypto / evp / p_open.c
index 6976f2a867ddbe3f275a60b9a5d558781cdbaa6e..53a59a295c272edab1a65f039a2175b73617dba7 100644 (file)
  * [including the GNU Public Licence.]
  */
 
-#ifndef OPENSSL_NO_RSA
 #include <stdio.h>
 #include "cryptlib.h"
+
+#ifndef OPENSSL_NO_RSA
+
 #include <openssl/evp.h>
 #include <openssl/objects.h>
 #include <openssl/x509.h>
+#include <openssl/rsa.h>
 
-int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char *ek,
-            int ekl, unsigned char *iv, EVP_PKEY *priv)
+int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
+       const unsigned char *ek, int ekl, const unsigned char *iv,
+       EVP_PKEY *priv)
        {
        unsigned char *key=NULL;
        int i,size=0,ret=0;
@@ -91,7 +95,7 @@ int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char *ek,
                goto err;
                }
 
-       i=EVP_PKEY_decrypt(key,ek,ekl,priv);
+       i=EVP_PKEY_decrypt_old(key,ek,ekl,priv);
        if ((i <= 0) || !EVP_CIPHER_CTX_set_key_length(ctx, i))
                {
                /* ERROR */
@@ -101,7 +105,7 @@ int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char *ek,
 
        ret=1;
 err:
-       if (key != NULL) memset(key,0,size);
+       if (key != NULL) OPENSSL_cleanse(key,size);
        OPENSSL_free(key);
        return(ret);
        }