【发布时间】:2009-12-08 18:34:41
【问题描述】:
在 Linux 中,/dev/urandom/ 的随机性如何?它被认为是安全的吗?
还有可能得到一个 1 的流吗?
【问题讨论】:
-
“它被认为是安全的吗?” 什么安全?答案完全取决于上下文。
在 Linux 中,/dev/urandom/ 的随机性如何?它被认为是安全的吗?
还有可能得到一个 1 的流吗?
【问题讨论】:
【讨论】:
/dev/urandom。
请查看man page:
Yarrow is a fairly resilient algorithm, and is believed to be resistant
to non-root. The quality of its output is however dependent on regular
addition of appropriate entropy. If the SecurityServer system daemon
fails for any reason, output quality will suffer over time without any
explicit indication from the random device itself.
Paranoid programmers can counteract this risk somewhat by collecting
entropy of their choice (e.g. from keystroke or mouse timings) and seed-
ing it into random directly before obtaining important random numbers.
【讨论】:
使用 /dev/urandom,它的加密安全。
好读:http://www.2uo.de/myths-about-urandom/
“如果您不确定应该使用 /dev/random 还是 /dev/urandom,那么您可能想使用后者。”
如果在早期启动有疑问,您是否收集了足够的熵。请改用系统调用getrandom()。 [1]
它两全其美,它会阻塞直到(仅一次!)收集到足够的熵,之后它将永远不会再次阻塞。
【讨论】: