Unable to Install python3-crypto on Ubuntu 22.04.5 – Blocks gen_ekb.py

I recently migrated my manufacturing machine from Ubuntu 20 to Ubuntu 22. However, I can no longer install python3-crypto using apt, as instructed in the Disk Encryption documentation. This prevents gen_ekb.py from working properly.

Has anyone encountered this issue or found a workaround?

gen_ekb.py errors:

from Crypto.Cipher import AES
ModuleNotFonudError: No module named 'Crypto'

Note:
It works perfectly on Ubuntu 20

Update:
I resolved the issue by replacing the import statement in gen_ekb.py:

from Crypto.Cipher import AES

with

from Cryptodome.Cipher import AES

Furthermore, I removed python3-crypto from the installation list and installed the following packages instead:

sudo apt-get install python3-cryptography python3-cffi-backend libxml2-utils
sudo apt-get install cryptsetup python3-pycryptodome

hello pinyu.wang,

did you try pip install cryptography instead?

Yes, I did try installing cryptography, but I’m still getting the same error No module named 'Crypto', so I think modifing the code directly might be the quickest solution.

hello pinyu.wang,

please refer to..

it looks python3-crypto has replaced by python3-cryptography from Ubuntu-22.04 and above.

Thanks for the information. Unfortunately, I’m still seeing the same error: No module named 'Crypto'. I’m wondering if you’ve tried any approach that works without modifying any code~

By the way, the document already mentions installing python3-cryptography

hello pinyu.wang,

we test on Ubuntu 24.04 directly, install python3-cryptography, it working without modify the code.

Got it. I’ll try it when I have an Ubuntu 24 machine.
Thanks for your help, appreciate it!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.