Entropy Source using RTL-SDR: Difference between revisions
No edit summary |
m added tinkering category |
||
| (7 intermediate revisions by the same user not shown) | |||
| Line 11: | Line 11: | ||
Get and compile {{code|rtl-entropy}}: | Get and compile {{code|rtl-entropy}}: | ||
{{highlight|lang= | {{highlight|lang=terminal|code= | ||
git clone https://github.com/pwarren/rtl-entropy.git | git clone https://github.com/pwarren/rtl-entropy.git | ||
cd rtl-entropy | cd rtl-entropy | ||
| Line 25: | Line 25: | ||
{{code|rtl_entropy}} will by default generate an socket at {{code|/var/run/rtl_entropy.fifo}}. Use the {{code|rngd}} to use this socket as an entropy source for {{code|/dev/random}}. This is accomplished by running: | {{code|rtl_entropy}} will by default generate an socket at {{code|/var/run/rtl_entropy.fifo}}. Use the {{code|rngd}} to use this socket as an entropy source for {{code|/dev/random}}. This is accomplished by running: | ||
{{highlight|lang= | {{highlight|lang=terminal|code= | ||
rtl_entropy -s 2.4M -e -b | rtl_entropy -s 2.4M -e -b | ||
rngd -f -r /var/run/rtl_entropy.fifo | rngd -f -r /var/run/rtl_entropy.fifo | ||
| Line 62: | Line 62: | ||
To see the current entropy pool size on your system, run | To see the current entropy pool size on your system, run | ||
{{highlight|lang= | {{highlight|lang=terminal|code= | ||
cat /proc/sys/kernel/random/poolsize | cat /proc/sys/kernel/random/poolsize | ||
}} | }} | ||
To see the current entropy bits available, run: | To see the current entropy bits available, run: | ||
{{highlight|lang= | {{highlight|lang=terminal|code= | ||
cat /proc/sys/kernel/random/entropy_avail | cat /proc/sys/kernel/random/entropy_avail | ||
}} | }} | ||
== Creating a Service == | == Creating a Service == | ||
To run the utilities above, create | To run the utilities above, create or edit the Systemd service file with the following contents. | ||
{{code|/usr/lib/systemd/system/rtl-entropy.service}}: | |||
{{highlight|lang=text|code= | |||
[Unit] | |||
Requires=rngd.service | |||
Description=RTL Entropy Gatherer Daemon | |||
[Service] | |||
ExecStartPre=/usr/bin/mkfifo /var/run/rtl_entropy.fifo | |||
ExecStart=/usr/bin/rtl_entropy -s 2.4M -o /var/run/rtl_entropy.fifo -e -q 1 | |||
[Install] | |||
WantedBy=multi-user.target | |||
}} | |||
{{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= | Requires=rtl-entropy.service | ||
Description=Hardware RNG Entropy Gatherer Daemon | |||
[Service] | [Service] | ||
ExecStart=/sbin/rngd -f -r /var/run/rtl_entropy.fifo | |||
ExecStart=/ | SuccessExitStatus=66 | ||
[Install] | [Install] | ||
| Line 89: | Line 103: | ||
== See Also == | == See Also == | ||
* [[Entropy]] | |||
* https://github.com/pwarren/rtl-entropy | * https://github.com/pwarren/rtl-entropy | ||
* | * http://sdr.osmocom.org/trac/wiki/rtl-sdr | ||
[[Category:Linux]] | {{Navbox Linux}}[[Category:Linux]] | ||
[[Category:Tinkering]] | |||
Latest revision as of 06:24, 1 September 2019
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/rtl-entropy.service:
[Unit]
Requires=rngd.service
Description=RTL Entropy Gatherer Daemon
[Service]
ExecStartPre=/usr/bin/mkfifo /var/run/rtl_entropy.fifo
ExecStart=/usr/bin/rtl_entropy -s 2.4M -o /var/run/rtl_entropy.fifo -e -q 1
[Install]
WantedBy=multi-user.target
/usr/lib/systemd/system/rngd.service:
[Unit]
Requires=rtl-entropy.service
Description=Hardware RNG Entropy Gatherer Daemon
[Service]
ExecStart=/sbin/rngd -f -r /var/run/rtl_entropy.fifo
SuccessExitStatus=66
[Install]
WantedBy=multi-user.target