Entropy Source using RTL-SDR: Difference between revisions

From Leo's Notes
This page was last edited on 23 November 2015, at 09:25.
m see also rtl-sdr info
service file update
Line 72: Line 72:


== Creating a Service ==
== Creating a Service ==
To run the utilities above, create a new Systemd service file with the following contents.
To run the utilities above, create or edit the Systemd service file with the following contents.


{{code|/usr/lib/systemd/system/rngd.service}}:
{{code|/usr/lib/systemd/system/rngd.service}}:
{{highlight|lang=text|code=
{{highlight|lang=text|code=
[Unit]
[Unit]
Description=RTL Entropy
Description=Description=Hardware RNG Entropy Gatherer Daemon


[Service]
[Service]
ExecStartPre=/usr/bin/rtl_entropy -s 2.4M -b
ExecStartPre=/usr/bin/rtl_entropy -s 2.4M -b
ExecStart=/usr/bin/rngd -f -r /var/run/rtl_entropy.fifo
ExecStart=/usr/sbin/rngd -f -r /var/run/rtl_entropy.fifo
ExecStopPost=/usr/bin/killall rtl_entropy
ExecStopPost=/usr/bin/killall rtl_entropy



Revision as of 09:25, 23 November 2015

You can use a cheap RTL-SDR USB dongle as an entropy source for your linux machine using the rtl-entropy project.

Installation

Depending on your system, you might not have the rtl-entropy package. In which case, you will need to compile it manually.

Install the rng-tools package, and also the rtl-entropy dependencies:

  • rng-tools
  • rtl-sdr-devel
  • libcap-devel
  • openssl-devel

Get and compile rtl-entropy:

git clone https://github.com/pwarren/rtl-entropy.git
cd rtl-entropy
mkdir build
cd build
cmake ../
make

Run make install or copy the src/rtl_entropy binary to somewhere on the system such as /usr/bin.

Usage

rtl_entropy will by default generate an socket at /var/run/rtl_entropy.fifo. Use the rngd to use this socket as an entropy source for /dev/random. This is accomplished by running:

rtl_entropy -s 2.4M -e -b
rngd -f -r /var/run/rtl_entropy.fifo

rtl_entropy Arguments

Arguments passed to rtl_entropy are:

-s sample rate
-e Use Kaminsky debiasing
-b run as a daemon.

Because we are capturing radio, it is possible for an attacker to influence our random pool and possibly any keys generated using this pool. The rtl-entropy developer mentions this on the project's github page and recommends enabling the -e option to turn on Kaminsky debiasing. This in essence makes influencing the entropy pool harder to guess by an attacker.

rngd Arguments

Arguments passed to rngd are:

-f Run in the foreground
-r Specify the entropy device
-W The watermark size (defaults to 2048 bits or typically half of the entropy pool size)

The watermark size defines how much influence this device has on the random pool. Setting this too high means the device will dominate the contents of the entropy pool.

To see the current entropy pool size on your system, run

cat /proc/sys/kernel/random/poolsize

To see the current entropy bits available, run:

cat /proc/sys/kernel/random/entropy_avail

Creating a Service

To run the utilities above, create or edit the Systemd service file with the following contents.

/usr/lib/systemd/system/rngd.service:

[Unit]
Description=Description=Hardware RNG Entropy Gatherer Daemon

[Service]
ExecStartPre=/usr/bin/rtl_entropy -s 2.4M -b
ExecStart=/usr/sbin/rngd -f -r /var/run/rtl_entropy.fifo
ExecStopPost=/usr/bin/killall rtl_entropy

[Install]
WantedBy=multi-user.target

See Also