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
|
"""OpenSSL/M2Crypto RC4 implementation."""
|
× |
5 |
|
|
UNCOV
6
|
from .cryptomath import * |
× |
UNCOV
7
|
from .rc4 import RC4 |
× |
8 |
|
|
UNCOV
9
|
if m2cryptoLoaded:
|
|
10 |
|
|
UNCOV
11
|
def new(key): |
× |
UNCOV
12
|
return OpenSSL_RC4(key)
|
× |
13 |
|
|
UNCOV
14
|
class OpenSSL_RC4(RC4): |
× |
15 |
|
|
UNCOV
16
|
def __init__(self, key): |
× |
UNCOV
17
|
RC4.__init__(self, key, "openssl") |
× |
UNCOV
18
|
self.rc4 = m2.rc4_new()
|
× |
UNCOV
19
|
m2.rc4_set_key(self.rc4, key)
|
× |
20 |
|
|
UNCOV
21
|
def __del__(self): |
× |
UNCOV
22
|
m2.rc4_free(self.rc4)
|
× |
23 |
|
|
UNCOV
24
|
def encrypt(self, plaintext): |
× |
UNCOV
25
|
return bytearray(m2.rc4_update(self.rc4, plaintext)) |
× |
26 |
|
|
UNCOV
27
|
def decrypt(self, ciphertext): |
× |
UNCOV
28
|
return bytearray(self.encrypt(ciphertext)) |
× |