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. It will require sudo permissions when using swrng-cl and swrng utilities with Linux or freeBSD based systems. For best results, all devices in a cluster should have same generation speeds and the system should have available a CPU/MCU core (or a hyper thread) per device.

SwiftRNG devices manufactured after March 2020 are viewed by Linux as ttyACM devices, by macOS as cu.usbmodem devices and by Windows as COM ports.

Instructions for bulding swrng-cl and swrng utilities can be found at this location.

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:

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,000,000 bytes of true random numbers from the SwiftRNG device and store them in a file named rnd.bin:

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,000,000 bytes of true random numbers from a of four SwiftRNG devices and store them in a file named rnd.bin:

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

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

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:

swrng -dd -fn rnd.bin

To continuously feed the Linux /dev/random entropy pool, use the following command (it requires sudo permissions):

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

To automatically start feeding the Linux /dev/random entropy pool at boot time when using Linux, add the following line in crontab (you can open crontab editor with sudo crontab -e command):

@reboot /usr/local/bin/swrng -fep >> /var/log/swrng-fep.log 2>&1

By default, 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 -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 bit Windows 10 and 64 bit Windows Server 2016/2019.

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 devices manufactured before March 2020 are viewed by Windows as Universal Serial Bus device. SwiftRNG devices manufactured after March 2020 are viewed by Windows as USB COM port.

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 Visual Studio 2019 and located in folder windows-binaries\windows-x64-vs-2019\.

To verify the SwiftRNG 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
  • DevModel – RNG device model
  • DevVer – SwiftRNG device version
  • DevS/N – Unique serial number assigned to a SwiftRNG device when manufactured

To download 12,000,000 bytes 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

Other commands and options available

The complete list of commands and options available with swrng can be retrieved using the following command:

swrng

Non-root access on Linux

To enable a non-root user to access the SwiftRNG device, simply copy the supplied 80-swiftrng-usb-access.rules file to /etc/udev/rules.d/ location. You may need to reboot the system for the changes to take effect. The non-root user access can be verified using the following command:

swrng -ld