Skip to content

Commit

Permalink
Ensure array length assumption agree (#1246)
Browse files Browse the repository at this point in the history
PASSIVE_ENTROPY_LOAD_LENGTH and CTR_DRBG_ENTROPY_LEN are currently equal. This assumption is used implicitly in RAND_load_entropy(). Statically ensure this continues to be true while assumed.
  • Loading branch information
torben-hansen authored Oct 13, 2023
1 parent 496574c commit 0602e8d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crypto/fipsmodule/rand/rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ static int rdrand(uint8_t *buf, size_t len) {
#if defined(BORINGSSL_FIPS)

#if defined(FIPS_ENTROPY_SOURCE_PASSIVE)

// Currently, we assume that the length of externally loaded entropy has the
// same length as the seed used in the ctr-drbg.
OPENSSL_STATIC_ASSERT(CTR_DRBG_ENTROPY_LEN == PASSIVE_ENTROPY_LOAD_LENGTH,
passive_entropy_load_length_different_from_ctr_drbg_seed_length)

void RAND_load_entropy(uint8_t out_entropy[CTR_DRBG_ENTROPY_LEN],
uint8_t entropy[PASSIVE_ENTROPY_LOAD_LENGTH]) {
OPENSSL_memcpy(out_entropy, entropy, CTR_DRBG_ENTROPY_LEN);
Expand Down

0 comments on commit 0602e8d

Please sign in to comment.