X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=crypto%2Fevp%2Fp_seal.c;h=e5919b0fbf982320c13672c6ca886c82f2b3f414;hb=ae53b299faaeb8cf985b04ea7964d160975ba07e;hp=d449e892bf7f7899f91e9621c06c674af86d1744;hpb=e7f97e2d22e386df60c8da63277727a931bf22b7;p=openssl.git diff --git a/crypto/evp/p_seal.c b/crypto/evp/p_seal.c index d449e892bf..e5919b0fbf 100644 --- a/crypto/evp/p_seal.c +++ b/crypto/evp/p_seal.c @@ -59,31 +59,35 @@ #include #include "cryptlib.h" #include -#ifndef NO_RSA +#ifndef OPENSSL_NO_RSA #include #endif #include #include #include -int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek, +int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek, int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk) { unsigned char key[EVP_MAX_KEY_LENGTH]; int i; - if (npubk <= 0) return(0); - if (RAND_bytes(key,EVP_MAX_KEY_LENGTH) <= 0) - return(0); - if (type->iv_len > 0) - RAND_pseudo_bytes(iv,type->iv_len); + if(type) { + EVP_CIPHER_CTX_init(ctx); + if(!EVP_EncryptInit_ex(ctx,type,NULL,NULL,NULL)) return 0; + } + if ((npubk <= 0) || !pubk) + return 1; + if (EVP_CIPHER_CTX_rand_key(ctx, key) <= 0) + return 0; + if (EVP_CIPHER_CTX_iv_length(ctx)) + RAND_pseudo_bytes(iv,EVP_CIPHER_CTX_iv_length(ctx)); - EVP_CIPHER_CTX_init(ctx); - EVP_EncryptInit(ctx,type,key,iv); + if(!EVP_EncryptInit_ex(ctx,NULL,NULL,key,iv)) return 0; for (i=0; i