Browse Source

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

Karel Miko 8 years ago
parent
commit
6417f96ea9
2 changed files with 2 additions and 1 deletions
  1. 1 1
      src/prngs/fortuna.c
  2. 1 0
      testprof/cipher_hash_test.c

+ 1 - 1
src/prngs/fortuna.c

@@ -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;
    }
 

+ 1 - 0
testprof/cipher_hash_test.c

@@ -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);