summaryrefslogtreecommitdiff
path: root/obnamlib/encryption.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-03-27 11:44:15 +0100
committerLars Wirzenius <liw@liw.fi>2011-03-27 11:44:15 +0100
commit5e0d40f23d5642456524a419bc024806717b8fdf (patch)
tree564bdfdd9b57eed8dc678ce9384133d1d0098403 /obnamlib/encryption.py
parentb742bd1a3f2a82e6b93f9802d948720fe7926743 (diff)
downloadobnam-5e0d40f23d5642456524a419bc024806717b8fdf.tar.gz
Fix tests to not read from /dev/random.
It depletes entropy for no purpose, and makes tests run slower.
Diffstat (limited to 'obnamlib/encryption.py')
-rw-r--r--obnamlib/encryption.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/obnamlib/encryption.py b/obnamlib/encryption.py
index 4ec718d7..6de56013 100644
--- a/obnamlib/encryption.py
+++ b/obnamlib/encryption.py
@@ -19,11 +19,11 @@ import subprocess
import tempfile
-def generate_symmetric_key(numbits):
+def generate_symmetric_key(numbits, filename='/dev/random'):
'''Generate a random key of at least numbits for symmetric encryption.'''
bytes = (numbits + 7) / 8
- f = open('/dev/random', 'rb')
+ f = open(filename, 'rb')
key = f.read(bytes)
f.close()