| HG324 Hardware Random Bit Generator | Users Manual |
|
|
|
|
|
HG 324 Random Bit Generator | Contents | Testing random bits |
Contents:
Drivers for downloading random data from the HG 324 at the moment exist only for IBM compatible PC's based on either Linux or MS-DOS, MS Windows 3x/9x/Me/NT4/2000NT/XP operating systems.
However, we recommend to drive the HG 324 under the Linux because the best drivers exist for Linux and the best overall performance of the generator is achieved under Linux.
Linux is a free and open-code operating system whose popularity has been growing quickly in past years. We believe it is now, and will with time become even more, the most convenient operating system for software development and network oriented multi-user platforms.
Thus we have decided to develop all our software related to the HG 324 primarily for Linux with graphics output to the i X11 windows system. It is not because we like Linux, but simply because Linux gets the most out of your computer as well as from the HG 324 Random Bit Generator. Linux allows to combine low-level communication between software drivers and computer ports with a true 32 bit software architecture and a high-performance graphics,i thus making possible a very fast download of the random data from the HG 324 unit with the minimal load to the processor.
For example, normally serial PC port is designed to support baudrates up to 115200 bits/sec, exceptionally twice as much. Under Linux and with the help of our proprietary technology it is possible to achieve bitrates up to 1,200.000 bits/sec ! Under MS DOS or MS Windows, the actual bitrate is strongly dependent on the particular hardware/software setup but nevertheless the typical performance of 16 bit (DOS) driver falls between 400 and 800 kbit/sec. Much lower bitrate may be expected only under Windows NT4 which seem to have particularly poor support for legacy parallel port mode. The new 32 bit driver for MS Windows however should perform up to the maximum bitrate alowed by the hardware (see the Benchmarks section).
Unfortunately some serial ports seem not to perform very well when pushed to the extreme bitrates, but the worst-case we have tested gave excellent results at 1.0 Mbit/sec with 32 bit drivers (under Linux or MS Windows) and 0.5 Mbit/sec with 16 bit drivers under MS DOS or MS Windows.
On the other hand parallel ports seem to operate well up to the highest possible rate achievable by the hardware.
Note howewer that we do not recomend operation of the HG 324 at bitrates higher than 1,200.000 bits/sec.
On top of all that, there is a possibility that kernel modules for reading the HG 324 as an external device will be available freely from the Linux community in the near future. For the moment, a parallel port device module for a limited number of kernel versions is available from us upon a request. This approach allows you to access the random bits from within your program (written in any programming language) as simple as opening a file and reading as many data as you wish. You have to know nothing about the way the readout is done nor to include any subroutines in your program. This type of readout also achieves the maximum average downloading speed but on top of that it allows for buffering the bits and burst rates much higher that the average.
Nevertheless, for critical applications (such as multi-dimensional Monte Carlo or security protocols) it is strongly advised to test the quality of the random data downloaded from the HG 324 in the particular hardware setup where it is to be used. To that end we supply some programs for randomness testing (described below): graf, ent, utest. For further details please refer to the part of this section concerned with description of the software.
For the performance of the unit under supported operating systems, please look at the Benchmark section.
The software distributed with this package consists of:
| Program | Description |
| bitwr | a program to download random data from the HG 324 to a binary file |
| bitplot | a program to show random bits read from tht HG 324 as points in plane |
| zero | a program to measure the bias of internal generators |
| graf | a program to display visually bits stored in a file |
| ent | a collection of standard tests for testing randomness of bits stored in a file |
| utest | the Universal Randomness Test. |
The last three programs work "offline" that is they operate on previously generated files of random bits.
More detailed description of each program follows.
Usage:
bitwr [-s speed] [-b bytes] [-LPT1] [-COM1] [-COM2] [-bs blocksize] [-npause pause] [-f] outfile
The description of options is given below.
| Option | Meaning |
| -s speed | set download speed in bits/second (default=maximum) |
| -b bytes | set the number of bytes to download (default=8192) |
| -LPT1 | force download from the parallel port at 0x378 (default=automatic) |
| -COM1 | force download from the serial port at 0x2f8 |
| -COM2 | force download from the serial port at 0x3f8 |
| -bs blocksize | set the size of download blocks (default=256) |
| -npause pause | set a pause between two bit requests |
| -f | overwrite the output file if the one with the same name already exists |
| outfile | output filename. Downloaded bits are written in the binary form. |
Notes
If the speed in bit/second is specified via the -s option,
program first tries to determine
an approximate number of "pause" steps between the subsequent bit requests
before the beginning of the download. This can take up to a few seconds.
The pause value is written
to the screen.
Once the number of pause steps has been determined you can specify it
directly via the -npause option in which case program starts to download
bits immediately using this number of pause steps.
If nor the speed nor he npause are specified, program downloads
bits at the at the maximum speed.
In order to speed up the writing of the downloaded data into the outpuit file, program buffers "blocksize" number of bytes before writing them. On systems with a busy disk it may pay off to set larger blocksize. However, the default size of 256 bytes should be enough for most systems. Actual number of downloaded bytes is rounded to the smallest number of blocks that is greater or equal to the requested filesize.
If none of the options -LPT1, -COM1, -COM2 is specified program scans the three ports in that order and searches for the HG 324. During this scan, some serial devices (especially those powered from the port such as a serial mouse) can get blocked. If that happens, the device can be unblocked by restarting its driver. In order to avoid this problem, you may force the readout from a selected ioport by specifying the appropriate option, in which case program reads only from the specified port rather than performing a scan over all ports.
Example 1.
bitwr -b 1000000 -f bits.01
download a million of bytes of random data (8E+06 bits) at the maximum speed and store them into the binary file named "bits.01".
Example 2.
bitwr -s 900000 -b 100000 -LPT1 -f bits.01
download a 100 kbyte (800 kbits) of random data, at the speed of 900000 bits/sec, from the HG 324 unit located at the parallel port and store them into the file "bits.01". Note that the option "-LPT1" forces the radout from the parallel port no matter if the unit is there or not.
Usage:
bitplot [-s speed] [-b bytes] [-drmd2] [-LPT1] [-COM1] [-COM2] [-bs blocksize] [-npause pause]
Program supports the following options:
| Option | Meaning |
| -s speed | set download speed in bits/second (default=maximum) |
| -b bytes | set the number of bytes to download (default=8192) |
| -drmd2 | set the inverting draw mode (default=unconditional) |
| -LPT1 | force download from the parallel port at 0x378 (default=automatic) |
| -COM1 | force download from the serial port at 0x2f8 |
| -COM2 | force download from the serial port at 0x3f8 |
| -bs blocksize | set the size of download blocks (default=256) |
| -npause pause | set a pause between two bit requests |
The actual number of points drawn is equal to the half of the requested number of bytes.
There are two available modes of drawing:
the unconditional draw mode (default)
in which a point overwrites the previous
contents of that pixel, and
the inverting mode (invoked by the option -drmd2)
in which a point inverts the previous
contents of that pixel.
Let us suppose that the background is white and points are black. In the first mode, points populate the 256x256 pixel area and as more points are drawn, the area becames darker and darker, finally becoming completely black.
On the other hand, in the second mode points populate the area until there is an equal chance of the point to be black or white. When this equilibrium is reached, drawing new points does not change much the black/white balance but the picture itself is constantly changed and looks very much like screen of a tv set tuned on an empty channel.
Note
Due to the business of drawing the points, this program cannot achieve as high bitrates as the program bitwr. The maximum attainable download rate depends mostly on the speed of the graphics adapter present in your computer.
Example 1.
bitplot -b 80000
plots 40000 points in the unconditional mode at the maximum speed.
The measurement is fast because of the built in algorithm which
works in the same manner as measuring the average voltage by
a low pass-filter. Nevertheless, to get the last digit right
it takes some minutes.
Bias should not depend on the downloading bitrate.
Readings with this program should be close to 0.5000 +/- 0.0010
Significant deviation indicate that something is wrong either with
the computer port in question or the generator.
Usage:
zero [-s speed] [-COM1] [-COM2] [-npause n] [-T sec] [-tau sec]
Description of the options is given below.
| Option | Meaning |
| -s speed | set the download speed in bits/second (default=100 kbit/sec) |
| -COM1 | force download from the serial port at 0x2f8 (default is the parallel port at 0x378) |
| -COM2 | force download from the serial port at 0x3f8 |
| -npause pause | set a pause between two bit requests rather than setting the speed |
| -T | screen refresh period in seconds (default=0.1s) |
| -t | exponential dumping factor in seconds (default 1.25s) |
Tip
Increase the exponential dumping factor if you wish to reach more stable and reliable result, but then you will wait longer for readings to settle down to its final value.
Example
zero
measures biases of the internal generators from the parallel port
at the download speed of 100000 bits/sec from each generator.
Please note that due to the task of updating the readings
on the screen, it is not possible to obtain the maximum download
rate per internal generator of 300000 bit/sec.
graf filename
where filename is name of the binary file of random bytes (produced by the program bitwr) you want to analyze and answer the questions. The result of test are the 1-D, 2-D and 3-D projections of random points. Here, the idea is to use the power of human brain to spot regularities (patterns) in an irregular, random picture. Any pattern that may be observed means that the produced bits are not completely random. A typical result form a file produced by the HG 324 generator looks similar to this:
|
|
Under Linux, program allows for storing the resulting picture(s) in an GIF image file. This program works under X-windows (X11).
HG 324 comes with the software for downloading the random data from it and some randomness tests. Please read more about that in the Software section of this manual.
Executables are available for Linux with C library versions libc5 and glibc2. Since only executables are distributed with this disk, it is necessary to find out which version of C library came with your Linux system in order to install adequate binaries. But don't worry: if you are not expert on that matter, you can simply try all versions of binaries and find which one works on your system.
Binaries are organized in two directories named libc5 and glibc2, refering to the version of C library installed on your Linux system. Some Linux systems support both versions of C libraries.
Below is a non-exhaustive table of C library versions used in different Linux distributions.
| Linux brand and version | C library |
| Slackware 4.x, Red Hat 5.x | libc5 |
| Slackware 7.0 and up, Red Hat 6.0 and up | glibc2 |
In order to install necessary software and manual, please follow a few simple steps:
mkdir ~/hg324
2. go into that directory:
cd ~/hg324
3. copy the whole contents of the floppy disk to that directory: This you can do in two ways.
a) If your Linux has mtools installed then simply type:
mcopy -p -n a: .
b) if you do not have mtools, then obtain the root privileges via the "su" command, and type the following:
su root (you'll be prompted for the superuser password)
mount /dev/fd0 /mnt
exit
cp -rf /mnt/* .
su root (you'll be prompted for the superuser password)
umount /mnt
exit
4. Next, you have to identify the directory where the executables compatible with your Linux libraries. For newer Linux it would be the gnulib2 directory (the alternative is libc5 directory). Go to that directoru and set up the necesary privileges for the executables. To do that you must run the script Setup as the superuser:
cd Linux/gnulib2
su root (you'll be prompted for the superuser password)
./Setup
exit
Setup is a simple script that will give necessary permissions to executables.
Please note that you absolutely MUST be the root in order to install the drivers the HG 324. By drivers we mean all the programs that are able to read data from the HG 324 unit. These are: bitwr, bitplot and zero.
5. The following step is optional. If you wish to install the exetutables system wide, then in the previous step, immediately after the Setup run the script Install:
./Install
By default, executables will be copied to the directory /usr/local/bin and their permissions will be set appropriately.
Again, you MUST have the root privileges to install this way. But once you have done it, any user from the system who has the "/usr/local/bin" in his/her path will be able to run all the programs, including drivers bitwr, bitplot and zero.
Drivers for the MS DOS and MS Windows 2x,3x,95,98, ME, NT4, 2000NT and XP are actually a port of the Linux drivers to the 16 bit MS DOS or 32 bit Windows (Win32) architecture. The 16 bit drivers are found in the directory named A:\DOS and one should use them only under MS DOS and MS Windows 2x,3x. Under MS Windows 95 and up one should use 32 bit drivers because they offer better performance. Hovewer, newer MS Windows (that is NT4, 2000NT and XP) do not allow by default the low-level access to PC ports which is needed to obtain the maximum download rate. To enable such an access we make use of a third-party freeware. There are several such programs available and one of them named "UserPort" is distributed with the HG 324 software disk.
Installation procedure of the HG 324 software is simple: you only need to copy all the executables into some directory on your hard disk drive. For MS Windows NT4, 2000NT or XP there is one more step to install the third-party driver.
The installation procedure is as follows:
cd c:\
mkdir hg324
2) go into that directory:
cd hg324
3) copy from the diskette all the DOS/Windows files.
copy a:\DOS\* .
copy a:\Win32\* .
If you are using MS Windows NT4, 2000NT or XP it is necessary to also install a driver that allows low-level access to the parallel and/or serial ports that are used with HG 324.
cd a:\Win32\userport\WinNT
Install
For Windows XP do the following:
cd a:\Win32\userport\WinXP
Install
When the userport window appears, just click "Start" then "Exit". The driver will be installed in the memory and it will stay there until PC is rebooted. The next time userport may be started from any directory. The executable is located in the C:\winnt (NT) or C:\windows (XP) directory. It is also possible to make uaserport start each time PC is booted by making apropriate entry in the autoexec.bat. Advanced users are encouraged to consult the drivers' documentation supplied with the driver package located in the directory a:\Win32\userport\Userport.zip for further information.
This completes the installation and you may start any program in the directory c:\hg324 .
Although the software is only a port (that is not really optimized for operation under MS DOS/Windows), it nevertheless achieves the download speeds up to 30-50 times faster then of other similar products on the market today, which is primarily due to the use of four independent high-performance bit generators built in the HG 324 and an advanced bit-transfer technology.
For the performance of the unit under all supported systems for IBM compatible PC's, please look at the Benchmark section.
|
|
|
|
HG 324 Random Bit Generator | Contents | Testing random bits |