summaryrefslogtreecommitdiff
path: root/crypto/drbg.c
diff options
context:
space:
mode:
authorStephan Mueller <smueller@chronox.de>2014-07-31 21:47:33 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2014-08-01 22:36:14 +0800
commit129e9f71918e0214016ce1052b268471804e1a1f (patch)
tree262bdc6df0152b023e66f06954c647ebb5325400 /crypto/drbg.c
parent400b3fa78b85fd56f9d692e40e54ff6be40f1b45 (diff)
downloadlinux-crypto-129e9f71918e0214016ce1052b268471804e1a1f.tar.gz
linux-crypto-129e9f71918e0214016ce1052b268471804e1a1f.zip
crypto: drbg - fix failure of generating multiple of 2**16 bytes
The function drbg_generate_long slices the request into 2**16 byte or smaller chunks. However, the loop, however invokes the random number generation function with zero bytes when the request size is a multiple of 2**16 bytes. The fix prevents zero bytes requests. Signed-off-by: Stephan Mueller <smueller@chronox.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/drbg.c')
-rw-r--r--crypto/drbg.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/drbg.c b/crypto/drbg.c
index ff975d9e..7894db9c 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -1500,7 +1500,7 @@ static int drbg_generate_long(struct drbg_state *drbg,
if (0 >= tmplen)
return tmplen;
len += tmplen;
- } while (slice > 0);
+ } while (slice > 0 && (len < buflen));
return len;
}