andOTP-decrypt icon indicating copy to clipboard operation
andOTP-decrypt copied to clipboard

Update to use from pycryptodome AES instead of pycrpto version as CCM…

Open felimwhiteley opened this issue 4 years ago • 4 comments

… is no longer present

As python3-pycryptodome was already part of the install dependencies it seems maybe this was forgotten or python 3.8 on Ubuntu 20.04 based distros caused it to break.

Otherwise it throws a

module 'Crypto.Cipher.AES' has no attribute 'MODE_GCM'

Error and exits after the password is entered.

felimwhiteley avatar Nov 02 '21 16:11 felimwhiteley

Hmm, the main branch works fine for me on Ubuntu 21.10. When I merge this the tests fail:

ImportError while importing test module '/home/asmw/src/andOTP-decrypt/tests/test_andotp.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_andotp.py:2: in <module>
    import andotp_decrypt as ad
andotp_decrypt.py:21: in <module>
    from Cryptodome.Cipher import AES
E   ModuleNotFoundError: No module named 'Cryptodome'

asmw avatar Nov 02 '21 17:11 asmw

Looking at the examples (https://www.pycryptodome.org/en/latest/src/examples.html#encrypt-data-with-aes), pycryptodome provides the Crypto module

asmw avatar Nov 02 '21 18:11 asmw

Sorry had missed your replies. It's a weird one, but I've seen various bits about the web about the MODE_GCM going away with later python versions, here's one example;

https://stackoverflow.com/questions/43987779/python-module-crypto-cipher-aes-has-no-attribute-mode-ccm-even-though-pycry

I'm using KDE Neon, the base system is Ubuntu 20.04 and I have Python 3.8.10 as part of that. And once I made my change I could just run the decrypt script on it's own (once installed the deps you have for debian systems) and I managed to decrypt the andOTP backup perfectly. I didn't use pip and the requirements.

felimwhiteley avatar Nov 04 '21 09:11 felimwhiteley

I have no idea. I guess it might be a precedence issue with PyCrypto and PyCryptodome? As I wrote, the version in the patch does not work for me. We could try the Crypto import first and fall-back to the Cryptodome? I wonder why it says No module named 'Cryptodome' here

asmw avatar Nov 05 '21 06:11 asmw