1
2
3
4 """PyCrypto AES implementation."""
5
6 from .cryptomath import *
7 from .aes import *
8
9 if pycryptoLoaded:
10 import Crypto.Cipher.AES
11
12 - def new(key, mode, IV):
14
16
18 AES.__init__(self, key, mode, IV, "pycrypto")
19 key = bytes(key)
20 IV = bytes(IV)
21 self.context = Crypto.Cipher.AES.new(key, mode, IV)
22
24 plaintext = bytes(plaintext)
25 return bytearray(self.context.encrypt(plaintext))
26
28 ciphertext = bytes(ciphertext)
29 return bytearray(self.context.decrypt(ciphertext))
30