crypto: drbg - always seeded with SP800-90B compliant noise source
As the Jitter RNG provides an SP800-90B compliant noise source, use this noise source always for the (re)seeding of the DRBG. To make sure the DRBG is always properly seeded, the reseed threshold is reduced to 1<<20 generate operations. The Jitter RNG may report health test failures. Such health test failures are treated as transient as follows. The DRBG will not reseed from the Jitter RNG (but from get_random_bytes) in case of a health test failure. Though, it produces the requested random number. The Jitter RNG has a failure counter where at most 1024 consecutive resets due to a health test failure are considered as a transient error. If more consecutive resets are required, the Jitter RNG will return a permanent error which is returned to the caller by the DRBG. With this approach, the worst case reseed threshold is significantly lower than mandated by SP800-90A in order to seed with an SP800-90B noise source: the DRBG has a reseed threshold of 2^20 * 1024 = 2^30 generate requests. Yet, in case of a transient Jitter RNG health test failure, the DRBG is seeded with the data obtained from get_random_bytes. However, if the Jitter RNG fails during the initial seeding operation even due to a health test error, the DRBG will send an error to the caller because at that time, the DRBG has received no seed that is SP800-90B compliant. Signed-off-by: Stephan Mueller <smueller@chronox.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
764428fe99
commit
97f2650e50
|
@ -1087,10 +1087,6 @@ static void drbg_async_seed(struct work_struct *work)
|
|||
if (ret)
|
||||
goto unlock;
|
||||
|
||||
/* If nonblocking pool is initialized, deactivate Jitter RNG */
|
||||
crypto_free_rng(drbg->jent);
|
||||
drbg->jent = NULL;
|
||||
|
||||
/* Set seeded to false so that if __drbg_seed fails the
|
||||
* next generate call will trigger a reseed.
|
||||
*/
|
||||
|
@ -1168,7 +1164,23 @@ static int drbg_seed(struct drbg_state *drbg, struct drbg_string *pers,
|
|||
entropylen);
|
||||
if (ret) {
|
||||
pr_devel("DRBG: jent failed with %d\n", ret);
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* Do not treat the transient failure of the
|
||||
* Jitter RNG as an error that needs to be
|
||||
* reported. The combined number of the
|
||||
* maximum reseed threshold times the maximum
|
||||
* number of Jitter RNG transient errors is
|
||||
* less than the reseed threshold required by
|
||||
* SP800-90A allowing us to treat the
|
||||
* transient errors as such.
|
||||
*
|
||||
* However, we mandate that at least the first
|
||||
* seeding operation must succeed with the
|
||||
* Jitter RNG.
|
||||
*/
|
||||
if (!reseed || ret != -EAGAIN)
|
||||
goto out;
|
||||
}
|
||||
|
||||
drbg_string_fill(&data1, entropy, entropylen * 2);
|
||||
|
@ -1492,6 +1504,8 @@ static int drbg_prepare_hrng(struct drbg_state *drbg)
|
|||
if (list_empty(&drbg->test_data.list))
|
||||
return 0;
|
||||
|
||||
drbg->jent = crypto_alloc_rng("jitterentropy_rng", 0, 0);
|
||||
|
||||
INIT_WORK(&drbg->seed_work, drbg_async_seed);
|
||||
|
||||
drbg->random_ready.owner = THIS_MODULE;
|
||||
|
@ -1512,8 +1526,6 @@ static int drbg_prepare_hrng(struct drbg_state *drbg)
|
|||
return err;
|
||||
}
|
||||
|
||||
drbg->jent = crypto_alloc_rng("jitterentropy_rng", 0, 0);
|
||||
|
||||
/*
|
||||
* Require frequent reseeds until the seed source is fully
|
||||
* initialized.
|
||||
|
|
|
@ -184,11 +184,7 @@ static inline size_t drbg_max_addtl(struct drbg_state *drbg)
|
|||
static inline size_t drbg_max_requests(struct drbg_state *drbg)
|
||||
{
|
||||
/* SP800-90A requires 2**48 maximum requests before reseeding */
|
||||
#if (__BITS_PER_LONG == 32)
|
||||
return SIZE_MAX;
|
||||
#else
|
||||
return (1UL<<48);
|
||||
#endif
|
||||
return (1<<20);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue