/gdata/tlslite/utils/PyCrypto_AES.py

http://radioappz.googlecode.com/ · Python · 22 lines · 14 code · 7 blank · 1 comment · 1 complexity · 479d8f9fe572d327f6668645a6ba3f39 MD5 · raw file

  1. """PyCrypto AES implementation."""
  2. from cryptomath import *
  3. from AES import *
  4. if pycryptoLoaded:
  5. import Crypto.Cipher.AES
  6. def new(key, mode, IV):
  7. return PyCrypto_AES(key, mode, IV)
  8. class PyCrypto_AES(AES):
  9. def __init__(self, key, mode, IV):
  10. AES.__init__(self, key, mode, IV, "pycrypto")
  11. self.context = Crypto.Cipher.AES.new(key, mode, IV)
  12. def encrypt(self, plaintext):
  13. return self.context.encrypt(plaintext)
  14. def decrypt(self, ciphertext):
  15. return self.context.decrypt(ciphertext)