我如何耗尽/ dev/urandom进行测试?

Tom*_*Tom 3 linux security random ubuntu entropy

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

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

我希望能够进行回归测试以验证我的修复.我正在使用Ubuntu 12.04.

Bas*_*tch 8

根据随机(4)手册页,

read from the /dev/urandom device will not block
Run Code Online (Sandbox Code Playgroud)

如果你想阻止它,你应该从/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.
Run Code Online (Sandbox Code Playgroud)

我相信你应该/dev/random通过阻止使用哪些确实可以用尽.但是你不应该从它读取超过256位.