summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/tlslite/tlslite/utils/cipherfactory.py
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/tlslite/tlslite/utils/cipherfactory.py')
-rw-r--r--chromium/third_party/tlslite/tlslite/utils/cipherfactory.py61
1 files changed, 26 insertions, 35 deletions
diff --git a/chromium/third_party/tlslite/tlslite/utils/cipherfactory.py b/chromium/third_party/tlslite/tlslite/utils/cipherfactory.py
index ccbb6b5ff9b..20e20f11003 100644
--- a/chromium/third_party/tlslite/tlslite/utils/cipherfactory.py
+++ b/chromium/third_party/tlslite/tlslite/utils/cipherfactory.py
@@ -1,30 +1,27 @@
+# Author: Trevor Perrin
+# See the LICENSE file for legal information regarding use of this file.
+
"""Factory functions for symmetric cryptography."""
import os
-import Python_AES
-import Python_RC4
+from tlslite.utils import python_aes
+from tlslite.utils import python_rc4
-import cryptomath
+from tlslite.utils import cryptomath
tripleDESPresent = False
if cryptomath.m2cryptoLoaded:
- import OpenSSL_AES
- import OpenSSL_RC4
- import OpenSSL_TripleDES
- tripleDESPresent = True
-
-if cryptomath.cryptlibpyLoaded:
- import Cryptlib_AES
- import Cryptlib_RC4
- import Cryptlib_TripleDES
+ from tlslite.utils import openssl_aes
+ from tlslite.utils import openssl_rc4
+ from tlslite.utils import openssl_tripledes
tripleDESPresent = True
if cryptomath.pycryptoLoaded:
- import PyCrypto_AES
- import PyCrypto_RC4
- import PyCrypto_TripleDES
+ from tlslite.utils import pycrypto_aes
+ from tlslite.utils import pycrypto_rc4
+ from tlslite.utils import pycrypto_tripledes
tripleDESPresent = True
# **************************************************************************
@@ -44,17 +41,15 @@ def createAES(key, IV, implList=None):
@return: An AES object.
"""
if implList == None:
- implList = ["cryptlib", "openssl", "pycrypto", "python"]
+ implList = ["openssl", "pycrypto", "python"]
for impl in implList:
- if impl == "cryptlib" and cryptomath.cryptlibpyLoaded:
- return Cryptlib_AES.new(key, 2, IV)
- elif impl == "openssl" and cryptomath.m2cryptoLoaded:
- return OpenSSL_AES.new(key, 2, IV)
+ if impl == "openssl" and cryptomath.m2cryptoLoaded:
+ return openssl_aes.new(key, 2, IV)
elif impl == "pycrypto" and cryptomath.pycryptoLoaded:
- return PyCrypto_AES.new(key, 2, IV)
+ return pycrypto_aes.new(key, 2, IV)
elif impl == "python":
- return Python_AES.new(key, 2, IV)
+ return python_aes.new(key, 2, IV)
raise NotImplementedError()
def createRC4(key, IV, implList=None):
@@ -70,19 +65,17 @@ def createRC4(key, IV, implList=None):
@return: An RC4 object.
"""
if implList == None:
- implList = ["cryptlib", "openssl", "pycrypto", "python"]
+ implList = ["openssl", "pycrypto", "python"]
if len(IV) != 0:
raise AssertionError()
for impl in implList:
- if impl == "cryptlib" and cryptomath.cryptlibpyLoaded:
- return Cryptlib_RC4.new(key)
- elif impl == "openssl" and cryptomath.m2cryptoLoaded:
- return OpenSSL_RC4.new(key)
+ if impl == "openssl" and cryptomath.m2cryptoLoaded:
+ return openssl_rc4.new(key)
elif impl == "pycrypto" and cryptomath.pycryptoLoaded:
- return PyCrypto_RC4.new(key)
+ return pycrypto_rc4.new(key)
elif impl == "python":
- return Python_RC4.new(key)
+ return python_rc4.new(key)
raise NotImplementedError()
#Create a new TripleDES instance
@@ -99,13 +92,11 @@ def createTripleDES(key, IV, implList=None):
@return: A 3DES object.
"""
if implList == None:
- implList = ["cryptlib", "openssl", "pycrypto"]
+ implList = ["openssl", "pycrypto"]
for impl in implList:
- if impl == "cryptlib" and cryptomath.cryptlibpyLoaded:
- return Cryptlib_TripleDES.new(key, 2, IV)
- elif impl == "openssl" and cryptomath.m2cryptoLoaded:
- return OpenSSL_TripleDES.new(key, 2, IV)
+ if impl == "openssl" and cryptomath.m2cryptoLoaded:
+ return openssl_tripledes.new(key, 2, IV)
elif impl == "pycrypto" and cryptomath.pycryptoLoaded:
- return PyCrypto_TripleDES.new(key, 2, IV)
+ return pycrypto_tripledes.new(key, 2, IV)
raise NotImplementedError() \ No newline at end of file