X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=crypto%2Fevp%2Fp_seal.c;h=8cc8fcb0bd058e4c4022fdceefde0e0c2e5e379f;hb=3205db2bfecdd83d321455a6302628f39b336be4;hp=618bdc10b607582c39536755196fb45eb5d36e0e;hpb=6b691a5c85ddc4e407e32781841fee5c029506cd;p=oweals%2Fopenssl.git diff --git a/crypto/evp/p_seal.c b/crypto/evp/p_seal.c index 618bdc10b6..8cc8fcb0bd 100644 --- a/crypto/evp/p_seal.c +++ b/crypto/evp/p_seal.c @@ -58,29 +58,36 @@ #include #include "cryptlib.h" -#include "rand.h" -#include "rsa.h" -#include "evp.h" -#include "objects.h" -#include "x509.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