Welcome Guest [Log In] [Register]
Welcome to Crypto. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
TESTU01 source for PRNG test reading from STDIN
Topic Started: May 1 2017, 06:47 PM (124 Views)
Karl-Uwe Frank
NSA worthy
[ *  *  *  *  *  * ]
I have uploaded a short ANSI-C source code that can test the output of any PRNG using the TESTU01 test battery
by reading in 32bit values from STDIN. This way it's not necessary to implement your PRNG algorithm into TESTU01
because you can simply pipe the output of any PRNG written in the programming language you favour to the test battery.

Perhaps someone might find it useful. Comments are welcome.


At http://www.freecx.co.uk/crypto/cryptanalysis/TestTools/TestU01/
you find all needed sources as well as some example PRNG source codes.

The original source code and explanation of TestU01 used in my implementation is located here
http://simul.iro.umontreal.ca/testu01/tu01.html


Running the given example PRNGs mentioned above against TESTU01_stdin we get the following results.

As expected a very basic LCG PRNG fails badly just the SmallCrush test

Code:
 
./LCG_stdio 0x2ddd6a2c 0xfffffffe | ./TestU01_stdin -s

========= Summary results of SmallCrush =========

Version: TestU01 1.2.3
Generator: 32-bit stdin
Number of statistics: 15
Total CPU time: 00:00:24.80
The following tests gave p-values outside [0.001, 0.9990]:
(eps means a value < 1.0e-300):
(eps1 means a value < 1.0e-15):

Test p-value
----------------------------------------------
1 BirthdaySpacings eps
2 Collision 1 - eps1
3 Gap eps
4 SimpPoker eps
5 CouponCollector eps
7 WeightDistrib eps
8 MatrixRank eps
9 HammingIndep eps
10 RandomWalk1 H eps
10 RandomWalk1 M eps
10 RandomWalk1 J 7.8e-7
10 RandomWalk1 R eps
10 RandomWalk1 C eps
----------------------------------------------
All other tests were passed




Not that terribly bad as the above LCG does the systems Rand PRNG on the SmallCrush test

Code:
 
./C_Rand_stdio 0x2ddd6a2c 0xfffffffe | ./TestU01_stdin -s

========= Summary results of SmallCrush =========

Version: TestU01 1.2.3
Generator: 32-bit stdin
Number of statistics: 15
Total CPU time: 00:00:25.71
The following tests gave p-values outside [0.001, 0.9990]:
(eps means a value < 1.0e-300):
(eps1 means a value < 1.0e-15):

Test p-value
----------------------------------------------
1 BirthdaySpacings eps
2 Collision eps
6 MaxOft eps
6 MaxOft AD 1 - eps1
10 RandomWalk1 H eps
10 RandomWalk1 M eps
10 RandomWalk1 J eps
10 RandomWalk1 R eps
10 RandomWalk1 C eps
----------------------------------------------
All other tests were passed




While a good PRNG however clearly pass the SmallCrush test

Code:
 
./bcd32_keystream 0x2ddd6a2c 0xfffffffe | ./TestU01_stdin -s


========= Summary results of SmallCrush =========

Version: TestU01 1.2.3
Generator: 32-bit stdin
Number of statistics: 15
Total CPU time: 00:00:26.17

All tests were passed


cHNiMUBACG0HAAAAAAAAAAAAAABIZVbDdKVM0w1kM9vxQHw+bkLxsY/Z0czY0uv8/Ks6WULxJVua
zjvpoYvtEwDVhP7RGTCBVlzZ+VBWPHg5rqmKWvtzsuVmMSDxAIS6Db6YhtzT+RStzoG9ForBcG8k
G97Q3Jml/aBun8Kyf+XOBHpl5gNW4YqhiM0=
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
ZetaBoards - Free Forum Hosting
Enjoy forums? Start your own community for free.
Learn More · Sign-up for Free
« Previous Topic · Utilities · Next Topic »
Add Reply