quarkslab / crypto-condor

crypto-condor is a Python library for compliance testing of implementations of cryptographic primitives
https://quarkslab.github.io/crypto-condor/latest/index.html
Apache License 2.0
17 stars 3 forks source link

Reference implementation not found #2

Closed pcotret closed 5 months ago

pcotret commented 5 months ago
$ python -m pip install crypto-condor
$ make build
[+] Installing with poetry
poetry install --with=dev,docs
The currently activated Python version 3.10.12 is not supported by the project (^3.11).
Trying to find and use a compatible version. 
Using python3.11 (3.11.0)
Installing dependencies from lock file

No dependencies to install or update

Installing the current project: crypto-condor (2024.06.04)

[+] Importing NIST crypto_condor/vectors/_kyber test vectors
[+] Importing NIST crypto_condor/vectors/_HMAC test vectors
[+] Importing NIST crypto_condor/vectors/_ECDH test vectors
[+] Importing NIST crypto_condor/vectors/_dilithium test vectors
[+] Importing NIST crypto_condor/vectors/_sphincs test vectors
[+] Importing NIST crypto_condor/vectors/_ecdsa test vectors
[+] Importing NIST crypto_condor/vectors/_falcon test vectors
[+] Importing NIST crypto_condor/vectors/_aes test vectors
[+] Importing NIST crypto_condor/vectors/_rsa test vectors
[+] Importing NIST crypto_condor/vectors/_sha test vectors
[+] Compiling primitives
cd crypto_condor/primitives && make all -j4
make[1]: Entering directory '/home/test/Documents/crypto-condor/crypto_condor/primitives'
python AES.py
AES directory not found: crypto-condor uses its own C implementation of AES for the classic modes of operation, which has to be compiled and installed locally.
Installation will be done at /home/test/.local/share/crypto-condor/AES
python Dilithium.py
Dilithium directory not found: crypto-condor uses the reference implementation of Dilithium, which has to be compiled and installed locally
Installation will be done at /home/test/.local/share/crypto-condor/Dilithium
Traceback (most recent call last):
  File "/home/test/Documents/crypto-condor/crypto_condor/primitives/Dilithium.py", line 474, in <module>
    _get_lib_dir()
  File "/home/test/Documents/crypto-condor/crypto_condor/primitives/Dilithium.py", line 73, in _get_lib_dir
    shutil.copyfile(str(rsc / "README.md"), lib_dir / "README.md")
  File "/usr/lib/python3.11/shutil.py", line 256, in copyfile
    with open(src, 'rb') as fsrc:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/test/.local/lib/python3.11/site-packages/crypto_condor/primitives/_dilithium/README.md'
make[1]: *** [Makefile:7: libs] Error 1
make[1]: Leaving directory '/home/test/Documents/crypto-condor/crypto_condor/primitives'
make: *** [Makefile:32: compile-primitives] Error 2

However, I assume it's OK as long as we've installed crypto-condor from PyPI.

pcotret commented 5 months ago

I have a similar behavior following https://quarkslab.github.io/crypto-condor/latest/development/CONTRIBUTING.html

$ make init
[+] Installing with poetry
poetry install --with=dev,docs
Installing dependencies from lock file

No dependencies to install or update

Installing the current project: crypto-condor (2024.06.04)

[+] Compiling primitives
cd crypto_condor/primitives && make all -j4
make[1]: Entering directory '/home/test/Documents/crypto-condor/crypto_condor/primitives'
python AES.py
python Dilithium.py
python Kyber.py
Kyber directory not found: crypto-condor uses the reference implementation of Kyber, which has to be compiled and installed locally
Installation will be done at /home/test/.local/share/crypto-condor/Kyber
python TestU01.py
TestU01 directory not found, copying it to /home/test/.local/share/crypto-condor/testu01
Could not compile TestU01
JulioLoayzaM commented 5 months ago

Hi @pcotret,

Indeed, it should work directly when installing from PyPI, make build/make init are used when installing from source. That said, the "no such file _dilithium/README.md" is a bug that affects users of the package, I'll push an update.

For the second error, that is a problem with the compilation of TestU01. On another machine I noticed the installation timed out because of a missing texlive package. I'm checking how to add debugging for that step.

JulioLoayzaM commented 5 months ago

Ok, so I've pushed a release that solves the bug for installing Kyber and Dilithium. As for TestU01, I've removed its dependency on TeX Live, meaning it is less likely for the compilation to fail. It also can display the compilation output when the verbosity is increased. For example:

head -c 1M </dev/urandom >random.bin
crypto-condor-cli -vv testu01 random.bin

So I'm closing this issue, feel free to open a new one if TestU01 fails to install (or any other problem).