On 26.08.17 10:55, MM wrote:
> On Saturday, 26 August 2017 01:17:32 UTC+1, Karl.Frank wrote:
>> Coming across this discussion
>>
>>
https://unix.stackexchange.com/questions/324209/when-to-use-dev-random-vs-dev-urandom
>>
>> most surprises was this answer
>>
>> According to Theodore Ts'o on the Linux Kernel Crypto mailing list,
>> /dev/random has been deprecated for a decade. From Re: [RFC PATCH v12
>> 3/4] Linux Random Number Generator:
>>
>> Practically no one uses /dev/random. It's essentially a deprecated
>> interface; the primary interfaces that have been recommended for well
>> over a decade is /dev/urandom, and now, getrandom(2).
>
> Ferguson, Schneier and Kohno explain why very well in section 9.1.3 of
> "Cryptography Engineering" ISBN 978-0-470-47424-2.
>
>> So, on system boot it seems to be appropriate seeding /dev/random first
>> and shortly thereafter /dev/urandom with some previously saved seeds -
>> or even restore the complete /dev/uramdom pool from a previously saved
>> state (as the random man page recommends).
>>
>> Assuming that /dev/urandom always maintain a full 4096 bit pool lead me
>> to these further questions:
>
> That is an assumption that is not viable.
>
>> * is this a proper way to feed external entropy into the /dev/urandom pool?
>>
>> dd if=/dev/trng bs=1 count=2048>> /dev/urandom
>
> On FreeBSD, sure.
>
This is some comment I found on Debian at /etc/init.d/urandom
#-------------------
...
Redirect output of subshell (not individual commands)
to cope with a misfeature in the FreeBSD (not Linux)
/dev/random, where every superuser write/close causes
an explicit reseed of the yarrow.
) >/dev/urandom
#-------------------
Regarding this the above mentioned feeding command should read
(dd if=/dev/trng bs=1 count=2048) >> /dev/urandom
if I interpret it correctly because otherwise the pool might become
"easier" to predict.
>> * is there any way to verify that feeded entropy with the above
>> mentioned command get properly injected?
>
> See the source. If you could determine the security state of the interface
> externally, you could attack it when its at its weakest. If you can't tell the
> difference between weak state and strong state, you can't use that to
> attack it.
>
> M
Of course this seems to be the logical approach. But on the other hand
you would might need to check the source for every Linux and *BSD
distribution. And furthermore after every update perhaps. In my opinion
a very hefty task.
But maybe the following answer on a similar question in the slackware
newsgroup and my rely on this matter might shed some light on the issue.
>
> Finally, for people who don't want to read "man 4 random", here is a
> snippet which (partially?) answers Karl's question:
> Writing to /dev/random or /dev/urandom will update the entropy
> pool with the data written, but this will not result in a higher
> entropy count. This means that it will impact the contents read
> from both files, but it will not make reads from /dev/random
> faster.
>
>
> Jim
>
That's what I'm really up to, seeding proper random data into the
entropy pool, either /dev/random or (if writing is permitted such as on
some virtual servers i.e. OpenVZ) to /dev/urandom.
Currently I'm observing on a virtual server which is under heavy ssh
attack that the available entropy of /dev/random frequently, at least
every 5 minutes, is decreasing to just 1 bit! And it stays at this
extremely low level for about 30 to 60 seconds. Then very slowly
increasing to 4, 10, 26, 45 and after about 3 minutes a jump up to round
about 120 to 150.
However constantly writing some 2048 bit FIPS-140-2 compliant data to
/dev/urandom keeps the available entropy of /dev/random on a regular
level of about 180.
So writing quality randomness to /dev/urandom seems to be a
reasonable mitigation against draining /dev/random.
--
cHNiMUBACG0HAAAAAAAAAAAAAABIZVbDdKVM0w1kM9vxQHw+bkLxsY/Z0czY0uv8/Ks6WULxJVua
zjvpoYvtEwDVhP7RGTCBVlzZ+VBWPHg5rqmKWvtzsuVmMSDxAIS6Db6YhtzT+RStzoG9ForBcG8k
G97Q3Jml/aBun8Kyf+XOBHpl5gNW4YqhiM0=