Disasm / verilog_decrypt

2 stars 0 forks source link

[workaround] ubuntu 18.04 #1

Open iDoka opened 1 year ago

iDoka commented 1 year ago

I'm appreciate to provide venv version and I would like to share my solution for Ubuntu 18.04.

Actually, ubuntu have ancient version of cryptography package from repo: python3-cryptography_2.1.4-1ubuntu1.4_amd64.deb But version from requirements.txt doesn't work for me:

(.venv) pip3 install -r requirements.txt
Collecting cryptography==41.0.1 (from -r requirements.txt (line 1))
  Could not find a version that satisfies the requirement cryptography==41.0.1 (from -r requirements.txt (line 1)) (from versions: 0.1, 0.2, 0.2.1, 0.2.2, 0.3, 0.4, 0.5, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.6, 0.6.1, 0.7, 0.7.1, 0.7.2, 0.8, 0.8.1, 0.8.2, 0.9, 0.9.1, 0.9.2, 0.9.3, 1.0, 1.0.1, 1.0.2, 1.1, 1.1.1, 1.1.2, 1.2, 1.2.1, 1.2.2, 1.2.3, 1.3, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.4, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.6, 1.7, 1.7.1, 1.7.2, 1.8, 1.8.1, 1.8.2, 1.9, 2.0, 2.0.1, 2.0.2, 2.0.3, 2.1, 2.1.1, 2.1.2, 2.1.3, 2.1.4, 2.2, 2.2.1, 2.2.2, 2.3, 2.3.1, 2.4, 2.4.1, 2.4.2, 2.5, 2.6, 2.6.1, 2.7, 2.8, 2.9, 2.9.1, 2.9.2, 3.0, 3.1, 3.1.1, 3.2, 3.2.1, 3.3, 3.3.1, 3.3.2, 3.4, 3.4.1, 3.4.2, 3.4.3, 3.4.4, 3.4.5, 3.4.6, 3.4.7, 3.4.8, 35.0.0, 36.0.0, 36.0.1, 36.0.2, 37.0.0, 37.0.1, 37.0.2, 37.0.3, 37.0.4, 38.0.0, 38.0.1, 38.0.2, 38.0.3, 38.0.4, 39.0.0, 39.0.1, 39.0.2, 40.0.0, 40.0.1, 40.0.2)
No matching distribution found for cryptography==41.0.1 (from -r requirements.txt (line 1))
  1. Downgrade version in requirements.txt (I'm picked up v40.0.2)
  2. By installing 'cryptography' I have stuggles with dependency 'setuptools_rust' (tried to add it to requirements.txt, but no results). I have used command to manual 'setuptools_rust' installation: pip3 install setuptools_rust
  3. Now, it seems that we can eventually install 'cryptography', but "This package requires Rust >=1.41.0". The solution is: "If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.": pip3 install --upgrade pip

Full sequence of cmds:

* downgrade version of cryptography in requirements.txt

python3 -m venv .venv
source .venv/bin/activate
pip3 install setuptools_rust
pip3 install --upgrade pip
pip3 install -r requirements.txt

Now, by running ./verilog_decrypt.py I realized the root of issue: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6. and script has been failed:

Traceback (most recent call last):
  File "./verilog_decrypt.py", line 93, in <module>
    main()
  File "./verilog_decrypt.py", line 59, in main
    aes = Cipher(algorithms.AES(encryption_key), modes.CBC(aes_iv)).decryptor()
  File "/home/doka/proj/2023/verilog_decrypt/.venv/lib/python3.6/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py", line 34, in __init__
    self.key = _verify_key_size(self, key)
  File "/home/doka/proj/2023/verilog_decrypt/.venv/lib/python3.6/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py", line 21, in _verify_key_size
    len(key) * 8, algorithm.name
ValueError: Invalid key size (504) for AES.

Okay, I have just downoladed and unpacked python v3.9.7 into /opt/python-3.9.7. Try again:

/opt/python-3.9.7/bin/python3.9 -m venv .venv
source .venv/bin/activate
pip3 install -r requirements.txt

and have the same issue (on cryptography==41.0.1): ValueError: Invalid key size (504) for AES

..to be continued

Disasm commented 1 year ago

The last error should be fixed by https://github.com/Disasm/verilog_decrypt/commit/b83958d7078b870508105233fe34955f784a8ee7.