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/e_aes_cbc_hmac_sha1.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/e_aes_cbc_hmac_sha1.c')
-rw-r--r-- | crypto/evp/e_aes_cbc_hmac_sha1.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/crypto/evp/e_aes_cbc_hmac_sha1.c b/crypto/evp/e_aes_cbc_hmac_sha1.c index 09d24dc3d0..053189e685 100644 --- a/crypto/evp/e_aes_cbc_hmac_sha1.c +++ b/crypto/evp/e_aes_cbc_hmac_sha1.c @@ -17,9 +17,11 @@ #include <openssl/aes.h> #include <openssl/sha.h> #include <openssl/rand.h> +#include <internal/rand.h> #include "modes_lcl.h" #include "internal/evp_int.h" #include "internal/constant_time_locl.h" +#include "evp_locl.h" typedef struct { AES_KEY ks; @@ -154,7 +156,8 @@ void aesni_multi_cbc_encrypt(CIPH_DESC *, void *, int); static size_t tls1_1_multi_block_encrypt(EVP_AES_HMAC_SHA1 *key, unsigned char *out, const unsigned char *inp, - size_t inp_len, int n4x) + size_t inp_len, int n4x, + RAND_DRBG *drbg) { /* n4x is 1 or 2 */ HASH_DESC hash_d[8], edges[8]; CIPH_DESC ciph_d[8]; @@ -174,8 +177,13 @@ static size_t tls1_1_multi_block_encrypt(EVP_AES_HMAC_SHA1 *key, # endif /* ask for IVs in bulk */ - if (RAND_bytes((IVs = blocks[0].c), 16 * x4) <= 0) + IVs = blocks[0].c; + if (drbg != NULL) { + if (RAND_DRBG_bytes(drbg, IVs, 16 * x4) == 0) + return 0; + } else if (RAND_bytes(IVs, 16 * x4) <= 0) { return 0; + } ctx = (SHA1_MB_CTX *) (storage + 32 - ((size_t)storage % 32)); /* align */ @@ -893,7 +901,8 @@ static int aesni_cbc_hmac_sha1_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, return (int)tls1_1_multi_block_encrypt(key, param->out, param->inp, param->len, - param->interleave / 4); + param->interleave / 4, + ctx->drbg); } case EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT: # endif |