OLD | NEW |
1 """Pure-Python AES implementation.""" | 1 """Pure-Python AES implementation.""" |
2 | 2 |
3 from cryptomath import * | 3 from cryptomath import * |
4 | 4 |
5 from AES import * | 5 from aes import * |
6 from rijndael import rijndael | 6 from rijndael import rijndael |
7 | 7 |
8 def new(key, mode, IV): | 8 def new(key, mode, IV): |
9 return Python_AES(key, mode, IV) | 9 return Python_AES(key, mode, IV) |
10 | 10 |
11 class Python_AES(AES): | 11 class Python_AES(AES): |
12 def __init__(self, key, mode, IV): | 12 def __init__(self, key, mode, IV): |
13 AES.__init__(self, key, mode, IV, "python") | 13 AES.__init__(self, key, mode, IV, "python") |
14 self.rijndael = rijndael(key, 16) | 14 self.rijndael = rijndael(key, 16) |
15 self.IV = IV | 15 self.IV = IV |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #XOR with the chaining block and overwrite the input with output | 59 #XOR with the chaining block and overwrite the input with output |
60 for y in range(16): | 60 for y in range(16): |
61 decryptedBytes[y] ^= chainBytes[y] | 61 decryptedBytes[y] ^= chainBytes[y] |
62 ciphertextBytes[(x*16)+y] = decryptedBytes[y] | 62 ciphertextBytes[(x*16)+y] = decryptedBytes[y] |
63 | 63 |
64 #Set the next chaining block | 64 #Set the next chaining block |
65 chainBytes = blockBytes | 65 chainBytes = blockBytes |
66 | 66 |
67 self.IV = bytesToString(chainBytes) | 67 self.IV = bytesToString(chainBytes) |
68 return bytesToString(ciphertextBytes) | 68 return bytesToString(ciphertextBytes) |
OLD | NEW |