"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/bundle/AfSplitter.py" between
revelation-0.5.3.tar.xz and revelation-0.5.4.tar.xz

About: Revelation is a password manager for the GNOME 3 desktop.

AfSplitter.py  (revelation-0.5.3.tar.xz):AfSplitter.py  (revelation-0.5.4.tar.xz)
skipping to change at line 58 skipping to change at line 58
def _diffuse(block, size, digest): def _diffuse(block, size, digest):
"""Internal function to diffuse information inside a buffer""" """Internal function to diffuse information inside a buffer"""
# Compute the number of full blocks, and the size of the leftover block # Compute the number of full blocks, and the size of the leftover block
digest_size = hashlib.new(digest).digest_size digest_size = hashlib.new(digest).digest_size
full_blocks = int(math.floor(float(len(block)) / float(digest_size))) full_blocks = int(math.floor(float(len(block)) / float(digest_size)))
padding = len(block) % digest_size padding = len(block) % digest_size
# hash the full blocks # hash the full blocks
ret = "" ret = b""
for i in range(0, full_blocks): for i in range(0, full_blocks):
hash = hashlib.new(digest) hash = hashlib.new(digest)
hash.update(struct.pack(">I", i)) hash.update(struct.pack(">I", i))
hash.update(block[i*digest_size:(i+1)*digest_size]) hash.update(block[i*digest_size:(i+1)*digest_size])
ret += hash.digest() ret += hash.digest()
# Hash the remaining data # Hash the remaining data
if padding > 0: if padding > 0:
hash = hashlib.new(digest) hash = hashlib.new(digest)
hash.update(struct.pack(">I", full_blocks)) hash.update(struct.pack(">I", full_blocks))
skipping to change at line 81 skipping to change at line 81
return ret return ret
def AFSplit(data, stripes, digesttype='sha1'): def AFSplit(data, stripes, digesttype='sha1'):
"""AF-Split data using digesttype. Returned data size will be len(data) * s tripes""" """AF-Split data using digesttype. Returned data size will be len(data) * s tripes"""
blockSize = len(data) blockSize = len(data)
rand = Random.new() rand = Random.new()
bufblock = "\x00" * blockSize bufblock = [0] * blockSize
ret = "" ret = b""
for i in range(0, stripes-1): for i in range(0, stripes-1):
# Get some random data # Get some random data
r = rand.read(blockSize) r = rand.read(blockSize)
ret += r ret += r
bufblock = _xor(r, bufblock) bufblock = _xor(r, bufblock)
bufblock = _diffuse(bufblock, blockSize, digesttype) bufblock = _diffuse(bufblock, blockSize, digesttype)
ret += _xor(bufblock, data) ret += _xor(bufblock, data)
return ret return ret
def AFMerge(data, stripes, digesttype='sha1'): def AFMerge(data, stripes, digesttype='sha1'):
"""AF-Merge data using digesttype. len(data) must be a multiple of stripes" "" """AF-Merge data using digesttype. len(data) must be a multiple of stripes" ""
if len(data) % stripes != 0: if len(data) % stripes != 0:
raise ValueError("ERROR: data is not a multiple of strips") raise ValueError("ERROR: data is not a multiple of strips")
blockSize = len(data) / stripes blockSize = len(data) // stripes
bufblock = "\x00" * blockSize bufblock = [0] * blockSize
for i in range(0, stripes - 1): for i in range(0, stripes - 1):
bufblock = _xor(data[i*blockSize:(i+1)*blockSize], bufblock) bufblock = _xor(data[i*blockSize:(i+1)*blockSize], bufblock)
bufblock = _diffuse(bufblock, blockSize, digesttype) bufblock = _diffuse(bufblock, blockSize, digesttype)
return _xor(data[(stripes-1)*blockSize:], bufblock) return _xor(data[(stripes-1)*blockSize:], bufblock)
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)