[PATCH 2/3] Use random.choice for generating LUKS backup passphrase
Vratislav Podzimek
vpodzime at redhat.com
Thu Mar 13 20:04:01 UTC 2014
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
blivet/devicelibs/crypto.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/blivet/devicelibs/crypto.py b/blivet/devicelibs/crypto.py
index 4ddb996..f69963a 100644
--- a/blivet/devicelibs/crypto.py
+++ b/blivet/devicelibs/crypto.py
@@ -20,7 +20,7 @@
# Martin Sivak <msivak at redhat.com>
#
-import os
+import random
from pycryptsetup import CryptSetup
from ..errors import *
@@ -38,9 +38,9 @@ GENERATED_PASSPHRASE_CHARSET = ("0123456789"
GENERATED_PASSPHRASE_LENGTH = 20
def generateBackupPassphrase():
- rnd = os.urandom(GENERATED_PASSPHRASE_LENGTH)
- cs = GENERATED_PASSPHRASE_CHARSET
- raw = "".join([cs[ord(c) % len(cs)] for c in rnd])
+ raw = ""
+ for i in xrange(GENERATED_PASSPHRASE_LENGTH):
+ raw += random.choice(GENERATED_PASSPHRASE_CHARSET)
# Make the result easier to read
parts = []
--
1.8.5.3
More information about the anaconda-patches
mailing list