Advertisement
Guest User

Untitled

a guest
Sep 1st, 2018
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.59 KB | None | 0 0
  1. diff -Naur revelation.orig/src/bundle/AfSplitter.py revelation/src/bundle/AfSplitter.py
  2. --- revelation.orig/src/bundle/AfSplitter.py 2018-09-01 12:38:17.702662965 +0200
  3. +++ revelation/src/bundle/AfSplitter.py 2018-09-01 12:30:00.584871451 +0200
  4. @@ -42,14 +42,8 @@
  5.  
  6. # will need changed to use Crypto.Random (now in python-crypt git)
  7. # see: http://lists.dlitz.net/pipermail/pycrypto/2008q3/000020.html
  8. -from Crypto.Util.randpool import RandomPool
  9. -from Crypto.Cipher import XOR
  10. -
  11. -def _xor(a, b):
  12. - """Internal function to performs XOR on two strings a and b"""
  13. -
  14. - xor = XOR.new(a)
  15. - return xor.encrypt(b)
  16. +from Crypto.Random import get_random_bytes
  17. +from Crypto.Util.strxor import strxor
  18.  
  19. def _diffuse(block, size, digest):
  20. """Internal function to diffuse information inside a buffer"""
  21. @@ -81,26 +75,19 @@
  22.  
  23. blockSize = len(data)
  24.  
  25. - rand = RandomPool()
  26. -
  27. bufblock = "\x00" * blockSize
  28.  
  29. ret = ""
  30. for i in range(0, stripes-1):
  31.  
  32. # Get some random data
  33. - rand.randomize()
  34. - rand.stir()
  35. - r = rand.get_bytes(blockSize)
  36. - if rand.entropy < 0:
  37. - print "Warning: RandomPool entropy dropped below 0"
  38. + r = get_random_bytes(blockSize)
  39.  
  40. ret += r
  41. - bufblock = _xor(r, bufblock)
  42. + bufblock = strxor(r, bufblock)
  43. bufblock = _diffuse(bufblock, blockSize, digesttype)
  44. - rand.add_event(bufblock)
  45.  
  46. - ret += _xor(bufblock, data)
  47. + ret += strxor(bufblock, data)
  48. return ret
  49.  
  50. def AFMerge(data, stripes, digesttype='sha1'):
  51. @@ -113,7 +100,7 @@
  52.  
  53. bufblock = "\x00" * blockSize
  54. for i in range(0, stripes - 1):
  55. - bufblock = _xor(data[i*blockSize:(i+1)*blockSize], bufblock)
  56. + bufblock = strxor(data[i*blockSize:(i+1)*blockSize], bufblock)
  57. bufblock = _diffuse(bufblock, blockSize, digesttype)
  58.  
  59. - return _xor(data[(stripes-1)*blockSize:], bufblock)
  60. + return strxor(data[(stripes-1)*blockSize:], bufblock)
  61. diff -Naur revelation.orig/src/bundle/luks.py revelation/src/bundle/luks.py
  62. --- revelation.orig/src/bundle/luks.py 2018-09-01 12:38:17.702662965 +0200
  63. +++ revelation/src/bundle/luks.py 2018-09-01 12:47:42.047084845 +0200
  64. @@ -65,7 +65,7 @@
  65.  
  66. # will need changed to use Crypto.Random (now in python-crypt git)
  67. # see: http://lists.dlitz.net/pipermail/pycrypto/2008q3/000020.html
  68. -from Crypto.Util.randpool import RandomPool
  69. +from Crypto.Random import get_random_bytes
  70. from Crypto.Cipher import *
  71. import PBKDFv2, AfSplitter
  72.  
  73. @@ -178,13 +178,11 @@
  74. self.keyBytes = masterSize
  75. self.hashSpec = hashSpec
  76.  
  77. - rand = RandomPool(self.SALT_SIZE + 16 + masterSize)
  78. -
  79. # Generate the salt
  80. - self.mkDigestSalt = rand.get_bytes(self.SALT_SIZE)
  81. + self.mkDigestSalt = get_random_bytes(self.SALT_SIZE)
  82.  
  83. # Generate a random master key
  84. - self.masterKey = rand.get_bytes(self.keyBytes)
  85. + self.masterKey = get_random_bytes(self.keyBytes)
  86. self.ivGen.set_key(self.masterKey)
  87.  
  88. # generate the master key digest
  89. @@ -210,7 +208,7 @@
  90. self.payloadOffset = currentSector
  91.  
  92. # Generate a UUID for this file
  93. - self._uuidgen(rand)
  94. + self._uuidgen()
  95.  
  96. # Create a new file, and save the header into it
  97. self.file = file
  98. @@ -263,8 +261,7 @@
  99. key.passwordIterations = iterations
  100.  
  101. # Generate a random salt for this key
  102. - rand = RandomPool(self.SALT_SIZE)
  103. - key.passwordSalt = rand.get_bytes(self.SALT_SIZE)
  104. + key.passwordSalt = get_random_bytes(self.SALT_SIZE)
  105.  
  106. # Hash the key using PBKDFv2
  107. pbkdf = PBKDFv2.PBKDFv2()
  108. @@ -594,13 +591,13 @@
  109. self.cipherName = cipherName
  110. self.cipherMode = cipherMode
  111.  
  112. - def _uuidgen(self, rand):
  113. + def _uuidgen(self):
  114. """Internal function to generate a UUID"""
  115.  
  116. # I copied this code (and slightly modified it) from a module written
  117. # by Denys Duchier http://ofxsuite.berlios.de/uuid.py (which is under the GPL)
  118.  
  119. - buf = rand.get_bytes(16)
  120. + buf = get_random_bytes(16)
  121. low,mid,hi_and_version,seq,node = struct.unpack(">IHHH6s",buf)
  122. seq = (seq & 0x3FFF) | 0x8000
  123. hi_and_version = (hi_and_version & 0x0FFF) | 0x4000
  124. diff -Naur revelation.orig/src/bundle/PBKDFv2.py revelation/src/bundle/PBKDFv2.py
  125. --- revelation.orig/src/bundle/PBKDFv2.py 2018-09-01 12:38:17.702662965 +0200
  126. +++ revelation/src/bundle/PBKDFv2.py 2018-09-01 12:35:22.345594877 +0200
  127. @@ -32,7 +32,7 @@
  128. """
  129.  
  130. import struct, string, math, hashlib, hmac # RFC2104
  131. -from Crypto.Cipher import XOR
  132. +from Crypto.Util.strxor import strxor
  133.  
  134. ################ PBKDFv2
  135. class PBKDFv2:
  136. @@ -145,5 +145,4 @@
  137. if len(a) != len(b):
  138. raise ValueError("ERROR: Strings are of different size! %s %s" % (len(a), len(b)))
  139.  
  140. - xor = XOR.new(a)
  141. - return xor.encrypt(b)
  142. + return strxor(a, b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement