Test: link drbgtest statically against libcrypto
and remove duplicate rand_drbg_seedlen() implementation again. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7462)
This commit is contained in:
parent
680bd131b6
commit
1c615e4ce9
4 changed files with 3 additions and 47 deletions
|
@ -1045,12 +1045,8 @@ static int drbg_bytes(unsigned char *out, int count)
|
||||||
* Calculates the minimum length of a full entropy buffer
|
* Calculates the minimum length of a full entropy buffer
|
||||||
* which is necessary to seed (i.e. instantiate) the DRBG
|
* which is necessary to seed (i.e. instantiate) the DRBG
|
||||||
* successfully.
|
* successfully.
|
||||||
*
|
|
||||||
* NOTE: There is a copy of this function in drbgtest.c.
|
|
||||||
* If you change anything here, you need to update
|
|
||||||
* the copy accordingly.
|
|
||||||
*/
|
*/
|
||||||
static size_t rand_drbg_seedlen(RAND_DRBG *drbg)
|
size_t rand_drbg_seedlen(RAND_DRBG *drbg)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* If no os entropy source is available then RAND_seed(buffer, bufsize)
|
* If no os entropy source is available then RAND_seed(buffer, bufsize)
|
||||||
|
|
|
@ -309,7 +309,7 @@ extern int rand_fork_count;
|
||||||
/* DRBG helpers */
|
/* DRBG helpers */
|
||||||
int rand_drbg_restart(RAND_DRBG *drbg,
|
int rand_drbg_restart(RAND_DRBG *drbg,
|
||||||
const unsigned char *buffer, size_t len, size_t entropy);
|
const unsigned char *buffer, size_t len, size_t entropy);
|
||||||
|
size_t rand_drbg_seedlen(RAND_DRBG *drbg);
|
||||||
/* locking api */
|
/* locking api */
|
||||||
int rand_drbg_lock(RAND_DRBG *drbg);
|
int rand_drbg_lock(RAND_DRBG *drbg);
|
||||||
int rand_drbg_unlock(RAND_DRBG *drbg);
|
int rand_drbg_unlock(RAND_DRBG *drbg);
|
||||||
|
|
|
@ -342,7 +342,7 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=main
|
||||||
|
|
||||||
SOURCE[drbgtest]=drbgtest.c
|
SOURCE[drbgtest]=drbgtest.c
|
||||||
INCLUDE[drbgtest]=../include
|
INCLUDE[drbgtest]=../include
|
||||||
DEPEND[drbgtest]=../libcrypto libtestutil.a
|
DEPEND[drbgtest]=../libcrypto.a libtestutil.a
|
||||||
|
|
||||||
SOURCE[drbg_cavs_test]=drbg_cavs_test.c drbg_cavs_data_ctr.c \
|
SOURCE[drbg_cavs_test]=drbg_cavs_test.c drbg_cavs_data_ctr.c \
|
||||||
drbg_cavs_data_hash.c drbg_cavs_data_hmac.c
|
drbg_cavs_data_hash.c drbg_cavs_data_hmac.c
|
||||||
|
|
|
@ -901,46 +901,6 @@ static int test_multi_thread(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OPENSSL_RAND_SEED_NONE
|
|
||||||
/*
|
|
||||||
* Calculates the minimum buffer length which needs to be
|
|
||||||
* provided to RAND_seed() in order to successfully
|
|
||||||
* instantiate the DRBG.
|
|
||||||
*
|
|
||||||
* Copied from rand_drbg_seedlen() in rand_drbg.c
|
|
||||||
*/
|
|
||||||
static size_t rand_drbg_seedlen(RAND_DRBG *drbg)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* If no os entropy source is available then RAND_seed(buffer, bufsize)
|
|
||||||
* is expected to succeed if and only if the buffer length satisfies
|
|
||||||
* the following requirements, which follow from the calculations
|
|
||||||
* in RAND_DRBG_instantiate().
|
|
||||||
*/
|
|
||||||
size_t min_entropy = drbg->strength;
|
|
||||||
size_t min_entropylen = drbg->min_entropylen;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Extra entropy for the random nonce in the absence of a
|
|
||||||
* get_nonce callback, see comment in RAND_DRBG_instantiate().
|
|
||||||
*/
|
|
||||||
if (drbg->min_noncelen > 0 && drbg->get_nonce == NULL) {
|
|
||||||
min_entropy += drbg->strength / 2;
|
|
||||||
min_entropylen += drbg->min_noncelen;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert entropy requirement from bits to bytes
|
|
||||||
* (dividing by 8 without rounding upwards, because
|
|
||||||
* all entropy requirements are divisible by 8).
|
|
||||||
*/
|
|
||||||
min_entropy >>= 3;
|
|
||||||
|
|
||||||
/* Return a value that satisfies both requirements */
|
|
||||||
return min_entropy > min_entropylen ? min_entropy : min_entropylen;
|
|
||||||
}
|
|
||||||
#endif /*OPENSSL_RAND_SEED_NONE*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test that instantiation with RAND_seed() works as expected
|
* Test that instantiation with RAND_seed() works as expected
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue