Avoid defining Python's AES class if libssl's is available

This commit is contained in:
Lonami Exo 2017-08-20 01:23:57 +02:00
parent c296459d0a
commit 274e16ac66

View File

@ -2,6 +2,12 @@ import os
import pyaes
from . import libssl
if libssl.libssl:
# Use libssl if available, since it will be faster
AES = libssl.AES
else:
# Fallback to a pure Python implementation
class AES:
@staticmethod
def decrypt_ige(cipher_text, key, iv):
@ -71,7 +77,3 @@ class AES:
cipher_text.extend(cipher_text_block)
return bytes(cipher_text)
# use libssl if available
if libssl.libssl:
AES = libssl.AES