X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fevp%2Fp_seal.c;h=e5919b0fbf982320c13672c6ca886c82f2b3f414;hp=cd292767733daaa061dff1e19eb4375153dd2cc5;hb=4739ccdb395c95bd9d05110d22f032987cf0cfe3;hpb=ec577822f95a8bca0023c5c77cef1a4916822d4a diff --git a/crypto/evp/p_seal.c b/crypto/evp/p_seal.c index cd29276773..e5919b0fbf 100644 --- a/crypto/evp/p_seal.c +++ b/crypto/evp/p_seal.c @@ -59,28 +59,35 @@ #include #include "cryptlib.h" #include +#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); - RAND_bytes(key,EVP_MAX_KEY_LENGTH); - if (type->iv_len > 0) - RAND_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