leetronics / infnoise

The world's easiest TRNG to get right
Creative Commons Zero v1.0 Universal
122 stars 25 forks source link

dieharder test failures for multipliers which are not a factor of four #15

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi, I received three Infinite Noise USB sticks this week and I'm testing them with dieharder.

x200 ➜  ~  sudo infnoise --multiplier 10 | dieharder -g 200 -a      
#=============================================================================#
#            dieharder version 3.31.1 Copyright 2003 Robert G. Brown          #
#=============================================================================#
   rng_name    |rands/second|   Seed   |
stdin_input_raw|  7.51e+04  |1364804889|
#=============================================================================#
        test_name   |ntup| tsamples |psamples|  p-value |Assessment
#=============================================================================#
   diehard_birthdays|   0|       100|     100|0.23129000|  PASSED  
      diehard_operm5|   0|   1000000|     100|0.00000000|  FAILED  
  diehard_rank_32x32|   0|     40000|     100|0.37159768|  PASSED  
    diehard_rank_6x8|   0|    100000|     100|0.60789942|  PASSED  
   diehard_bitstream|   0|   2097152|     100|0.00000000|  FAILED  
        diehard_opso|   0|   2097152|     100|0.00000000|  FAILED  
        diehard_oqso|   0|   2097152|     100|0.00000000|  FAILED  
         diehard_dna|   0|   2097152|     100|0.56541430|  PASSED  
diehard_count_1s_str|   0|    256000|     100|0.00000000|  FAILED  
diehard_count_1s_byt|   0|    256000|     100|0.25930858|  PASSED  
 diehard_parking_lot|   0|     12000|     100|0.00000000|  FAILED  
    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
    diehard_3dsphere|   3|      4000|     100|0.97260166|  PASSED  
     diehard_squeeze|   0|    100000|     100|0.00000000|  FAILED  
        diehard_sums|   0|       100|     100|0.00098605|   WEAK   
        diehard_runs|   0|    100000|     100|0.00000000|  FAILED  
        diehard_runs|   0|    100000|     100|0.00000547|   WEAK   
       diehard_craps|   0|    200000|     100|0.87231322|  PASSED  
       diehard_craps|   0|    200000|     100|0.00000000|  FAILED  
^C

I started with 10 as this is suggested in /etc/infnoise.conf. It seems that infnoise is broken for multipliers which are not a factor of four.

x200 ➜  ~  for m in `seq 1000 -1 100`; do echo -n $m; sudo infnoise --multiplier $m | dieharder -g 200 -d 11 | grep diehard_2dsphere; done
1000    diehard_2dsphere|   2|      8000|     100|0.79740406|  PASSED  
999    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
998    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
997    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
996    diehard_2dsphere|   2|      8000|     100|0.96286276|  PASSED  
995    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
994    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
993    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
992    diehard_2dsphere|   2|      8000|     100|0.16767338|  PASSED  
991    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
990    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
989    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
988    diehard_2dsphere|   2|      8000|     100|0.85300938|  PASSED  
987    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
986    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
985    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
984    diehard_2dsphere|   2|      8000|     100|0.94821266|  PASSED  
983    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
982    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
981    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
980    diehard_2dsphere|   2|      8000|     100|0.66834763|  PASSED  
979    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
978    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
977    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
976    diehard_2dsphere|   2|      8000|     100|0.89871392|  PASSED  
975    diehard_2dsphere|   2|      8000|     100|0.00000000|  FAILED  
974^C

This happens using version 0.3.0, version 0.2.6 doesn't show this behavior:

x200 ➜  ~  for m in `seq 1000 -1 100`; do echo -n $m; sudo infnoise --multiplier $m | dieharder -g 200 -d 11 | grep diehard_2dsphere; done
1000    diehard_2dsphere|   2|      8000|     100|0.29921090|  PASSED  
999    diehard_2dsphere|   2|      8000|     100|0.74759359|  PASSED  
998    diehard_2dsphere|   2|      8000|     100|0.29975106|  PASSED  
997    diehard_2dsphere|   2|      8000|     100|0.98317491|  PASSED  
996    diehard_2dsphere|   2|      8000|     100|0.96896072|  PASSED  
995    diehard_2dsphere|   2|      8000|     100|0.61387792|  PASSED  
994    diehard_2dsphere|   2|      8000|     100|0.28696629|  PASSED  
993^C

-- Christophe

ghost commented 5 years ago

I have tested this with different Infinite Noise TRNG on two different machines running Ubuntu Cosmic. Infnoise was installed from https://launchpad.net/ubuntu/+source/infnoise and https://github.com/13-37-org/infnoise/releases.

manuel-domke commented 5 years ago

Thanks a lot for the close inspection. Your observation with the factor of four made it easy to spot.

This was caused by naively returning the full buffer size instead of the actual number of bytes written in readData(). A new release will follow soon.

Still wondering (and analyzing) why it did not occur during my tests..

manuel-domke commented 5 years ago

I wasn't aware github automatically closes an issue when I say "fix #..." - so reopened it awaiting your confirmation/some more test results.

manuel-domke commented 5 years ago

@wk3-org: can you please confirm? I'll go on with release 0.3.1 now anyway.

Ricky-Tigg commented 9 months ago

Hello. At the time of this report, the demonstration of the partial non-reliability of the DieHarder program was unknown. Not anymore; reference: A Bad Day to Die Hard: Correcting the Dieharder Battery |Published: November 2021. Are still valid the discovered weaknesses since no new version that fixes them was released since June 2003, date of the release of the version against which this report was made.