1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
--- src/bundle/AfSplitter.py.~1~ 2012-05-26 14:19:34.000000000 +0200
+++ src/bundle/AfSplitter.py 2017-07-15 10:10:57.817775246 +0200
@@ -42,7 +42,7 @@
# will need changed to use Crypto.Random (now in python-crypt git)
# see: http://lists.dlitz.net/pipermail/pycrypto/2008q3/000020.html
-from Crypto.Util.randpool import RandomPool
+from Crypto import Random
from Crypto.Cipher import XOR
def _xor(a, b):
@@ -81,7 +81,7 @@
blockSize = len(data)
- rand = RandomPool()
+ rand = Random.new()
bufblock = "\x00" * blockSize
@@ -89,12 +89,7 @@
for i in range(0, stripes-1):
# Get some random data
- rand.randomize()
- rand.stir()
- r = rand.get_bytes(blockSize)
- if rand.entropy < 0:
- print "Warning: RandomPool entropy dropped below 0"
-
+ r = rand.rand(blockSize)
ret += r
bufblock = _xor(r, bufblock)
bufblock = _diffuse(bufblock, blockSize, digesttype)
--- src/bundle/luks.py.~1~ 2012-05-26 14:19:34.000000000 +0200
+++ src/bundle/luks.py 2017-07-15 10:10:08.735052052 +0200
@@ -65,7 +65,7 @@
# will need changed to use Crypto.Random (now in python-crypt git)
# see: http://lists.dlitz.net/pipermail/pycrypto/2008q3/000020.html
-from Crypto.Util.randpool import RandomPool
+from Crypto import Random
from Crypto.Cipher import *
import PBKDFv2, AfSplitter
@@ -178,13 +178,13 @@
self.keyBytes = masterSize
self.hashSpec = hashSpec
- rand = RandomPool(self.SALT_SIZE + 16 + masterSize)
+ rand = Random.new()
# Generate the salt
- self.mkDigestSalt = rand.get_bytes(self.SALT_SIZE)
+ self.mkDigestSalt = rand.read(self.SALT_SIZE)
# Generate a random master key
- self.masterKey = rand.get_bytes(self.keyBytes)
+ self.masterKey = rand.read(self.keyBytes)
self.ivGen.set_key(self.masterKey)
# generate the master key digest
@@ -263,8 +263,8 @@
key.passwordIterations = iterations
# Generate a random salt for this key
- rand = RandomPool(self.SALT_SIZE)
- key.passwordSalt = rand.get_bytes(self.SALT_SIZE)
+ rand = Random.new()
+ key.passwordSalt = rand.read(self.SALT_SIZE)
# Hash the key using PBKDFv2
pbkdf = PBKDFv2.PBKDFv2()
|