1 # Author: Trevor Perrin
2 # See the LICENSE file for legal information regarding use of this file.
4 """PyCrypto AES implementation."""
6 from .cryptomath import *
10 import Crypto.Cipher.AES
12 def new(key, mode, IV):
13 return PyCrypto_AES(key, mode, IV)
15 class PyCrypto_AES(AES):
17 def __init__(self, key, mode, IV):
18 AES.__init__(self, key, mode, IV, "pycrypto")
21 self.context = Crypto.Cipher.AES.new(key, mode, IV)
23 def encrypt(self, plaintext):
24 plaintext = bytes(plaintext)
25 return bytearray(self.context.encrypt(plaintext))
27 def decrypt(self, ciphertext):
28 ciphertext = bytes(ciphertext)
29 return bytearray(self.context.decrypt(ciphertext))