From b9fa4c063a1e127eddceeebecdb072f462da28a1 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 7 Dec 2017 11:09:43 +0100 Subject: [PATCH] fortuna_import() shouldn't ignore additional input (cherry picked from commit 0c05e5386f836a8cbf4bfbc12bc9113f974b6d61) --- src/prngs/fortuna.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/prngs/fortuna.c b/src/prngs/fortuna.c index 225eedc..e1056a1 100644 --- a/src/prngs/fortuna.c +++ b/src/prngs/fortuna.c @@ -413,6 +413,7 @@ LBL_UNLOCK: int fortuna_import(const unsigned char *in, unsigned long inlen, prng_state *prng) { int err, x; + unsigned long len; LTC_ARGCHK(in != NULL); LTC_ARGCHK(prng != NULL); @@ -424,10 +425,14 @@ int fortuna_import(const unsigned char *in, unsigned long inlen, prng_state *prn if ((err = fortuna_start(prng)) != CRYPT_OK) { return err; } - for (x = 0; x < LTC_FORTUNA_POOLS; x++) { - if ((err = fortuna_add_entropy(in+x*32, 32, prng)) != CRYPT_OK) { + x = 0; + while (inlen > 0) { + len = MIN(inlen, 32); + if ((err = fortuna_add_entropy(in+x*32, len, prng)) != CRYPT_OK) { return err; } + x++; + inlen -= len; } return CRYPT_OK; }