From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org, Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-kernel@vger.kernel.org,
Stephan Mueller <smueller@chronox.de>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
Eric Biggers <ebiggers@kernel.org>,
Joachim Vandersmissen <joachim@jvdsn.com>
Subject: [PATCH] crypto: drbg - Rename MAX_ADDTL => MAX_ADDTL_BYTES
Date: Tue, 5 May 2026 17:02:17 -0700 [thread overview]
Message-ID: <20260506000217.70738-1-ebiggers@kernel.org> (raw)
Give this constant a name which is clearer and consistent with
DRBG_MAX_REQUEST_BYTES. No functional change.
Suggested-by: Joachim Vandersmissen <joachim@jvdsn.com>
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
crypto/drbg.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/crypto/drbg.c b/crypto/drbg.c
index ad7b9577479e..ab443be199a0 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -120,11 +120,11 @@
* Maximum length of additional info and personalization strings, in bytes.
* SP800-90A allows up to 2**35 bits, i.e. 2**32 bytes. We use 2**32 - 2 bytes
* so that the value never quite completely fills the range of a size_t,
* allowing the health check to verify that larger values are rejected.
*/
-#define DRBG_MAX_ADDTL (U32_MAX - 1)
+#define DRBG_MAX_ADDTL_BYTES (U32_MAX - 1)
struct drbg_state {
struct mutex drbg_mutex; /* lock around DRBG */
u8 V[DRBG_STATE_LEN]; /* internal state -- 10.1.2.1 1a */
struct hmac_sha512_key key; /* current key -- 10.1.2.1 1b */
@@ -235,11 +235,11 @@ static int drbg_seed(struct drbg_state *drbg, const u8 *pers, size_t pers_len,
u8 entropy_buf[(32 + 16) * 2];
size_t entropylen;
const u8 *entropy;
/* 9.1 / 9.2 / 9.3.1 step 3 */
- if (pers_len > DRBG_MAX_ADDTL) {
+ if (pers_len > DRBG_MAX_ADDTL_BYTES) {
pr_devel("DRBG: personalization string too long %zu\n",
pers_len);
return -EINVAL;
}
@@ -353,11 +353,11 @@ static int drbg_generate(struct drbg_state *drbg, u8 *out, size_t outlen,
}
/* 9.3.1 step 3 is implicit with the chosen DRBG */
/* 9.3.1 step 4 */
- if (addtl_len > DRBG_MAX_ADDTL) {
+ if (addtl_len > DRBG_MAX_ADDTL_BYTES) {
pr_devel("DRBG: additional information string too long %zu\n",
addtl_len);
return -EINVAL;
}
/* 9.3.1 step 5 is implicit with the chosen DRBG */
@@ -568,18 +568,19 @@ static inline int __init drbg_healthcheck_sanity(void)
* we may get an OOPS. And we want to get an OOPS as this is a
* grave bug.
*/
/* overflow addtllen with additional info string */
- ret = drbg_generate(drbg, buf, OUTBUFLEN, buf, DRBG_MAX_ADDTL + 1);
+ ret = drbg_generate(drbg, buf, OUTBUFLEN, buf,
+ DRBG_MAX_ADDTL_BYTES + 1);
BUG_ON(ret == 0);
/* overflow max_bits */
ret = drbg_generate(drbg, buf, DRBG_MAX_REQUEST_BYTES + 1, NULL, 0);
BUG_ON(ret == 0);
/* overflow max addtllen with personalization string */
- ret = drbg_seed(drbg, buf, DRBG_MAX_ADDTL + 1, false);
+ ret = drbg_seed(drbg, buf, DRBG_MAX_ADDTL_BYTES + 1, false);
BUG_ON(ret == 0);
/* all tests passed */
pr_devel("DRBG: Sanity tests for failure code paths successfully "
"completed\n");
base-commit: 5b03b1f97542c49a498dbb3b4c1fefb3aca60032
--
2.54.0
reply other threads:[~2026-05-06 0:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260506000217.70738-1-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=herbert@gondor.apana.org.au \
--cc=joachim@jvdsn.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox