diff options
Diffstat (limited to 'crypto/evp/p_open.c')
-rw-r--r-- | crypto/evp/p_open.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/crypto/evp/p_open.c b/crypto/evp/p_open.c index b9ca7892c2..6dbccceafa 100644 --- a/crypto/evp/p_open.c +++ b/crypto/evp/p_open.c @@ -76,6 +76,11 @@ int EVP_OpenInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char *ek, goto err; } + if(type) { + EVP_CIPHER_CTX_init(ctx); + EVP_DecryptInit(ctx,type,NULL,NULL); + } + size=RSA_size(priv->pkey.rsa); key=(unsigned char *)Malloc(size+2); if (key == NULL) @@ -87,14 +92,13 @@ int EVP_OpenInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char *ek, } i=EVP_PKEY_decrypt(key,ek,ekl,priv); - if (i != type->key_len) + if ((i <= 0) || !EVP_CIPHER_CTX_set_key_length(ctx, i)) { /* ERROR */ goto err; } + if(!EVP_DecryptInit(ctx,NULL,key,iv)) goto err; - EVP_CIPHER_CTX_init(ctx); - EVP_DecryptInit(ctx,type,key,iv); ret=1; err: if (key != NULL) memset(key,0,size); |