summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorStephan Mueller <smueller@chronox.de>2015-04-18 19:35:45 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2015-04-21 09:14:45 +0800
commit082eb10ba97449a370e58f746522a4b90bcaee78 (patch)
tree9b5c9dce71039eab77779297bdfa8f5e57a306fe /crypto
parent04a34d4680e75e9be63204b3a7b51a6abe3ce35a (diff)
downloadlinux-082eb10ba97449a370e58f746522a4b90bcaee78.tar.bz2
crypto: drbg - fix drbg_generate return val check
The drbg_generate returns 0 in success case. That means that drbg_generate_long will always only generate drbg_max_request_bytes at most. Longer requests will be truncated to drbg_max_request_bytes. Reported-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Stephan Mueller <smueller@chronox.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/drbg.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/crypto/drbg.c b/crypto/drbg.c
index 8d2944fab8e8..5a218a5c9b9c 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -1442,19 +1442,19 @@ static int drbg_generate_long(struct drbg_state *drbg,
unsigned char *buf, unsigned int buflen,
struct drbg_string *addtl)
{
- int len = 0;
+ unsigned int len = 0;
unsigned int slice = 0;
do {
- int tmplen = 0;
+ int err = 0;
unsigned int chunk = 0;
slice = ((buflen - len) / drbg_max_request_bytes(drbg));
chunk = slice ? drbg_max_request_bytes(drbg) : (buflen - len);
- tmplen = drbg_generate(drbg, buf + len, chunk, addtl);
- if (0 >= tmplen)
- return tmplen;
- len += tmplen;
+ err = drbg_generate(drbg, buf + len, chunk, addtl);
+ if (0 > err)
+ return err;
+ len += chunk;
} while (slice > 0 && (len < buflen));
- return len;
+ return 0;
}
/*