aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/drbg.c
diff options
context:
space:
mode:
authorStephan Mueller <smueller@chronox.de>2015-06-09 21:33:37 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-06-10 07:14:05 -0400
commit42ea507fae1ac4b4af0d9d715ab56fa4de2a0341 (patch)
tree18c491c8da018ac142ab53d3d47982a95bc3f1d3 /crypto/drbg.c
parentc2719503f5e1e6213d716bb078bdad01e28ebcbf (diff)
crypto: drbg - reseed often if seedsource is degraded
As required by SP800-90A, the DRBG implements are reseeding threshold. This threshold is at 2**48 (64 bit) and 2**32 bit (32 bit) as implemented in drbg_max_requests. With the recently introduced changes, the DRBG is now always used as a stdrng which is initialized very early in the boot cycle. To ensure that sufficient entropy is present, the Jitter RNG is added to even provide entropy at early boot time. However, the 2nd seed source, the nonblocking pool, is usually degraded at that time. Therefore, the DRBG is seeded with the Jitter RNG (which I believe contains good entropy, which however is questioned by others) and is seeded with a degradded nonblocking pool. This seed is now used for quasi the lifetime of the system (2**48 requests is a lot). The patch now changes the reseed threshold as follows: up until the time the DRBG obtains a seed from a fully iniitialized nonblocking pool, the reseeding threshold is lowered such that the DRBG is forced to reseed itself resonably often. Once it obtains the seed from a fully initialized nonblocking pool, the reseed threshold is set to the value required by SP800-90A. Signed-off-by: Stephan Mueller <smueller@chronox.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/drbg.c')
-rw-r--r--crypto/drbg.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/crypto/drbg.c b/crypto/drbg.c
index c6cbf1336d73..5fad297424fc 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -1088,6 +1088,9 @@ static void drbg_async_seed(struct work_struct *work)
1088 1088
1089 __drbg_seed(drbg, &seedlist, true); 1089 __drbg_seed(drbg, &seedlist, true);
1090 1090
1091 if (drbg->seeded)
1092 drbg->reseed_threshold = drbg_max_requests(drbg);
1093
1091 mutex_unlock(&drbg->drbg_mutex); 1094 mutex_unlock(&drbg->drbg_mutex);
1092 1095
1093 memzero_explicit(entropy, entropylen); 1096 memzero_explicit(entropy, entropylen);
@@ -1334,7 +1337,7 @@ static int drbg_generate(struct drbg_state *drbg,
1334 * 9.3.1 step 6 and 9 supplemented by 9.3.2 step c is implemented 1337 * 9.3.1 step 6 and 9 supplemented by 9.3.2 step c is implemented
1335 * here. The spec is a bit convoluted here, we make it simpler. 1338 * here. The spec is a bit convoluted here, we make it simpler.
1336 */ 1339 */
1337 if ((drbg_max_requests(drbg)) < drbg->reseed_ctr) 1340 if (drbg->reseed_threshold < drbg->reseed_ctr)
1338 drbg->seeded = false; 1341 drbg->seeded = false;
1339 1342
1340 if (drbg->pr || !drbg->seeded) { 1343 if (drbg->pr || !drbg->seeded) {
@@ -1478,6 +1481,12 @@ static int drbg_prepare_hrng(struct drbg_state *drbg)
1478 1481
1479 drbg->jent = crypto_alloc_rng("jitterentropy_rng", 0, 0); 1482 drbg->jent = crypto_alloc_rng("jitterentropy_rng", 0, 0);
1480 1483
1484 /*
1485 * Require frequent reseeds until the seed source is fully
1486 * initialized.
1487 */
1488 drbg->reseed_threshold = 50;
1489
1481 return err; 1490 return err;
1482} 1491}
1483 1492
@@ -1522,6 +1531,7 @@ static int drbg_instantiate(struct drbg_state *drbg, struct drbg_string *pers,
1522 drbg->core = &drbg_cores[coreref]; 1531 drbg->core = &drbg_cores[coreref];
1523 drbg->pr = pr; 1532 drbg->pr = pr;
1524 drbg->seeded = false; 1533 drbg->seeded = false;
1534 drbg->reseed_threshold = drbg_max_requests(drbg);
1525 1535
1526 ret = drbg_alloc_state(drbg); 1536 ret = drbg_alloc_state(drbg);
1527 if (ret) 1537 if (ret)