All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org, Herbert Xu <herbert@gondor.apana.org.au>
Cc: "Stephan Müller" <smueller@chronox.de>,
	"Eric Biggers" <ebiggers@kernel.org>
Subject: [PATCH 05/14] crypto: drbg - Use jitterentropy library API
Date: Sun, 18 Oct 2026 13:46:09 -0700	[thread overview]
Message-ID: <20261018204618.104876-6-ebiggers@kernel.org> (raw)
In-Reply-To: <20261018204618.104876-1-ebiggers@kernel.org>

Now that the jitterentropy RNG is accessible via a regular set of
functions, make drbg.c just use those instead of crypto_rng.

Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
 crypto/drbg.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/crypto/drbg.c b/crypto/drbg.c
index e057b00e74f5b..6015822129edc 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -96,6 +96,7 @@
 #include <linux/mutex.h>
 #include <linux/string_choices.h>
 #include <linux/unaligned.h>
+#include "jitterentropy-kcapi.h"
 
 /* State length in bytes */
 #define DRBG_STATE_LEN		SHA512_DIGEST_SIZE
@@ -130,7 +131,7 @@ struct drbg_state {
 	/* Number of RNG requests since last reseed -- 10.1.2.1 1c */
 	size_t reseed_ctr;
 	bool instantiated;
-	struct crypto_rng *jent;
+	struct jitterentropy *jent;
 	const u8 *test_entropy;
 	size_t test_entropylen;
 };
@@ -272,9 +273,9 @@ static int drbg_seed(struct drbg_state *drbg, const u8 *pers, size_t pers_len,
 			 * Get seed from Jitter RNG, failures are
 			 * fatal only in FIPS mode.
 			 */
-			ret = crypto_rng_get_bytes(drbg->jent,
-						   &entropy_buf[entropylen],
-						   entropylen);
+			ret = crypto_jent_get_bytes(drbg->jent,
+						    &entropy_buf[entropylen],
+						    entropylen);
 			if (fips_enabled && ret) {
 				pr_devel("DRBG: jent failed with %d\n", ret);
 
@@ -454,7 +455,7 @@ static int drbg_kcapi_seed(struct crypto_rng *tfm,
 
 	/* Allocate jitterentropy_rng if not in test mode. */
 	if (drbg->test_entropylen == 0) {
-		drbg->jent = crypto_alloc_rng("jitterentropy_rng", 0, 0);
+		drbg->jent = crypto_jent_alloc();
 		if (IS_ERR(drbg->jent)) {
 			ret = PTR_ERR(drbg->jent);
 			drbg->jent = NULL;
@@ -466,7 +467,7 @@ static int drbg_kcapi_seed(struct crypto_rng *tfm,
 
 	ret = drbg_seed(drbg, pers, pers_len, /* reseed= */ false);
 	if (ret) {
-		crypto_free_rng(drbg->jent);
+		crypto_jent_free(drbg->jent);
 		drbg->jent = NULL;
 		return ret;
 	}
@@ -512,7 +513,7 @@ static void drbg_kcapi_exit(struct crypto_tfm *tfm)
 {
 	struct drbg_state *drbg = crypto_tfm_ctx(tfm);
 
-	crypto_free_rng(drbg->jent);
+	crypto_jent_free(drbg->jent);
 	memzero_explicit(drbg, sizeof(*drbg));
 }
 
@@ -615,3 +616,4 @@ MODULE_AUTHOR("Stephan Mueller <smueller@chronox.de>");
 MODULE_DESCRIPTION("NIST SP800-90A Deterministic Random Bit Generator (DRBG)");
 MODULE_ALIAS_CRYPTO("stdrng");
 MODULE_ALIAS_CRYPTO("drbg_nopr_hmac_sha512");
+MODULE_IMPORT_NS("CRYPTO_INTERNAL"); /* for jitterentropy */
-- 
2.56.0


  parent reply	other threads:[~2026-10-18 20:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-18 20:46 [PATCH 00/14] crypto: Remove the unnecessary crypto_rng API Eric Biggers
2026-10-18 20:46 ` [PATCH 01/14] crypto: drbg - Don't use uninitialized stack data Eric Biggers
2026-10-18 20:46 ` [PATCH 02/14] crypto: rng - Remove unnecessary inclusions of internal/rng.h Eric Biggers
2026-10-18 20:46 ` [PATCH 03/14] crypto: jitterentropy - Move health check to first use Eric Biggers
2026-10-18 20:46 ` [PATCH 04/14] crypto: jitterentropy - Add library API Eric Biggers
2026-10-18 20:46 ` Eric Biggers [this message]
2026-10-18 20:46 ` [PATCH 06/14] crypto: drbg " Eric Biggers
2026-10-18 20:46 ` [PATCH 07/14] crypto: drbg - Add self-test for " Eric Biggers
2026-10-18 20:46 ` [PATCH 08/14] crypto: algif_rng - Use DRBG and jitterentropy library APIs Eric Biggers
2026-10-18 20:46 ` [PATCH 09/14] crypto: stdrng - Reimplement "stdrng" using direct DRBG calls Eric Biggers
2026-10-18 20:46 ` [PATCH 10/14] crypto: drbg - Remove crypto_rng support Eric Biggers
2026-10-18 20:46 ` [PATCH 11/14] crypto: jitterentropy " Eric Biggers
2026-10-18 20:46 ` [PATCH 12/14] crypto: jitterentropy - Remove the kconfig prompt Eric Biggers
2026-10-18 20:46 ` [PATCH 13/14] crypto: rng - Remove the rng algorithm type Eric Biggers
2026-10-18 20:46 ` [PATCH 14/14] crypto: stdrng - Make crypto_stdrng_get_bytes() take size_t Eric Biggers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261018204618.104876-6-ebiggers@kernel.org \
    --to=ebiggers@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=smueller@chronox.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.