[pycrypto] Run test suite with /dev/random

Sebastian Ramacher sebastian+lists at ramacher.at
Fri Jan 20 10:20:57 CST 2012


On 01/13/2012 07:59 PM, Sebastian Ramacher wrote:
> Thank you for the explanation. This was a misunderstanding on my side. I'll talk
> with the Hurd Developers then.

Apparently this is a known issue with Hurd's urandom implementation.

Nevertheless there is still an issue in pycrypto left. The assumption that read
always returns the amount of data requested if there is enough available is not
true. If the process is interrupted by a signal read will return less. At least
that's the case for Python3.

The following example illustrates that:

% cat signal.py
from Crypto.Random import OSRNG
r = OSRNG.new()

S = 1024**3
while True:
  r.read(S)

% python3 signal.py & ; PID=$! ; sleep 2 ; kill -STOP $PID ; sleep 10 ; kill
-CONT $PID ; sleep 1 ; kill -KILL $PID
[2] 25862
[2]  + 25862 suspended (signal)  python3 signal.py
Traceback (most recent call last):
  File "signal.py", line 6, in <module>
    r.read(S)
  File "/usr/lib/python3/dist-packages/Crypto/Random/OSRNG/rng_base.py", line
78, in read
    raise AssertionError("%s produced truncated output (requested %d, got %d)" %
(self.name, N, len(data)))
AssertionError: /dev/urandom produced truncated output (requested 1073741824,
got 20447500)
kill: kill 25862 failed: no such process


I've attached a patch that fixes this issue.

Kind regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: posixread.diff
Type: text/x-diff
Size: 542 bytes
Desc: not available
Url : http://lists.dlitz.net/pipermail/pycrypto/attachments/20120120/7b674eb6/attachment.diff 


More information about the pycrypto mailing list