Skip to content

Commit b9fa4c0

Browse files
committed
fortuna_import() shouldn't ignore additional input
(cherry picked from commit 0c05e53)
1 parent 67d8ca1 commit b9fa4c0

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/prngs/fortuna.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ int fortuna_export(unsigned char *out, unsigned long *outlen, prng_state *prng)
413413
int fortuna_import(const unsigned char *in, unsigned long inlen, prng_state *prng)
414414
{
415415
int err, x;
416+
unsigned long len;
416417

417418
LTC_ARGCHK(in != NULL);
418419
LTC_ARGCHK(prng != NULL);
@@ -424,10 +425,14 @@ int fortuna_import(const unsigned char *in, unsigned long inlen, prng_state *prn
424425
if ((err = fortuna_start(prng)) != CRYPT_OK) {
425426
return err;
426427
}
427-
for (x = 0; x < LTC_FORTUNA_POOLS; x++) {
428-
if ((err = fortuna_add_entropy(in+x*32, 32, prng)) != CRYPT_OK) {
428+
x = 0;
429+
while (inlen > 0) {
430+
len = MIN(inlen, 32);
431+
if ((err = fortuna_add_entropy(in+x*32, len, prng)) != CRYPT_OK) {
429432
return err;
430433
}
434+
x++;
435+
inlen -= len;
431436
}
432437
return CRYPT_OK;
433438
}

0 commit comments

Comments
 (0)