diff options
author | Kurt Roeckx <kurt@roeckx.be> | 2017-11-05 14:37:15 +0100 |
---|---|---|
committer | Kurt Roeckx <kurt@roeckx.be> | 2018-02-28 21:20:01 +0100 |
commit | d91f45688c2d0bfcc5b3b57fb20cc80b010eef0b (patch) | |
tree | 8d1b6a41dcd33ac56b261d46d6fbad7675f0fd58 /crypto/evp/p_seal.c | |
parent | b3f9064cc66324d2359dba5350c71540ce869ceb (diff) |
Tell the ciphers which DRBG to use for generating random bytes.
Reviewed-by: Richard Levitte <levitte@openssl.org>
GH: #4672
Diffstat (limited to 'crypto/evp/p_seal.c')
-rw-r--r-- | crypto/evp/p_seal.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/crypto/evp/p_seal.c b/crypto/evp/p_seal.c index 50ea60235a..3b79dab8b8 100644 --- a/crypto/evp/p_seal.c +++ b/crypto/evp/p_seal.c @@ -14,6 +14,8 @@ #include <openssl/evp.h> #include <openssl/objects.h> #include <openssl/x509.h> +#include <internal/rand.h> +#include "evp_locl.h" int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek, int *ekl, unsigned char *iv, @@ -31,9 +33,14 @@ int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, return 1; if (EVP_CIPHER_CTX_rand_key(ctx, key) <= 0) return 0; - if (EVP_CIPHER_CTX_iv_length(ctx) - && RAND_bytes(iv, EVP_CIPHER_CTX_iv_length(ctx)) <= 0) - return 0; + if (EVP_CIPHER_CTX_iv_length(ctx)) { + if (ctx->drbg) { + if (RAND_DRBG_bytes(ctx->drbg, iv, EVP_CIPHER_CTX_iv_length(ctx)) == 0) + return 0; + } else if (RAND_bytes(iv, EVP_CIPHER_CTX_iv_length(ctx)) <= 0) { + return 0; + } + } if (!EVP_EncryptInit_ex(ctx, NULL, NULL, key, iv)) return 0; |