Разделяет ли «урандом» ту же энтропию «случайного»?

840
Xiè Jìléi

Использует ли пул энтропии / dev / random то же самое для / dev / urandom?

я бы хотел

mknod /dev/random 1 9 

чтобы заменить медленное случайное, я думаю, что текущая энтропия достаточно случайна, если urandom основан на той же энтропии, и все последующие случайные числа генерируются на основе этой энтропии, я не думаю, что будет какая-либо уязвимая.

3

3 ответа на вопрос

9
T.J. Crowder

В конце концов, то, что urandomдает вам, вполне может зависеть от реализации, но на странице руководства сказано, что она будет использовать имеющуюся энтропию, если она там есть, и прибегнет к PRNG только тогда, когда у нее кончится энтропия. Так что, если у вас достаточно энтропии, вы должны получить такой же хороший результат, как если бы вы использовали randomвместо этого.

Но, и это большое, но: вы должны предположить, что вы получаете чисто псевдогенерируемое значение без какой-либо подлинной энтропии вообще, потому что пул энтропии может быть пустым. Таким образом, вы должны рассматривать urandomкак PRNG, даже если это может быть лучше, чем в любой конкретной ситуации. Независимо от того, является ли это, не является детерминированным (в пределах вашего кода), и вы должны ожидать, что наихудший случай будет применим В конце концов, если бы вы были уверены, что в пуле достаточно энтропии, вы бы использовали random, верно? Таким образом, сам акт использования urandomозначает, что вы в порядке с PRNG, а это означает потенциально теоретически взломанный результат.

1
Erwan Legrand

The problem here is not that /dev/urandom is a PRNG. The problem is /dev/urandom will not block until enough entropy has been gathered to seed it.

Thus, you don't want to use either /dev/random or /dev/urandom on Linux. You need something which provides a replacement for these, be it a kernel module or a daemon.

Another option is to switch to FreeBSD where both /dev/random and /dev/urandom do what you want, i.e. they provide cryptographically strong pseudo-random numbers and block until they are seeded.

0
The Spooniest

urandom uses the same entropy pool that random does, and if there is enough entropy in the pool at the moment you call it, it returns the same kinds of results that random would.

However, you might be surprised at just how big of an if that can be, and it's not something that you have any direct control over. Most computers are not equipped with hardware that constantly gathers any kind of reliable entropy, and gathering enough of it from non-constant but reliable sources can take a while. When there isn't enough, urandom falls back on a PRNG, with all the problems (including predictability) that go with it.

For a lot of applications -most games, for example- that's still good enough. But there are important applications where it isn't, and I assure you, your machine does use those applications behind the scenes even if you don't consciously see/use them. For that reason, it's not a good idea to just use urandom everywhere.

Out of curiosity, what makes you think random is so slow? Where is your computer locking up?

В Linux и / dev / random, и / dev / urandom всегда используют один и тот же CSPRNG. Viktor Dahl 8 лет назад 1

Похожие вопросы