Home › Forums › TrueRNG Hardware random number generator › TrueRNG v3 Ubuntu setup
Tagged: linux, TrueRNG v3, ubuntu
This topic contains 3 replies, has 2 voices, and was last updated by dgv 6 years, 3 months ago.
-
AuthorPosts
-
December 30, 2017 at 6:25 pm #2120
Im running Ubuntu Server 16.04.3 LTS. I installed TrueRNG v3, RNG-Tools, and followed the install guide. Ubuntu uses getrandom(2) and it defaults to /dev/urandom but TrueRNG populates /dev/random.
How can I pass the GRND_RANDOM bit so I can utilize the TrueRNG v3? If I don’t change this then I won’t be using the TrueRNG v3 but I will be using PRNG of /dev/urandom instead.
http://manpages.ubuntu.com/manpages/xenial/man2/getrandom.2.html
GRND_RANDOM
If this bit is set, then random bytes are drawn from the
/dev/random pool instead of the /dev/urandom pool. The
/dev/random pool is limited based on the entropy that can be
obtained from environmental noise. If the number of available
bytes in /dev/random is less than requested in buflen, the call
returns just the available random bytes. If no random bytes are
available, the behavior depends on the presence of GRND_NONBLOCK
in the flags argument.December 30, 2017 at 6:28 pm #2121My goal is to call random_int(1,100000) from PHP which in turn calls getrandom(2) from Ubuntu which is using /dev/urandom as discussed until I make the change to Ubuntu.
December 30, 2017 at 7:02 pm #2122By default, getrandom() draws entropy from the urandom source (i.e.,
the same source as the /dev/urandom device). This behavior can be
changed via the flags argument.January 1, 2018 at 3:13 am #2124Hello,
The system call getrandom(2) is invoked within the implementation of php’s “random_int”.
Solution 1: if you have the source code of your PHP package
find the getrandom(2) call in the PHP source code, replace the 3rd argument (which should be “0″) by
GRND_RANDOM. Recompile and reinstall.Solution 2: read directly the TrueRNG device
You may write your own function “truerng_int” which reads the device.
Ask your favorite search engine for keywords “php call c function” or “php call c lib”;
you should find documentation on how to do this.
Look at the posting “Library and pgm” in this forum for a library offering C/C++ interfaces.Solution 3: do nothing
As a matter of fact, there is one single random pool in the kernel. The devices /dev/random and /dev/urandom
differ on their behavior for accessing this pool. With your device plugged-in, the pool should
be nearly filled most of the time, so using /dev/urandom is not a problem. See the man page urandom(4).cheers,
Denis/
-
AuthorPosts
You must be logged in to reply to this topic.