crypto/drbg.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
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
On Tue, May 05, 2026 at 05:02:17PM -0700, Eric Biggers wrote: > 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(-) Patch applied. Thanks. -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
© 2016 - 2026 Red Hat, Inc.