Linux

The swrandom make project is available in the following SDK location:

linux\swrandom

We strongly recommend performing the following steps before building the swrandom module on Ubuntu:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get reboot
sudo apt-get install make
sudo apt-get install gcc

We strongly recommend performing the following steps before building the swrandom module on CentOS and Red Hat with system administration permissions:

yum install make
yum install gcc
yum install kernel-devel
reboot

The swrandom module can be built with make. You will need to rebuild the module each time a new version of the kernel is installed (this step and the next one can be automated so that the module can be built and loaded at system boot time so you will not need to perform it manually - ask system administrator to automate these steps).

Once the module is successfully built with make, it should be loaded into the kernel by running the ins-swrandom.sh script with system administration permissions:

./ins-swrandom.sh

To load the module with a specific SwiftRNG power profile, use the following command (this example loads the module using SwiftRNG power profile 5, valid values are 0 through 9):

./ins-swrandom.sh powerProfile=5

After the swrandom module is successfully loaded by the kernel, the random bytes will be available for download from the following device:

/dev/swrandom

The module allows the entropy available in /dev/swrandom to be distributed concurrently by multiple consumer applications.

You can download random bytes to a file using the following command:

sudo dd if=/dev/swrandom of=download.bin bs=100 count=120000

The swrandom module will automatically detect the event when a SwiftRNG device is plugged in or unplugged from any USB port.

To verify if the swrandom module has successfully detected the SwiftRNG device, simply check the kernel system logs, you should see a log that should look similar to this:

  -----------------------------------------
  -- SwiftRNG device connected and ready --
  -----------------------------------------

Currently the swrandom module can only use one SwiftRNG device at a time.

swrandom module can be unloaded from the kernel by running the following command (using system administration privileges):

rmmod swrandom

Configuring for rngd on Ubuntu

The following steps explain how to configure swrandom module for use with rngd daemon on Ubuntu server (64 and 32 bits) or desktop versions:

Step 1

Make sure the OS is updated with the latest changes by running the following from command line:

sudo apt-get update
sudo apt-get upgrade

Step 2

Reboot the system after step 1:

sudo reboot

Step 3

Make sure the make, gcc and rng-tools packages are installed by running the following commands:

sudo apt-get install make
sudo apt-get install gcc
sudo apt-get install rng-tools

Step 4

Build the swrandom module, make sure it builds successfully:

cd swrandom
make

Step 5

Install the swrandom module (if successfully installed, it will create device /dev/swrandom):

sudo ./ins-swrandom.sh

Step 6

Make sure the SwiftRNG device is plugged in and the module has been installed successfully and initialized.

You should see a log fragment similar to the following in kernel system logs:

  -----------------------------------------
  -- SwiftRNG device connected and ready --
  -----------------------------------------

Step 7

Execute the following test from command line to verify that the SwiftRNG device is working:

sudo dd if=/dev/swrandom of=/dev/null bs=12000000 count=10

You should get a report similar to this one after waiting for about 10 seconds:

10+0 records in
10+0 records out
120000000 bytes (120 MB) copied, 9.60855 s, 12.5 MB/s

Step 8

You can start the rngd daemon by running the following (this daemon is part of the rng-tools package) (repeat this step if the SwiftRNG device gets re-connected to the computer):

sudo rngd -r /dev/swrandom

The command will return to command line with no message if everything went well. The rngd daemon will use the entropy from /dev/swrandom to actually feed the /dev/random pool. It will also check the SwiftRNG data quality when using /dev/swrandom device.

Step 9

Now you can test the /dev/random pool by running the following:

sudo dd if=/dev/random of=download.bin bs=1 count=120000

The output may look similar to this:

120000+0 records in
120000+0 records out
120000 bytes (120 kB) copied, 4.28862 s, 28.0 kB/s

Non-root access on Linux

To enable a non-root user to access the /dev/swrandom device, simply copy the supplied 80-swiftrng-device-access.rules file to /etc/udev/rules.d/ location.