1
2
3
4 """Abstract class for AES."""
5
7 - def __init__(self, key, mode, IV, implementation):
8 if len(key) not in (16, 24, 32):
9 raise AssertionError()
10 if mode != 2:
11 raise AssertionError()
12 if len(IV) != 16:
13 raise AssertionError()
14 self.isBlockCipher = True
15 self.isAEAD = False
16 self.block_size = 16
17 self.implementation = implementation
18 if len(key)==16:
19 self.name = "aes128"
20 elif len(key)==24:
21 self.name = "aes192"
22 elif len(key)==32:
23 self.name = "aes256"
24 else:
25 raise AssertionError()
26
27
28
30 assert(len(plaintext) % 16 == 0)
31
32
33
35 assert(len(ciphertext) % 16 == 0)
36