You are not logged in.

#1 2020-07-01 15:43:35

tugliano
Member
Registered: 2020-07-01
Posts: 1

Fast /dev/random even if not using rng-tools

Hi!
I was reading about rng-tools in the wiki. According to what is written, if it isn't installed and enabled, this specific command should be extremely slow:

dd if=/dev/random of=/dev/null bs=1024 count=1 iflag=fullblock

However, I don't have it, and also don't have haveged, But that command execute instantly:

❮ sudo dd if=/dev/random of=/dev/null bs=1024 count=1 iflag=fullblock
1+0 records in
1+0 records out
1024 bytes (1.0 kB, 1.0 KiB) copied, 7.0418e-05 s, 14.5 MB/s

Even if I increment the "count", say to 100, it also terminate instantly.
I really don't know why is so.
My processor is an Intel i7-8550U.
Can hardware random number generation be enabled by default? I am not sure if I really need rng-tools if os

Offline

#2 2020-07-01 16:15:38

GaKu999
Member
From: US/Eastern
Registered: 2020-06-21
Posts: 696

Re: Fast /dev/random even if not using rng-tools

This may be better as a wiki discussion or in the wiki subforum.

It also goes fast for me, but in certain scenarios there isn’t enough entropy available and thus, getting extra entropy from haveged or a hardware TRNG is the way to go, for example, a live os loaded in RAM with no hard disk usage or tiny embedded devices.

The kernel by defaults gets some entropy but it may not be enough in those cases.

Last edited by GaKu999 (2020-07-01 16:15:53)


My reposSome snippets

Heisenberg might have been here.

Offline

#3 2020-07-01 16:54:11

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,701

Re: Fast /dev/random even if not using rng-tools

I do not know about that processor, but yes, hardware TRNGs can be very fast and do not need tools like rng-tools.   

ewaller@odin/home/ewaller % time dd if=/dev/random of=/dev/null bs=1024 count=1000 iflag=fullblock
1000+0 records in
1000+0 records out
1024000 bytes (1.0 MB, 1000 KiB) copied, 0.0125223 s, 81.8 MB/s

real	0m0.014s
user	0m0.000s
sys	0m0.014s
ewaller@odin/home/ewaller % 

I have neither haveged or rng-tools installed


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#4 2020-07-01 17:53:30

frostschutz
Member
Registered: 2013-11-15
Posts: 1,652

Re: Fast /dev/random even if not using rng-tools

the random behavior of the kernel changed a lot in the last 1-2 years

the random generator has a much faster algorithm (used to be capped under 10MB/s, now over 200MB/s, on the same machine) and the kernel collects entropy more actively too

so a lot of info regarding random is simply outdated. things improved a lot.

for wiping hard drives and such, if you need gigabytes of random data, PRNG/AESNI is still faster though...

Offline

#5 2020-07-01 18:36:17

mpan
Member
Registered: 2012-08-01
Posts: 1,644
Website

Re: Fast /dev/random even if not using rng-tools

tugliano:
Despite “/dev/random” having mythological status, on Linux it was — from practical point of view — generating pseudorandomness⁽¹⁾ of the same quality as “/dev/urandom” for ages. The difference was that “/dev/random” was blocking until entropy counter was high enough, which basically meant it was ensuring random data was mixed in often enough into PRNG output it used. Thomas Hühn explains “/dev/random” of the past, if you want some details. That “/dev/random” behavior has changed in 5.6 and now “/dev/random” is exactly the same as “/dev/urandom” after the initial seeding.⁽²⁾ Therefore they generate pseudorandom data at the same rate.

In any case, in software one should use the getrandom(2) to acquire pseudorandomness, not either of the files directly.

____
⁽¹⁾ Yes, “/dev/random” is a PRNG and uses the same algorithm as “/dev/urandom”.
⁽²⁾ Phoronix on 5.6 changes

Offline

Board footer

Powered by FluxBB