The swrng software utility can be used to verify the SwiftRNG installation status and download true random bytes from a SwiftRNG.

Linux and macOS

The software kit contains the swrngapi.c and swrngapi.h source files that can be included in other projects for communicating with the SwiftRNG device directly. Source files swrng-cl-api.c and swrng-cl-api.h are used for communicating with a cluster of multiple SwiftRNG devices to boost the generation speed and for fail-over capability.

Note: swrng-cl is a clustered version of the swrng utility and it is designed to work with a cluster of two or more SwiftRNG devices concurrently.

After the SwiftRNG device is plugged into an available USB port, to verify that the device was successfully configured for Linux or macOS, run the following from the command line:

sudo swrng –ld

When the SwiftRNG device is successfully installed and ready, the output from running the above command should look something like this:

{DevNum=0 DevModel=SwiftRNG DevVer=V1.2 DevS/N=HJA5A6D44A5BD43}

Where:

  • DevNum – logical device number starting with 0 (you can use multiple SwiftRNG devices)
  • DevModel – RNG device model
  • DevVer – SwiftRNG device version
  • DevS/N – Unique serial number assigned to a SwiftRNG device when manufactured

To download 12 MB of true random numbers from the SwiftRNG device and store them in a file named rnd.bin:

sudo swrng -dd -fn rnd.bin -nb 12000000
...
Completed in 1 seconds, post-processing method used: none, device built-in correction method used: none, 
speed: 11718 KBytes/sec, blocks re-sent: 0

To download 12 MB of true random numbers from a cluster of four SwiftRNG devices and store them in a file named rnd.bin:

sudo swrng-cl -dd -fn rnd.bin -nb 12000000 -cs 2
...
Completed, cluster size: 2, fail-over events: 0, cluster resize attempts: 0

To download 12 MB of true random numbers from the SwiftRNG device and send them to standard output:

sudo swrng -dd -fn STDOUT -nb 12000000

To download an unlimited amount of true random numbers from the SwiftRNG device and store them in a file named rnd.bin:

sudo swrng -dd -fn rnd.bin

To continuously feed the Linux /dev/random entropy pool, use the following command:

sudo swrng -fep
...
Feeding the kernel /dev/random entropy pool. Initial amount of entropy bits in the pool: 652 ...

By default, the swrng utility will use the SwiftRNG power profile 9 (the fastest speed and highest power consumption). The following demonstrates how to lower the power consumption of SwiftRNG by setting power profile number to 4 (the number must be between 0 and 9) for downloading random bytes:

sudo swrng -dd -fn rnd.bin -nb 12000000 -ppn 4
...
Completed in 1 seconds, post-processing method used: none, device built-in correction method used: none, 
speed: 11718 KBytes/sec, blocks re-sent: 0

Windows

This applies to 64 bits Windows 7, 8.1 and 10.

The SwiftRNG device should be connected to the PC using one of the available USB 2.0 or 3.0 ports. Once the SwiftRNG device is connected for the first time, Windows OS will automatically install the appropriate certified USB driver.

SwiftRNG software kit contains pre-built utilities and components that can be used on Windows. You can download the latest windows-binaries.zip here.

The SwiftRNG software kit contains the swrng.exe software utility that was built with VC C++ 2017 and located in folder windows-binaries\windows-x64-vs-2017\.

To verify the swrng device installation status, run the following command from the command line:

swrng.exe -ld

When the SwiftRNG device is successfully installed and ready, the output from running the above command should look something like this:

{DevNum=0 DevModel=SwiftRNG DevVer=V1.0 DevS/N=HJA5A6D44A5BD43}

Where:

  • DevNum – logical device number starting with 0 (you can use multiple SwiftRNG devices)
  • DevModel – RNG device model
  • DevVer – SwiftRNG device version
  • DevS/N – Unique serial number assigned to a SwiftRNG device when manufactured

To download 12 MB of true random numbers from the SwiftRNG device and store them in a file named rnd.bin:

swrng.exe -dd -fn rnd.bin -nb 12000000

To download an unlimited amount of true random numbers from the SwiftRNG device and store them in a file named rnd.bin:

swrng.exe -dd -fn rnd.bin

By default, the swrng utility will use the SwiftRNG power profile 9 (the fastest speed and highest power consumption). The following demonstrates how to lower the power consumption of SwiftRNG by setting power profile number to 4 (the number must be between 0 and 9) for downloading random bytes:

swrng.exe -dd -fn rnd.bin -nb 12000000 -ppn 4

Non-root access on Linux

To enable a non-root user to access swrng and swrngapi, simply copy the supplied 80-swiftrng-usb-access.rules file to /etc/udev/rules.d/.