You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
297 lines
9.3 KiB
297 lines
9.3 KiB
--- lib/Crypto/Cipher/blockalgo.py
|
|
+++ lib/Crypto/Cipher/blockalgo.py
|
|
@@ -22,8 +22,6 @@
|
|
"""Module with definitions common to all block ciphers."""
|
|
|
|
import sys
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
from Crypto.Util.py3compat import *
|
|
|
|
#: *Electronic Code Book (ECB)*.
|
|
--- lib/Crypto/PublicKey/DSA.py
|
|
+++ lib/Crypto/PublicKey/DSA.py
|
|
@@ -82,8 +82,6 @@ __revision__ = "$Id$"
|
|
__all__ = ['generate', 'construct', 'error', 'DSAImplementation', '_DSAobj']
|
|
|
|
import sys
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
|
|
from Crypto.PublicKey import _DSA, _slowmath, pubkey
|
|
from Crypto import Random
|
|
--- lib/Crypto/PublicKey/RSA.py
|
|
+++ lib/Crypto/PublicKey/RSA.py
|
|
@@ -68,8 +68,6 @@ __revision__ = "$Id$"
|
|
__all__ = ['generate', 'construct', 'error', 'importKey', 'RSAImplementation', '_RSAobj']
|
|
|
|
import sys
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
from Crypto.Util.py3compat import *
|
|
#from Crypto.Util.python_compat import *
|
|
from Crypto.Util.number import getRandomRange, bytes_to_long, long_to_bytes
|
|
--- lib/Crypto/PublicKey/_slowmath.py
|
|
+++ lib/Crypto/PublicKey/_slowmath.py
|
|
@@ -30,8 +30,6 @@ __all__ = ['rsa_construct']
|
|
|
|
import sys
|
|
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
from Crypto.Util.number import size, inverse, GCD
|
|
|
|
class error(Exception):
|
|
--- lib/Crypto/Random/Fortuna/FortunaAccumulator.py
|
|
+++ lib/Crypto/Random/Fortuna/FortunaAccumulator.py
|
|
@@ -25,8 +25,6 @@
|
|
__revision__ = "$Id$"
|
|
|
|
import sys
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
from Crypto.Util.py3compat import *
|
|
|
|
from binascii import b2a_hex
|
|
--- lib/Crypto/Random/Fortuna/FortunaGenerator.py
|
|
+++ lib/Crypto/Random/Fortuna/FortunaGenerator.py
|
|
@@ -25,8 +25,6 @@
|
|
__revision__ = "$Id$"
|
|
|
|
import sys
|
|
-if sys.version_info[0] is 2 and sys.version_info[1] is 1:
|
|
- from Crypto.Util.py21compat import *
|
|
from Crypto.Util.py3compat import *
|
|
|
|
import struct
|
|
--- lib/Crypto/Random/Fortuna/SHAd256.py
|
|
+++ lib/Crypto/Random/Fortuna/SHAd256.py
|
|
@@ -32,8 +32,6 @@ __revision__ = "$Id$"
|
|
__all__ = ['new', 'digest_size']
|
|
|
|
import sys
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
from Crypto.Util.py3compat import *
|
|
|
|
from binascii import b2a_hex
|
|
--- lib/Crypto/Random/random.py
|
|
+++ lib/Crypto/Random/random.py
|
|
@@ -29,8 +29,6 @@ __all__ = ['StrongRandom', 'getrandbits'
|
|
|
|
from Crypto import Random
|
|
import sys
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
|
|
class StrongRandom(object):
|
|
def __init__(self, rng=None, randfunc=None):
|
|
--- lib/Crypto/SelfTest/PublicKey/test_DSA.py
|
|
+++ lib/Crypto/SelfTest/PublicKey/test_DSA.py
|
|
@@ -28,8 +28,6 @@ __revision__ = "$Id$"
|
|
|
|
import sys
|
|
import os
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
from Crypto.Util.py3compat import *
|
|
|
|
import unittest
|
|
--- lib/Crypto/SelfTest/PublicKey/test_RSA.py
|
|
+++ lib/Crypto/SelfTest/PublicKey/test_RSA.py
|
|
@@ -28,8 +28,6 @@ __revision__ = "$Id$"
|
|
|
|
import sys
|
|
import os
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
from Crypto.Util.py3compat import *
|
|
|
|
import unittest
|
|
--- lib/Crypto/SelfTest/Random/Fortuna/test_FortunaAccumulator.py
|
|
+++ lib/Crypto/SelfTest/Random/Fortuna/test_FortunaAccumulator.py
|
|
@@ -27,8 +27,6 @@
|
|
__revision__ = "$Id$"
|
|
|
|
import sys
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
from Crypto.Util.py3compat import *
|
|
|
|
import unittest
|
|
--- lib/Crypto/SelfTest/Random/Fortuna/test_FortunaGenerator.py
|
|
+++ lib/Crypto/SelfTest/Random/Fortuna/test_FortunaGenerator.py
|
|
@@ -27,8 +27,6 @@
|
|
__revision__ = "$Id$"
|
|
|
|
import sys
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
from Crypto.Util.py3compat import *
|
|
|
|
import unittest
|
|
--- lib/Crypto/SelfTest/Random/test_random.py
|
|
+++ lib/Crypto/SelfTest/Random/test_random.py
|
|
@@ -28,8 +28,6 @@ __revision__ = "$Id$"
|
|
|
|
import unittest
|
|
import sys
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
from Crypto.Util.py3compat import *
|
|
|
|
class SimpleTest(unittest.TestCase):
|
|
--- lib/Crypto/SelfTest/st_common.py
|
|
+++ lib/Crypto/SelfTest/st_common.py
|
|
@@ -29,8 +29,6 @@ __revision__ = "$Id$"
|
|
import unittest
|
|
import binascii
|
|
import sys
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
from Crypto.Util.py3compat import *
|
|
|
|
class _list_testloader(unittest.TestLoader):
|
|
--- lib/Crypto/SelfTest/Util/test_Counter.py
|
|
+++ lib/Crypto/SelfTest/Util/test_Counter.py
|
|
@@ -27,8 +27,6 @@
|
|
__revision__ = "$Id$"
|
|
|
|
import sys
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
from Crypto.Util.py3compat import *
|
|
|
|
import unittest
|
|
--- lib/Crypto/SelfTest/Util/test_number.py
|
|
+++ lib/Crypto/SelfTest/Util/test_number.py
|
|
@@ -27,8 +27,6 @@
|
|
__revision__ = "$Id$"
|
|
|
|
import sys
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
|
|
import unittest
|
|
|
|
--- lib/Crypto/Signature/PKCS1_PSS.py
|
|
+++ lib/Crypto/Signature/PKCS1_PSS.py
|
|
@@ -67,8 +67,6 @@ __revision__ = "$Id$"
|
|
__all__ = [ 'new', 'PSS_SigScheme' ]
|
|
|
|
from Crypto.Util.py3compat import *
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
import Crypto.Util.number
|
|
from Crypto.Util.number import ceil_shift, ceil_div, long_to_bytes
|
|
from Crypto.Util.strxor import strxor
|
|
--- lib/Crypto/Util/Counter.py
|
|
+++ lib/Crypto/Util/Counter.py
|
|
@@ -52,8 +52,6 @@ An example of usage is the following:
|
|
:undocumented: __package__
|
|
"""
|
|
import sys
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
from Crypto.Util.py3compat import *
|
|
|
|
from Crypto.Util import _counter
|
|
--- lib/Crypto/Util/_number_new.py
|
|
+++ lib/Crypto/Util/_number_new.py
|
|
@@ -28,8 +28,6 @@ __revision__ = "$Id$"
|
|
__all__ = ['ceil_shift', 'ceil_div', 'floor_div', 'exact_log2', 'exact_div']
|
|
|
|
import sys
|
|
-if sys.version_info[0] == 2 and sys.version_info[1] == 1:
|
|
- from Crypto.Util.py21compat import *
|
|
|
|
def ceil_shift(n, b):
|
|
"""Return ceil(n / 2**b) without performing any floating-point or division operations.
|
|
--- lib/Crypto/Util/py21compat.py
|
|
+++ /dev/null
|
|
@@ -1,84 +0,0 @@
|
|
-# -*- coding: utf-8 -*-
|
|
-#
|
|
-# Util/py21compat.py : Compatibility code for Python 2.1
|
|
-#
|
|
-# Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net>
|
|
-#
|
|
-# ===================================================================
|
|
-# The contents of this file are dedicated to the public domain. To
|
|
-# the extent that dedication to the public domain is not available,
|
|
-# everyone is granted a worldwide, perpetual, royalty-free,
|
|
-# non-exclusive license to exercise all rights associated with the
|
|
-# contents of this file for any purpose whatsoever.
|
|
-# No rights are reserved.
|
|
-#
|
|
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
-# SOFTWARE.
|
|
-# ===================================================================
|
|
-
|
|
-"""Compatibility code for Python 2.1
|
|
-
|
|
-Currently, this just defines:
|
|
- - True and False
|
|
- - object
|
|
- - isinstance
|
|
-"""
|
|
-
|
|
-__revision__ = "$Id$"
|
|
-__all__ = []
|
|
-
|
|
-import sys
|
|
-import __builtin__
|
|
-
|
|
-# 'True' and 'False' aren't defined in Python 2.1. Define them.
|
|
-try:
|
|
- True, False
|
|
-except NameError:
|
|
- (True, False) = (1, 0)
|
|
- __all__ += ['True', 'False']
|
|
-
|
|
-# New-style classes were introduced in Python 2.2. Defining "object" in Python
|
|
-# 2.1 lets us use new-style classes in versions of Python that support them,
|
|
-# while still maintaining backward compatibility with old-style classes
|
|
-try:
|
|
- object
|
|
-except NameError:
|
|
- class object: pass
|
|
- __all__ += ['object']
|
|
-
|
|
-# Starting with Python 2.2, isinstance allows a tuple for the second argument.
|
|
-# Also, builtins like "tuple", "list", "str", "unicode", "int", and "long"
|
|
-# became first-class types, rather than functions. We want to support
|
|
-# constructs like:
|
|
-# isinstance(x, (int, long))
|
|
-# So we hack it for Python 2.1.
|
|
-try:
|
|
- isinstance(5, (int, long))
|
|
-except TypeError:
|
|
- __all__ += ['isinstance']
|
|
- _builtin_type_map = {
|
|
- tuple: type(()),
|
|
- list: type([]),
|
|
- str: type(""),
|
|
- unicode: type(u""),
|
|
- int: type(0),
|
|
- long: type(0L),
|
|
- }
|
|
- def isinstance(obj, t):
|
|
- if not __builtin__.isinstance(t, type(())):
|
|
- # t is not a tuple
|
|
- return __builtin__.isinstance(obj, _builtin_type_map.get(t, t))
|
|
- else:
|
|
- # t is a tuple
|
|
- for typ in t:
|
|
- if __builtin__.isinstance(obj, _builtin_type_map.get(typ, typ)):
|
|
- return True
|
|
- return False
|
|
-
|
|
-# vim:set ts=4 sw=4 sts=4 expandtab:
|