diff options
| author | Eric Biggers <ebiggers@kernel.org> | 2026-04-19 23:34:16 -0700 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2026-05-07 16:10:01 +0800 |
| commit | 2b30c567603b6e12f153dc7f584d3be87a96be35 (patch) | |
| tree | e9edddeb7ae05d032b49de1919c8c9dfb0007634 /crypto | |
| parent | ad8883374f34809f04d6839b9e7efe0afa5e92cd (diff) | |
| download | linux-next-history-2b30c567603b6e12f153dc7f584d3be87a96be35.tar.gz | |
crypto: drbg - Fold drbg_prepare_hrng() into drbg_kcapi_seed()
Fold drbg_prepare_hrng() into its only caller.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/drbg.c | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/crypto/drbg.c b/crypto/drbg.c index a9d586107ebed..45d97f3ba4efe 100644 --- a/crypto/drbg.c +++ b/crypto/drbg.c @@ -506,25 +506,6 @@ err: return len; } -static int drbg_prepare_hrng(struct drbg_state *drbg) -{ - /* We do not need an HRNG in test mode. */ - if (drbg->test_entropylen != 0) - return 0; - - drbg->jent = crypto_alloc_rng("jitterentropy_rng", 0, 0); - if (IS_ERR(drbg->jent)) { - const int err = PTR_ERR(drbg->jent); - - drbg->jent = NULL; - if (fips_enabled) - return err; - pr_info("DRBG: Continuing without Jitter RNG\n"); - } - - return 0; -} - /* * DRBG uninstantiate function as required by SP800-90A - this function * frees all buffers and the DRBG handle @@ -602,9 +583,18 @@ static int drbg_kcapi_seed(struct crypto_rng *tfm, memset(drbg->V, 1, DRBG_STATE_LEN); hmac_sha512_preparekey(&drbg->key, initial_key, DRBG_STATE_LEN); - ret = drbg_prepare_hrng(drbg); - if (ret) - goto free_everything; + /* Allocate jitterentropy_rng if not in test mode. */ + if (drbg->test_entropylen == 0) { + drbg->jent = crypto_alloc_rng("jitterentropy_rng", 0, 0); + if (IS_ERR(drbg->jent)) { + ret = PTR_ERR(drbg->jent); + drbg->jent = NULL; + if (fips_enabled) + goto free_everything; + pr_info("DRBG: Continuing without Jitter RNG\n"); + } + } + ret = drbg_seed(drbg, pers, pers_len, /* reseed= */ false); if (ret) goto free_everything; |
