summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Crypto/Protocol/AllOrNothing.py8
-rw-r--r--lib/Crypto/Random/random.py2
-rw-r--r--python-3-changes.txt6
3 files changed, 7 insertions, 9 deletions
diff --git a/lib/Crypto/Protocol/AllOrNothing.py b/lib/Crypto/Protocol/AllOrNothing.py
index f2d70bc..4ece960 100644
--- a/lib/Crypto/Protocol/AllOrNothing.py
+++ b/lib/Crypto/Protocol/AllOrNothing.py
@@ -190,13 +190,14 @@ class AllOrNothing:
# encrypted, and create the hash cipher.
K0 = self.__K0digit * self.__key_size
hcipher = self.__newcipher(K0)
+ block_size = self.__ciphermodule.block_size
# Since we have all the blocks (or this method would have been called
- # prematurely), we can calcualte all the hash blocks.
+ # prematurely), we can calculate all the hash blocks.
hashes = []
for i in range(1, len(blocks)):
mticki = blocks[i-1] ^ i
- hi = hcipher.encrypt(long_to_bytes(mticki))
+ hi = hcipher.encrypt(long_to_bytes(mticki, block_size))
hashes.append(bytes_to_long(hi))
# now we can calculate K' (key). remember the last block contains
@@ -204,8 +205,7 @@ class AllOrNothing:
key = blocks[-1] ^ reduce(operator.xor, hashes)
# and now we can create the cipher object
- mcipher = self.__newcipher(long_to_bytes(key))
- block_size = self.__ciphermodule.block_size
+ mcipher = self.__newcipher(long_to_bytes(key, self.__key_size))
# And we can now decode the original message blocks
parts = []
diff --git a/lib/Crypto/Random/random.py b/lib/Crypto/Random/random.py
index 9d969f2..bef02e6 100644
--- a/lib/Crypto/Random/random.py
+++ b/lib/Crypto/Random/random.py
@@ -122,7 +122,7 @@ class StrongRandom(object):
selected = {} # we emulate a set using a dict here
for i in xrange(k):
r = None
- while r is None or r in selected:
+ while r is None or selected.has_key(r):
r = self.randrange(num_choices)
retval.append(population[r])
selected[r] = 1
diff --git a/python-3-changes.txt b/python-3-changes.txt
index ea2c04c..ca6f5a6 100644
--- a/python-3-changes.txt
+++ b/python-3-changes.txt
@@ -58,12 +58,10 @@ Use instead assertEqual(expr,True) for assert_ and assertEqual(expr,False) for
failIf
Added unit tests for Crypto.Random.random. Fixed random.shuffle().
-Not changed: random.sample() fails on Python 2.1. This is now exposed through
- the unit test.
+random.sample() changed to no longer fail on Python 2.1.
Added unit test for Crypto.Protocol.AllOrNothing.
-Not changed: AllOrNothing fails when called a few times (<10, usually). This
- is now exposed through the unit test.
+AllOrNothing changed to no longer fail occasionally.
C code: