Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3DES implementation #202

Merged
merged 1 commit into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment explaining why it's present would likely be a good idea – backwards compatibility and so on

also, the later re-sets to True probably should be removed

"""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