github
3964 of 5790 branches covered (68.46%)
Branch coverage included in aggregate %.
66 of 95 new or added lines in 4 files covered. (69.47%)
958 existing lines in 43 files now uncovered.11139 of 13847 relevant lines covered (80.44%)
0.8 hits per line
1 |
# Author: Trevor Perrin
|
|
2 |
# See the LICENSE file for legal information regarding use of this file.
|
|
3 |
|
|
UNCOV
4
|
"""PyCrypto AES implementation."""
|
× |
5 |
|
|
UNCOV
6
|
from .cryptomath import * |
× |
UNCOV
7
|
from .aes import * |
× |
8 |
|
|
UNCOV
9
|
if pycryptoLoaded:
|
|
UNCOV
10
|
import Crypto.Cipher.AES |
× |
11 |
|
|
UNCOV
12
|
def new(key, mode, IV): |
× |
UNCOV
13
|
return PyCrypto_AES(key, mode, IV)
|
× |
14 |
|
|
UNCOV
15
|
class PyCrypto_AES(AES): |
× |
16 |
|
|
UNCOV
17
|
def __init__(self, key, mode, IV): |
× |
UNCOV
18
|
AES.__init__(self, key, mode, IV, "pycrypto") |
× |
UNCOV
19
|
key = bytes(key)
|
× |
UNCOV
20
|
IV = bytes(IV)
|
× |
UNCOV
21
|
self.context = Crypto.Cipher.AES.new(key, mode, IV)
|
× |
22 |
|
|
UNCOV
23
|
def encrypt(self, plaintext): |
× |
UNCOV
24
|
plaintext = bytes(plaintext)
|
× |
UNCOV
25
|
return bytearray(self.context.encrypt(plaintext)) |
× |
26 |
|
|
UNCOV
27
|
def decrypt(self, ciphertext): |
× |
UNCOV
28
|
ciphertext = bytes(ciphertext)
|
× |
UNCOV
29
|
return bytearray(self.context.decrypt(ciphertext)) |
× |