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

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 4

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

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

Windows

This applies to 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 (the driver is already provided by OS).

The Software & Documentation Kit contains the swrng.exe software utility located in folder windows-x64\x64\Release. Alternatively, the folder windows-x64\swrng contains a Visual Studio C++ 2015 project that can be used to build the swrng.exe software utility. The kit also comes with the SwiftRNG.dll and complete source code that can be included in other software projects for sharing random data generated by SwiftRNG device.

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

windows-x64\x64\Release\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:

windows-x64\x64\Release\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:

windows-x64\x64\Release\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:

windows-x64\x64\Release\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/.