Skip to content

Commit

Permalink
python_tripledes added, cipherfactory modified
Browse files Browse the repository at this point in the history
  • Loading branch information
avargaRH committed Feb 1, 2018
1 parent 79eee61 commit d7d7b1d
Show file tree
Hide file tree
Showing 2 changed files with 585 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tlslite/utils/cipherfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
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

if cryptomath.m2cryptoLoaded:
from tlslite.utils import openssl_aes
Expand Down Expand Up @@ -118,7 +119,7 @@ def createRC4(key, IV, implList=None):
raise NotImplementedError()

#Create a new TripleDES instance
def createTripleDES(key, IV, implList=None):
def createTripleDES(key, IV=None, implList=None):
"""Create a new 3DES object.
:type key: str
Expand All @@ -131,11 +132,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 d7d7b1d

Please sign in to comment.