X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fevp%2Fp_open.c;h=c748fbea877250031f8b40b60b36ef2d4b5f85c9;hp=c0a50b9cd6b25e6543f04b520acb9829f88c2a11;hb=a6bbbf2ff5580addb917a8b4f1160f90af91d268;hpb=de822715b2a7af12844d408b6d2f5f0b655d54bb diff --git a/crypto/evp/p_open.c b/crypto/evp/p_open.c index c0a50b9cd6..c748fbea87 100644 --- a/crypto/evp/p_open.c +++ b/crypto/evp/p_open.c @@ -56,22 +56,26 @@ * [including the GNU Public Licence.] */ -#ifndef OPENSSL_NO_RSA #include #include "cryptlib.h" + +#ifndef OPENSSL_NO_RSA + #include #include #include +#include -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; if(type) { EVP_CIPHER_CTX_init(ctx); - if(!EVP_DecryptInit(ctx,type,NULL,NULL)) return 0; + if(!EVP_DecryptInit_ex(ctx,type,NULL, NULL,NULL)) return 0; } if(!priv) return 1; @@ -91,17 +95,17 @@ 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 */ goto err; } - if(!EVP_DecryptInit(ctx,NULL,key,iv)) goto err; + if(!EVP_DecryptInit_ex(ctx,NULL,NULL,key,iv)) goto err; ret=1; err: - if (key != NULL) memset(key,0,size); + if (key != NULL) OPENSSL_cleanse(key,size); OPENSSL_free(key); return(ret); } @@ -110,8 +114,9 @@ int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) { int i; - i=EVP_DecryptFinal(ctx,out,outl); - EVP_DecryptInit(ctx,NULL,NULL,NULL); + i=EVP_DecryptFinal_ex(ctx,out,outl); + if (i) + i = EVP_DecryptInit_ex(ctx,NULL,NULL,NULL,NULL); return(i); } #else /* !OPENSSL_NO_RSA */