-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"LAF Crypto failed to import!" error is unhelpful #39
Comments
So, the following advice may not work for you, but this is what I found. I am using Windows x64 Python 3.6.4. because the laf_crypto was not importing, there must be an issue with the module. (lglaf requires _AES.py) in case your wondering. Sure enough, there is a further dependency in laf_crypto for crypto.cipher. However getting it installed with 'pip pycrypto'. fails. Digging in further, the project seems dead ( SEE: pycrypto/pycrypto#173 ) and is not working with Python for windows. There is a FORK of the project named pycryptodome that at least provides the library. Your best bet is to remove any version of pycrypto and install pycryptodome with: See: https://pycryptodome.readthedocs.io/en/latest/src/examples.html |
Only an AES ECB encrypt implementation is required, the https://cryptography.io/en/latest/ library seems better maintained, would it be OK to switch to that @tuxuser ? |
@Lekensteyn sure! Maybe somebody can test this? diff --git a/laf_crypto.py b/laf_crypto.py
index fa6cad5..fb1c434 100644
--- a/laf_crypto.py
+++ b/laf_crypto.py
@@ -1,4 +1,5 @@
-from Crypto.Cipher import AES
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
from utils import int_as_byte
class LafCrypto(object):
@@ -30,5 +31,6 @@ class LafCrypto(object):
plaintext += int_as_byte(k)
encryption_key = LafCrypto.key_transform(encryption_key)
xored_key = LafCrypto.xor_key(encryption_key, kilo_challenge)
- obj = AES.new(xored_key, AES.MODE_ECB)
- return obj.encrypt(plaintext)
+ obj = Cipher(algorithms.AES(xored_key), modes.ECB(), backend=default_backend()).encryptor()
+ # Is finalize (aka. add padding) desired?
+ return obj.update(plaintext) + obj.finalize()
UPDATE: PR sent, #44 |
Printing a warning but not explaining why it happened isn't helpful, there's no way to know why it didn't load (missing a library, etc)
The text was updated successfully, but these errors were encountered: