From 8766da37a2612ebcea13c7451a2157d175f29a41 Mon Sep 17 00:00:00 2001 From: Legrandin Date: Sun, 4 Aug 2013 22:46:06 +0200 Subject: whitespace changes (pre-AEAD) [dlitz@dlitz.net: Whitespace changes extracted from the author's pull request:] - [9c13f9c] Rename 'IV' parameter to 'nonce' for AEAD modes. - [4ec64d8] Removed last references to ApiUsageError - [ee46922] Removed most 'import *' statements --- lib/Crypto/Cipher/ARC2.py | 4 ++-- lib/Crypto/Cipher/Blowfish.py | 2 +- lib/Crypto/Cipher/CAST.py | 2 +- lib/Crypto/Cipher/DES.py | 2 +- lib/Crypto/Cipher/DES3.py | 2 +- lib/Crypto/Cipher/blockalgo.py | 13 +++++++------ lib/Crypto/SelfTest/Protocol/test_KDF.py | 4 ++-- lib/Crypto/SelfTest/PublicKey/test_ElGamal.py | 2 +- lib/Crypto/SelfTest/Signature/test_pkcs1_pss.py | 2 +- lib/Crypto/SelfTest/Util/test_asn1.py | 20 ++++++++++---------- lib/Crypto/__init__.py | 2 +- 11 files changed, 28 insertions(+), 27 deletions(-) (limited to 'lib') diff --git a/lib/Crypto/Cipher/ARC2.py b/lib/Crypto/Cipher/ARC2.py index ddcca47..1b62be1 100644 --- a/lib/Crypto/Cipher/ARC2.py +++ b/lib/Crypto/Cipher/ARC2.py @@ -32,7 +32,7 @@ The company eventually published its full specification in RFC2268_. RC2 has a fixed data block size of 8 bytes. Length of its keys can vary from 8 to 128 bits. One particular property of RC2 is that the actual -cryptographic strength of the key (*effective key length*) can be reduced +cryptographic strength of the key (*effective key length*) can be reduced via a parameter. Even though RC2 is not cryptographically broken, it has not been analyzed as @@ -66,7 +66,7 @@ class RC2Cipher (blockalgo.BlockAlgo): def __init__(self, key, *args, **kwargs): """Initialize an ARC2 cipher object - + See also `new()` at the module level.""" blockalgo.BlockAlgo.__init__(self, _ARC2, key, *args, **kwargs) diff --git a/lib/Crypto/Cipher/Blowfish.py b/lib/Crypto/Cipher/Blowfish.py index 2ce78e9..5c3128d 100644 --- a/lib/Crypto/Cipher/Blowfish.py +++ b/lib/Crypto/Cipher/Blowfish.py @@ -60,7 +60,7 @@ class BlowfishCipher (blockalgo.BlockAlgo): def __init__(self, key, *args, **kwargs): """Initialize a Blowfish cipher object - + See also `new()` at the module level.""" blockalgo.BlockAlgo.__init__(self, _Blowfish, key, *args, **kwargs) diff --git a/lib/Crypto/Cipher/CAST.py b/lib/Crypto/Cipher/CAST.py index 5f009a7..88f8cac 100644 --- a/lib/Crypto/Cipher/CAST.py +++ b/lib/Crypto/Cipher/CAST.py @@ -63,7 +63,7 @@ class CAST128Cipher(blockalgo.BlockAlgo): def __init__(self, key, *args, **kwargs): """Initialize a CAST-128 cipher object - + See also `new()` at the module level.""" blockalgo.BlockAlgo.__init__(self, _CAST, key, *args, **kwargs) diff --git a/lib/Crypto/Cipher/DES.py b/lib/Crypto/Cipher/DES.py index 1062d23..2ae63bc 100644 --- a/lib/Crypto/Cipher/DES.py +++ b/lib/Crypto/Cipher/DES.py @@ -58,7 +58,7 @@ class DESCipher(blockalgo.BlockAlgo): def __init__(self, key, *args, **kwargs): """Initialize a DES cipher object - + See also `new()` at the module level.""" blockalgo.BlockAlgo.__init__(self, _DES, key, *args, **kwargs) diff --git a/lib/Crypto/Cipher/DES3.py b/lib/Crypto/Cipher/DES3.py index 0265c0c..7d20e5f 100644 --- a/lib/Crypto/Cipher/DES3.py +++ b/lib/Crypto/Cipher/DES3.py @@ -71,7 +71,7 @@ class DES3Cipher(blockalgo.BlockAlgo): def __init__(self, key, *args, **kwargs): """Initialize a TDES cipher object - + See also `new()` at the module level.""" blockalgo.BlockAlgo.__init__(self, _DES3, key, *args, **kwargs) diff --git a/lib/Crypto/Cipher/blockalgo.py b/lib/Crypto/Cipher/blockalgo.py index 218a367..89410f5 100644 --- a/lib/Crypto/Cipher/blockalgo.py +++ b/lib/Crypto/Cipher/blockalgo.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Cipher/blockalgo.py +# Cipher/blockalgo.py # # =================================================================== # The contents of this file are dedicated to the public domain. To @@ -100,7 +100,7 @@ MODE_OFB = 5 #: to the *IV* for the other modes) and increment its lowest **m** bits by #: one (modulo *2^m*) for each block. In most cases, **m** is chosen to be half #: the block size. -#: +#: #: Reusing the same *initial counter block* for encryptions done with the same #: key lead to catastrophic cryptograhic failures. #: @@ -201,7 +201,7 @@ class BlockAlgo: or decrypting other data with the same key. This function does not add any padding to the plaintext. - + - For `MODE_ECB` and `MODE_CBC`, *plaintext* length (in bytes) must be a multiple of *block_size*. @@ -245,11 +245,12 @@ class BlockAlgo: def decrypt(self, ciphertext): """Decrypt data with the key and the parameters set at initialization. - + The cipher object is stateful; decryption of a long block of data can be broken up in two or more calls to `decrypt()`. + That is, the statement: - + >>> c.decrypt(a) + c.decrypt(b) is always equivalent to: @@ -260,7 +261,7 @@ class BlockAlgo: or decrypting other data with the same key. This function does not remove any padding from the plaintext. - + - For `MODE_ECB` and `MODE_CBC`, *ciphertext* length (in bytes) must be a multiple of *block_size*. diff --git a/lib/Crypto/SelfTest/Protocol/test_KDF.py b/lib/Crypto/SelfTest/Protocol/test_KDF.py index f0a44d1..741c4ce 100644 --- a/lib/Crypto/SelfTest/Protocol/test_KDF.py +++ b/lib/Crypto/SelfTest/Protocol/test_KDF.py @@ -45,7 +45,7 @@ class PBKDF1_Tests(unittest.TestCase): # From http://www.di-mgt.com.au/cryptoKDFs.html#examplespbkdf ("password","78578E5A5D63CB06",16,1000,"DC19847E05C64D2FAF10EBFB4A3D2A20"), ) - + def test1(self): v = self._testData[0] res = PBKDF1(v[0], t2b(v[1]), v[2], v[3], SHA1) @@ -71,7 +71,7 @@ class PBKDF2_Tests(unittest.TestCase): 25, 4096, "3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038"), ( 'pass\x00word',"7361006c74",16,4096, "56fa6aa75548099dcc37d7f03425e0c3"), ) - + def test1(self): # Test only for HMAC-SHA1 as PRF diff --git a/lib/Crypto/SelfTest/PublicKey/test_ElGamal.py b/lib/Crypto/SelfTest/PublicKey/test_ElGamal.py index cdee8cf..0c76792 100644 --- a/lib/Crypto/SelfTest/PublicKey/test_ElGamal.py +++ b/lib/Crypto/SelfTest/PublicKey/test_ElGamal.py @@ -151,7 +151,7 @@ class ElGamalTest(unittest.TestCase): tv2['key'] += [tv2[c]] del tv2[c] return tv2 - + def _test_random_key(self, bits): elgObj = ElGamal.generate(bits, Random.new().read) self._check_private_key(elgObj) diff --git a/lib/Crypto/SelfTest/Signature/test_pkcs1_pss.py b/lib/Crypto/SelfTest/Signature/test_pkcs1_pss.py index 314d2b8..d8ddda3 100644 --- a/lib/Crypto/SelfTest/Signature/test_pkcs1_pss.py +++ b/lib/Crypto/SelfTest/Signature/test_pkcs1_pss.py @@ -385,7 +385,7 @@ class PKCS1_PSS_Tests(unittest.TestCase): rng = Random.new().read key = MyKey(RSA.generate(1024,rng)) - + # Helper function to monitor what's request from MGF global mgfcalls def newMGF(seed,maskLen): diff --git a/lib/Crypto/SelfTest/Util/test_asn1.py b/lib/Crypto/SelfTest/Util/test_asn1.py index 58d12b4..0986c70 100644 --- a/lib/Crypto/SelfTest/Util/test_asn1.py +++ b/lib/Crypto/SelfTest/Util/test_asn1.py @@ -63,12 +63,12 @@ class DerObjectTests(unittest.TestCase): # Initialize with payload der = DerObject(0x03, b('\x12\x12')) self.assertEquals(der.encode(), b('\x03\x02\x12\x12')) - + def testObjEncode3(self): # Long payload der = DerObject(b('\x10')) der.payload = b("0")*128 - self.assertEquals(der.encode(), b('\x10\x81\x80' + "0"*128)) + self.assertEquals(der.encode(), b('\x10\x81\x80' + "0"*128)) def testObjEncode4(self): # Implicit tags (constructed) @@ -79,7 +79,7 @@ class DerObjectTests(unittest.TestCase): der = DerObject(0x02, implicit=0x1E, constructed=False) der.payload = b('ppll') self.assertEquals(der.encode(), b('\x9E\x04ppll')) - + # ----- def testObjDecode1(self): @@ -185,7 +185,7 @@ class DerIntegerTests(unittest.TestCase): # Value -128 der = DerInteger(-128) self.assertEquals(der.encode(), b('\x02\x01\x80')) - # Value + # Value der = DerInteger(-87873) self.assertEquals(der.encode(), b('\x02\x03\xFE\xA8\xBF')) @@ -260,7 +260,7 @@ class DerIntegerTests(unittest.TestCase): # Wide length field der = DerInteger() self.assertRaises(ValueError, der.decode, b('\x02\x81\x01\x01')) - + class DerSequenceTests(unittest.TestCase): def testInit1(self): @@ -296,13 +296,13 @@ class DerSequenceTests(unittest.TestCase): self.assertEquals(len(der),1) self.assertEquals(der[0],1) self.assertEquals(der.encode(), b('0\x03\x02\x01\x01')) - + def testEncode3(self): # One multi-byte integer (non-zero) der = DerSequence() der.append(0x180L) self.assertEquals(der.encode(), b('0\x04\x02\x02\x01\x80')) - + def testEncode4(self): # One very long integer der = DerSequence() @@ -389,7 +389,7 @@ class DerSequenceTests(unittest.TestCase): der.decode(b('0\x03\x02\x01\x7f')) self.assertEquals(len(der),1) self.assertEquals(der[0],127) - + def testDecode4(self): # One very long integer der = DerSequence() @@ -495,7 +495,7 @@ class DerOctetStringTests(unittest.TestCase): # No leftovers allowed der = DerOctetString() self.assertRaises(ValueError, der.decode, b('\x04\x01\x01\xff')) - + class DerNullTests(unittest.TestCase): def testEncode1(self): @@ -632,7 +632,7 @@ class DerSetOfTests(unittest.TestCase): der = DerSetOf() self.assertRaises(ValueError, der.decode, b('1\x08\x02\x02\x01\x80\x02\x02\x00\xff\xAA')) - + def get_tests(config={}): from Crypto.SelfTest.st_common import list_test_cases listTests = [] diff --git a/lib/Crypto/__init__.py b/lib/Crypto/__init__.py index db238d7..04f30c8 100644 --- a/lib/Crypto/__init__.py +++ b/lib/Crypto/__init__.py @@ -35,7 +35,7 @@ Crypto.Protocol Crypto.PublicKey Public-key encryption and signature algorithms (RSA, DSA) Crypto.Signature - Public-key signature algorithms (RSA PKCS#1) + Public-key signature algorithms (RSA PKCS#1) Crypto.Util Various useful modules and functions (long-to-string conversion, random number generation, number theoretic functions) -- cgit v1.2.1