|
@ -21,19 +21,20 @@ |
|
|
# SOFTWARE. |
|
|
# SOFTWARE. |
|
|
|
|
|
|
|
|
import logging |
|
|
import logging |
|
|
|
|
|
from ctypes import CDLL, c_char_p, c_int, c_long, byref,\ |
|
|
|
|
|
create_string_buffer, c_void_p |
|
|
|
|
|
|
|
|
__all__ = ['ciphers'] |
|
|
__all__ = ['ciphers'] |
|
|
|
|
|
|
|
|
|
|
|
libcrypto = None |
|
|
loaded = False |
|
|
loaded = False |
|
|
|
|
|
|
|
|
buf_size = 2048 |
|
|
buf_size = 2048 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def load_openssl(): |
|
|
def load_openssl(): |
|
|
global loaded, libcrypto, CDLL, c_char_p, c_int, c_long, byref,\ |
|
|
global loaded, libcrypto, buf |
|
|
create_string_buffer, c_void_p, buf |
|
|
|
|
|
from ctypes import CDLL, c_char_p, c_int, c_long, byref,\ |
|
|
|
|
|
create_string_buffer, c_void_p |
|
|
|
|
|
from ctypes.util import find_library |
|
|
from ctypes.util import find_library |
|
|
for p in ('crypto', 'eay32', 'libeay32'): |
|
|
for p in ('crypto', 'eay32', 'libeay32'): |
|
|
libcrypto_path = find_library(p) |
|
|
libcrypto_path = find_library(p) |
|
@ -152,7 +153,7 @@ def test(): |
|
|
BLOCK_SIZE = 16384 |
|
|
BLOCK_SIZE = 16384 |
|
|
rounds = 1 * 1024 |
|
|
rounds = 1 * 1024 |
|
|
plain = urandom(BLOCK_SIZE * rounds) |
|
|
plain = urandom(BLOCK_SIZE * rounds) |
|
|
import M2Crypto.EVP |
|
|
# import M2Crypto.EVP |
|
|
# cipher = M2Crypto.EVP.Cipher('aes_128_cfb', 'k' * 32, 'i' * 16, 1, |
|
|
# cipher = M2Crypto.EVP.Cipher('aes_128_cfb', 'k' * 32, 'i' * 16, 1, |
|
|
# key_as_bytes=0, d='md5', salt=None, i=1, |
|
|
# key_as_bytes=0, d='md5', salt=None, i=1, |
|
|
# padding=1) |
|
|
# padding=1) |
|
|