fortuna - import does not fail when input data are larger than export_size

This commit is contained in:
Karel Miko 2017-04-29 14:12:36 +02:00
parent d7f2b2dd6e
commit 6417f96ea9
2 changed files with 2 additions and 1 deletions

View File

@ -408,7 +408,7 @@ int fortuna_import(const unsigned char *in, unsigned long inlen, prng_state *prn
LTC_ARGCHK(in != NULL);
LTC_ARGCHK(prng != NULL);
if (inlen != (unsigned long)fortuna_desc.export_size) {
if (inlen < (unsigned long)fortuna_desc.export_size) {
return CRYPT_INVALID_ARG;
}

View File

@ -50,6 +50,7 @@ int cipher_hash_test(void)
DOX(prng_descriptor[x].pexport(buf, &n, &nprng), prng_descriptor[x].name);
prng_descriptor[x].done(&nprng);
DOX(prng_descriptor[x].pimport(buf, n, &nprng), prng_descriptor[x].name);
DOX(prng_descriptor[x].pimport(buf, 4096, &nprng), prng_descriptor[x].name); /* try to import larger data */
DOX(prng_descriptor[x].ready(&nprng), prng_descriptor[x].name);
if (prng_descriptor[x].read(buf, 100, &nprng) != 100) {
fprintf(stderr, "Error reading from imported PRNG (%s)!\n", prng_descriptor[x].name);