summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLegrandin <gooksankoo@hoiptorrow.mailexpire.com>2012-05-11 22:57:49 +0200
committerLegrandin <gooksankoo@hoiptorrow.mailexpire.com>2012-05-11 22:57:49 +0200
commit4ce6b8d7f1c070687f0144736dd9a14b4b603b7d (patch)
tree7634a0ee9614ea1be3807c9e3e593c52984a1db6
parent5faa23c67a2943b007b3c640c73a88c6a6bb9b6f (diff)
downloadpycrypto-4ce6b8d7f1c070687f0144736dd9a14b4b603b7d.tar.gz
Fixes to make test suite pass for Python 2.1 and Python 3
-rw-r--r--lib/Crypto/Cipher/AES.py2
-rw-r--r--lib/Crypto/Cipher/DES3.py2
-rw-r--r--lib/Crypto/Protocol/AllOrNothing.py10
-rw-r--r--lib/Crypto/SelfTest/PublicKey/test_ElGamal.py4
4 files changed, 12 insertions, 6 deletions
diff --git a/lib/Crypto/Cipher/AES.py b/lib/Crypto/Cipher/AES.py
index 83ae7c5..6b31686 100644
--- a/lib/Crypto/Cipher/AES.py
+++ b/lib/Crypto/Cipher/AES.py
@@ -92,5 +92,5 @@ MODE_CTR = 6
#: Size of a data block (in bytes)
block_size = 16
#: Size of a key (in bytes)
-key_size = { 16, 24, 32 }
+key_size = ( 16, 24, 32 )
diff --git a/lib/Crypto/Cipher/DES3.py b/lib/Crypto/Cipher/DES3.py
index fcbe2b8..5015152 100644
--- a/lib/Crypto/Cipher/DES3.py
+++ b/lib/Crypto/Cipher/DES3.py
@@ -108,4 +108,4 @@ MODE_CTR = 6
#: Size of a data block (in bytes)
block_size = 8
#: Size of a key (in bytes)
-key_size = { 16, 24 }
+key_size = ( 16, 24 )
diff --git a/lib/Crypto/Protocol/AllOrNothing.py b/lib/Crypto/Protocol/AllOrNothing.py
index 4ece960..acc92d5 100644
--- a/lib/Crypto/Protocol/AllOrNothing.py
+++ b/lib/Crypto/Protocol/AllOrNothing.py
@@ -49,7 +49,13 @@ import sys
from Crypto.Util.number import bytes_to_long, long_to_bytes
from Crypto.Util.py3compat import *
-
+def isInt(x):
+ test = 0
+ try:
+ test += x
+ except TypeError:
+ return 0
+ return 1
class AllOrNothing:
"""Class implementing the All-or-Nothing package transform.
@@ -81,7 +87,7 @@ class AllOrNothing:
self.__mode = mode
self.__IV = IV
self.__key_size = ciphermodule.key_size
- if self.__key_size == 0:
+ if not isInt(self.__key_size) or self.__key_size==0:
self.__key_size = 16
__K0digit = bchr(0x69)
diff --git a/lib/Crypto/SelfTest/PublicKey/test_ElGamal.py b/lib/Crypto/SelfTest/PublicKey/test_ElGamal.py
index d199fee..cdee8cf 100644
--- a/lib/Crypto/SelfTest/PublicKey/test_ElGamal.py
+++ b/lib/Crypto/SelfTest/PublicKey/test_ElGamal.py
@@ -132,10 +132,10 @@ class ElGamalTest(unittest.TestCase):
key = ElGamal.construct(d['key'])
# Positive test
res = key.verify( d['h'], (d['sig1'],d['sig2']) )
- self.assertTrue(res)
+ self.failUnless(res)
# Negative test
res = key.verify( d['h'], (d['sig1']+1,d['sig2']) )
- self.assertFalse(res)
+ self.failIf(res)
def convert_tv(self, tv, as_longs=0):
"""Convert a test vector from textual form (hexadecimal ascii