OLD | NEW |
1 """Abstract class for AES.""" | 1 """Abstract class for AES.""" |
2 | 2 |
3 class AES: | 3 class AES: |
4 def __init__(self, key, mode, IV, implementation): | 4 def __init__(self, key, mode, IV, implementation): |
5 if len(key) not in (16, 24, 32): | 5 if len(key) not in (16, 24, 32): |
6 raise AssertionError() | 6 raise AssertionError() |
7 if mode != 2: | 7 if mode != 2: |
8 raise AssertionError() | 8 raise AssertionError() |
9 if len(IV) != 16: | 9 if len(IV) != 16: |
10 raise AssertionError() | 10 raise AssertionError() |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 #CBC-Mode encryption, returns ciphertext | 23 #CBC-Mode encryption, returns ciphertext |
24 #WARNING: *MAY* modify the input as well | 24 #WARNING: *MAY* modify the input as well |
25 def encrypt(self, plaintext): | 25 def encrypt(self, plaintext): |
26 assert(len(plaintext) % 16 == 0) | 26 assert(len(plaintext) % 16 == 0) |
27 | 27 |
28 #CBC-Mode decryption, returns plaintext | 28 #CBC-Mode decryption, returns plaintext |
29 #WARNING: *MAY* modify the input as well | 29 #WARNING: *MAY* modify the input as well |
30 def decrypt(self, ciphertext): | 30 def decrypt(self, ciphertext): |
31 assert(len(ciphertext) % 16 == 0) | 31 assert(len(ciphertext) % 16 == 0) |
OLD | NEW |