AES Pseudorandom Number Generator
Test Jig


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

Pressing the Generate button generates the number of bytes of pseudorandom data 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 them 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.997454 bits per byte.

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

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

    Arithmetic mean value of data bytes is 127.5236 (127.5 = random).
    Monte Carlo value for Pi is 3.166453031 (error 0.79 percent).
    Serial correlation coefficient is 0.001007 (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


       

Pseudorandom Sequence

Bytes:    Generated:    Test:
     

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.


This document is in the public domain.