diff options
author | Stephan Mueller <smueller@chronox.de> | 2014-08-26 04:29:45 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-08-26 04:58:05 -0400 |
commit | b9347aff91ce4789619168539f08202d8d6a1177 (patch) | |
tree | d38c52fb8408e6ce77cc61735c2f68d8a2e1b949 /include/crypto | |
parent | 7c8ae03f41e635813b777a0989d8ac1ff5a8494e (diff) |
crypto: drbg - fix maximum value checks on 32 bit systems
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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/crypto')
-rw-r--r-- | include/crypto/drbg.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/crypto/drbg.h b/include/crypto/drbg.h index 3d8e73a1a1c7..5186f750c713 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) | |||
154 | static inline size_t drbg_max_addtl(struct drbg_state *drbg) | 154 | static inline size_t drbg_max_addtl(struct drbg_state *drbg) |
155 | { | 155 | { |
156 | /* SP800-90A requires 2**35 bytes additional info str / pers str */ | 156 | /* SP800-90A requires 2**35 bytes additional info str / pers str */ |
157 | #if (__BITS_PER_LONG == 32) | ||
158 | /* | ||
159 | * SP800-90A allows smaller maximum numbers to be returned -- we | ||
160 | * return SIZE_MAX - 1 to allow the verification of the enforcement | ||
161 | * of this value in drbg_healthcheck_sanity. | ||
162 | */ | ||
163 | return (SIZE_MAX - 1); | ||
164 | #else | ||
157 | return (1UL<<35); | 165 | return (1UL<<35); |
166 | #endif | ||
158 | } | 167 | } |
159 | 168 | ||
160 | static inline size_t drbg_max_requests(struct drbg_state *drbg) | 169 | static inline size_t drbg_max_requests(struct drbg_state *drbg) |
161 | { | 170 | { |
162 | /* SP800-90A requires 2**48 maximum requests before reseeding */ | 171 | /* SP800-90A requires 2**48 maximum requests before reseeding */ |
172 | #if (__BITS_PER_LONG == 32) | ||
173 | return SIZE_MAX; | ||
174 | #else | ||
163 | return (1UL<<48); | 175 | return (1UL<<48); |
176 | #endif | ||
164 | } | 177 | } |
165 | 178 | ||
166 | /* | 179 | /* |