【问题标题】:How can I exhaust /dev/urandom for testing?如何用尽 /dev/urandom 进行测试?
【发布时间】:2012-10-22 17:59:56
【问题描述】:

我最近遇到了一个错误,当我的 linux 服务器上的熵太低并且读取 /dev/urandom 返回的字节数少于预期的字节数时,我没有正确处理。

如何通过测试重新创建它?有没有办法降低系统的熵或可靠地清空 /dev/urandom?

我希望能够进行回归测试来验证我的修复。我使用的是 Ubuntu 12.04。

【问题讨论】:

  • 你可以通过反复阅读urandom来耗尽熵。您可以在/proc/sys/kernel/random/ 中阅读当前的熵级别

标签: linux security ubuntu random entropy


【解决方案1】:

根据random(4)手册页,

read from the /dev/urandom device will not block

如果你想阻止它,你应该从/dev/random(没有任何u)读取很多字节。 (有多少取决于硬件和系统)。

所以你不能“exaust”/dev/urandom,因为

 A read from the /dev/urandom device will not block waiting for 
 more entropy. As a result, if there is not sufficient entropy in 
 the entropy pool, the returned values are theoretically vulnerable 
 to a cryptographic attack on the algorithms used by the driver.

我相信你应该使用/dev/random,它确实可以通过阻塞来耗尽。 但你不应该从中读取超过 256 位。

【讨论】:

    猜你喜欢
    • 2014-11-21
    • 1970-01-01
    • 2010-11-18
    • 2011-10-19
    • 2017-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多