diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2017-08-05 12:04:10 +0100 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2017-08-05 12:04:10 +0100 |
commit | 4c78ba5918daf7965759a720687c58d2ebb0eb1f (patch) | |
tree | a78b9b04e176f26f3ee48fdd29413ef2a15e1e66 /crypto/rand | |
parent | 78632b6633cf8af21a4fba2091f3e771e3ab40fb (diff) |
Add entropy sanity check
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/4092)
Diffstat (limited to 'crypto/rand')
-rw-r--r-- | crypto/rand/drbg_rand.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/rand/drbg_rand.c b/crypto/rand/drbg_rand.c index 06f8affeb8..934679e315 100644 --- a/crypto/rand/drbg_rand.c +++ b/crypto/rand/drbg_rand.c @@ -243,6 +243,9 @@ int ctr_instantiate(RAND_DRBG *drbg, { RAND_DRBG_CTR *ctr = &drbg->ctr; + if (ent == NULL) + return 0; + memset(ctr->K, 0, sizeof(ctr->K)); memset(ctr->V, 0, sizeof(ctr->V)); AES_set_encrypt_key(ctr->K, drbg->strength, &ctr->ks); @@ -254,6 +257,8 @@ int ctr_reseed(RAND_DRBG *drbg, const unsigned char *ent, size_t entlen, const unsigned char *adin, size_t adinlen) { + if (ent == NULL) + return 0; ctr_update(drbg, ent, entlen, adin, adinlen, NULL, 0); return 1; } |