aboutsummaryrefslogtreecommitdiff
path: root/paramiko/rng_posix.py
diff options
context:
space:
mode:
authorJeremy T. Bouse <jbouse@debian.org>2009-11-27 16:25:55 -0500
committerJeremy T. Bouse <jbouse@debian.org>2009-11-27 16:25:55 -0500
commite299181a5dda25aed4879ebcbe1359604448b3ae (patch)
treef2d18804fcc3367ca9c5e977c1618679b5a5e363 /paramiko/rng_posix.py
parented280d5ac360e2af796e9bd973d7b4df89f0c449 (diff)
downloadpython-paramiko-e299181a5dda25aed4879ebcbe1359604448b3ae.tar
python-paramiko-e299181a5dda25aed4879ebcbe1359604448b3ae.tar.gz
Imported Upstream version 1.7.6upstream/1.7.6
Diffstat (limited to 'paramiko/rng_posix.py')
-rw-r--r--paramiko/rng_posix.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/paramiko/rng_posix.py b/paramiko/rng_posix.py
index 1e6d72c..c4c9691 100644
--- a/paramiko/rng_posix.py
+++ b/paramiko/rng_posix.py
@@ -43,7 +43,7 @@ def open_rng_device(device_path=None):
f = None
g = None
-
+
if device_path is None:
device_path = "/dev/urandom"
@@ -54,7 +54,7 @@ def open_rng_device(device_path=None):
f = open(device_path, "rb", 0)
except EnvironmentError:
raise error("Unable to open /dev/urandom")
-
+
# Open a second file descriptor for sanity checking later.
try:
g = open(device_path, "rb", 0)
@@ -65,17 +65,17 @@ def open_rng_device(device_path=None):
st = os.fstat(f.fileno()) # f
if stat.S_ISREG(st.st_mode) or not stat.S_ISCHR(st.st_mode):
raise error("/dev/urandom is not a character special device")
-
+
st = os.fstat(g.fileno()) # g
if stat.S_ISREG(st.st_mode) or not stat.S_ISCHR(st.st_mode):
raise error("/dev/urandom is not a character special device")
-
+
# Check that /dev/urandom always returns the number of bytes requested
x = f.read(20)
y = g.read(20)
if len(x) != 20 or len(y) != 20:
raise error("Error reading from /dev/urandom: input truncated")
-
+
# Check that different reads return different data
if x == y:
raise error("/dev/urandom is broken; returning identical data: %r == %r" % (x, y))