Skip to content

Commit

Permalink
python_tripledes and test_tlslite_utils_tripledes added, updated
Browse files Browse the repository at this point in the history
  • Loading branch information
avargaRH committed Apr 18, 2018
1 parent 6498e79 commit da9336a
Show file tree
Hide file tree
Showing 4 changed files with 1,032 additions and 9 deletions.
10 changes: 6 additions & 4 deletions tlslite/utils/cipherfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
from tlslite.utils import python_aesgcm
from tlslite.utils import python_chacha20_poly1305
from tlslite.utils import python_rc4
from tlslite.utils import python_tripledes

from tlslite.utils import cryptomath

tripleDESPresent = False
tripleDESPresent = True
"""Inform if the 3DES algorithm is supported."""

if cryptomath.m2cryptoLoaded:
from tlslite.utils import openssl_aes
from tlslite.utils import openssl_rc4
from tlslite.utils import openssl_tripledes
tripleDESPresent = True

if cryptomath.pycryptoLoaded:
from tlslite.utils import pycrypto_aes
from tlslite.utils import pycrypto_aesgcm
from tlslite.utils import pycrypto_rc4
from tlslite.utils import pycrypto_tripledes
tripleDESPresent = True

# **************************************************************************
# Factory Functions for AES
Expand Down Expand Up @@ -131,11 +131,13 @@ def createTripleDES(key, IV, implList=None):
:returns: A 3DES object.
"""
if implList is None:
implList = ["openssl", "pycrypto"]
implList = ["openssl", "pycrypto", "python"]

for impl in implList:
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)
elif impl == "python":
return python_tripledes.new(key, IV)
raise NotImplementedError()
Loading

0 comments on commit da9336a

Please sign in to comment.