AES Pseudorandom Number Generator Test Jig


This page permits evaluation of the quality of pseudorandom data generated by the AESprng generator. It is used in conjunction with the XD and ENT programs.

Pressing the Generate button generates the number of bytes of pseudorandom specified in tbe Bytes box seeding the generator with the specified Seed, placing the results in hexadecimal form in the Pseudorandom Sequence box and selecting it. You can then copy the data and paste it to a file (for example "/tmp/a"), which may converted to binary with the XD program and tested for randomness with the ENT program with a sequence like the following.

    % xd -l /tmp/a /tmp/b
    % wc -c /tmp/b
      65536 /tmp/b
    % ent /tmp/b
    Entropy = 7.997183 bits per byte.

    Optimum compression would reduce the size
    of this 65536 byte file by 0 percent.

    Chi square distribution for 65536 samples is 255.48, and randomly
    would exceed this value 50.00 percent of the times.

    Arithmetic mean value of data bytes is 127.3066 (127.5 = random).
    Monte Carlo value for Pi is 3.163156931 (error 0.69 percent).
    Serial correlation coefficient is -0.000628 (totally uncorrelated = 0.0).
This is the result obtained seeding the generator with a single hexadecimal key byte of 1.

Note: when you run this test, you may have to answer one or more warning messages issued by the browser to the effect that the script has become "unresponsive". Do not cancel the script--tell the browser to keep going until the hexadecimal data appear in the box. In Mozilla 1.5 and possibly other browsers, this warning alert is very poorly phrased: if you click "OK", it terminates the script. To permit the script to continue, you must click the "Cancel" button. It pays to read the text of such warnings carefully before clicking away!

Seed


 Text    Hexadecimal      

Pseudorandom Sequence

Bytes:    Generated:    Test:  next()  nextInt(255)
     

Enter the number of bytes you wish to generate in the Bytes field above. If you check the next() button, the "get next byte" method will be tested. If the nextInt(255) button is checked, bytes are obtained with the nextInt method which returns a 32 bit value and scales it to the desired range, in this case 0 to 255. If the script execution pauses during generation with an "unresponsive" warning from the browser, the Generated field will show the number of bytes generated so far, rounded down to a multiple of 1024.

JavaScrypt Home Page

Fourmilab Home Page


by John Walker
November, 2003
This document is in the public domain.