linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephan Mueller <smueller@chronox.de>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
	linux-next@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] DRBG: fix maximum value checks on 32 bit systems
Date: Tue, 26 Aug 2014 10:29:45 +0200	[thread overview]
Message-ID: <2984929.nIbTCa5fhe@myon.chronox.de> (raw)
In-Reply-To: <20140826080858.GA4161@gondor.apana.org.au>

The maximum values for additional input string or generated blocks is
larger than 1<<32. To ensure a sensible value on 32 bit systems, return
SIZE_MAX on 32 bit systems. This value is lower than the maximum
allowed values defined in SP800-90A. The standard allow lower maximum
values, but not larger values.

SIZE_MAX - 1 is used for drbg_max_addtl to allow
drbg_healthcheck_sanity to check the enforcement of the variable
without wrapping.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Stephan Mueller <smueller@chronox.de>
---
 include/crypto/drbg.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/crypto/drbg.h b/include/crypto/drbg.h
index 3d8e73a..5186f75 100644
--- a/include/crypto/drbg.h
+++ b/include/crypto/drbg.h
@@ -154,13 +154,26 @@ static inline size_t drbg_max_request_bytes(struct drbg_state *drbg)
 static inline size_t drbg_max_addtl(struct drbg_state *drbg)
 {
 	/* SP800-90A requires 2**35 bytes additional info str / pers str */
+#if (__BITS_PER_LONG == 32)
+	/*
+	 * SP800-90A allows smaller maximum numbers to be returned -- we
+	 * return SIZE_MAX - 1 to allow the verification of the enforcement
+	 * of this value in drbg_healthcheck_sanity.
+	 */
+	return (SIZE_MAX - 1);
+#else
 	return (1UL<<35);
+#endif
 }
 
 static inline size_t drbg_max_requests(struct drbg_state *drbg)
 {
 	/* SP800-90A requires 2**48 maximum requests before reseeding */
+#if (__BITS_PER_LONG == 32)
+	return SIZE_MAX;
+#else
 	return (1UL<<48);
+#endif
 }
 
 /*
-- 
1.9.3



  reply	other threads:[~2014-08-26  8:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-26  6:14 linux-next: build warnings after merge of the crypto tree Stephen Rothwell
2014-08-26  6:38 ` Herbert Xu
2014-08-26  7:00   ` Stephan Mueller
2014-08-26  7:31   ` [PATCH] DRBG: fix bit shifting on 32 bit systems Stephan Mueller
2014-08-26  7:32     ` Herbert Xu
2014-08-26  7:37       ` Stephan Mueller
2014-08-26  8:06       ` [PATCH] DRBG: fix maximum value checks " Stephan Mueller
2014-08-26  8:08         ` Herbert Xu
2014-08-26  8:29           ` Stephan Mueller [this message]
2014-08-26  8:43             ` [PATCH v2] " Herbert Xu
2014-08-26  8:52               ` Stephan Mueller
2014-08-26  8:58                 ` Herbert Xu
2014-08-26  9:36                   ` Stephan Mueller
2014-08-27 13:35                     ` Herbert Xu
2014-08-27 13:40                       ` Stephan Mueller
2014-08-28  7:13                       ` Stephan Mueller
2014-08-28  7:17                       ` DRBG: remove test for uninitialized DRBG handle Stephan Mueller
2014-09-01  5:11                         ` [PATCH v2] DRBG: remove check " Stephan Mueller
2014-09-03  1:33                           ` Stephan Mueller
2014-09-03 23:21                             ` Herbert Xu
2014-09-03 23:50                               ` Stephan Mueller
2014-09-05  7:55                                 ` Herbert Xu
2014-09-05 11:25                                   ` Stephan Mueller
2014-09-05  8:13                           ` Herbert Xu

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=2984929.nIbTCa5fhe@myon.chronox.de \
    --to=smueller@chronox.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    /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;
as well as URLs for NNTP newsgroup(s).