diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-05-06 01:26:53 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-05-06 01:26:53 +0000 |
commit | 9590d0bb421cb7fdf7dd04d4b1d0d77e3f06f13b (patch) | |
tree | 768763aa48be1a5a2c8dae7cba81859510f1146e /src/lib/tlslite/utils/OpenSSL_TripleDES.py | |
parent | 13f6d1554dd24d08d44662906fa9f3f008a23058 (diff) | |
download | bcfg2-9590d0bb421cb7fdf7dd04d4b1d0d77e3f06f13b.tar.gz bcfg2-9590d0bb421cb7fdf7dd04d4b1d0d77e3f06f13b.tar.bz2 bcfg2-9590d0bb421cb7fdf7dd04d4b1d0d77e3f06f13b.zip |
more to python 2.6 ssl
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5187 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/tlslite/utils/OpenSSL_TripleDES.py')
-rwxr-xr-x | src/lib/tlslite/utils/OpenSSL_TripleDES.py | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/src/lib/tlslite/utils/OpenSSL_TripleDES.py b/src/lib/tlslite/utils/OpenSSL_TripleDES.py deleted file mode 100755 index f5ba16565..000000000 --- a/src/lib/tlslite/utils/OpenSSL_TripleDES.py +++ /dev/null @@ -1,44 +0,0 @@ -"""OpenSSL/M2Crypto 3DES implementation.""" - -from cryptomath import * -from TripleDES import * - -if m2cryptoLoaded: - - def new(key, mode, IV): - return OpenSSL_TripleDES(key, mode, IV) - - class OpenSSL_TripleDES(TripleDES): - - def __init__(self, key, mode, IV): - TripleDES.__init__(self, key, mode, IV, "openssl") - self.key = key - self.IV = IV - - def _createContext(self, encrypt): - context = m2.cipher_ctx_new() - cipherType = m2.des_ede3_cbc() - m2.cipher_init(context, cipherType, self.key, self.IV, encrypt) - return context - - def encrypt(self, plaintext): - TripleDES.encrypt(self, plaintext) - context = self._createContext(1) - ciphertext = m2.cipher_update(context, plaintext) - m2.cipher_ctx_free(context) - self.IV = ciphertext[-self.block_size:] - return ciphertext - - def decrypt(self, ciphertext): - TripleDES.decrypt(self, ciphertext) - context = self._createContext(0) - #I think M2Crypto has a bug - it fails to decrypt and return the last block passed in. - #To work around this, we append sixteen zeros to the string, below: - plaintext = m2.cipher_update(context, ciphertext+('\0'*16)) - - #If this bug is ever fixed, then plaintext will end up having a garbage - #plaintext block on the end. That's okay - the below code will ignore it. - plaintext = plaintext[:len(ciphertext)] - m2.cipher_ctx_free(context) - self.IV = ciphertext[-self.block_size:] - return plaintext
\ No newline at end of file |