summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--paramiko/osrandom.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/paramiko/osrandom.py b/paramiko/osrandom.py
index 447d090e..6c559e02 100644
--- a/paramiko/osrandom.py
+++ b/paramiko/osrandom.py
@@ -37,6 +37,13 @@ try:
except ImportError:
winrandom = None
+# Lastly, try to get the plain "RandomPool"
+# (sometimes windows doesn't even have winrandom!)
+try:
+ from Crypto.Util.randpool import RandomPool
+except ImportError:
+ RandomPool = None
+
##
## Define RandomPool classes
@@ -88,6 +95,15 @@ class DevUrandomPool(BaseOSRandomPool):
return bytes
+class FallbackRandomPool (BaseOSRandomPool):
+ def __init__(self):
+ self._wr = RandomPool()
+ self.randomize()
+
+ def get_bytes(self, n):
+ return self._wr.get_bytes(n)
+
+
##
## Detect default random number source
##
@@ -103,6 +119,11 @@ if osrandom_source is None and winrandom is not None:
osrandom_source = "winrandom"
DefaultRandomPoolClass = WinRandomPool
+# Try final fallback
+if osrandom_source is None and RandomPool is not None:
+ osrandom_source = "randompool"
+ DefaultRandomPoolClass = FallbackRandomPool
+
# Give up
if osrandom_source is None:
raise ImportError("Cannot find OS entropy source")