Legrandin / pycryptodome

A self-contained cryptographic library for Python
https://www.pycryptodome.org
Other
2.74k stars 492 forks source link

Tests cannot be run on non-x86 architectures #774

Closed bdrung closed 6 months ago

bdrung commented 8 months ago

The Debian/Ubuntu packages runs the tests cases, but they fail on non-x86 architectures:

make[4]: Entering directory '/<<PKGBUILDDIR>>/src/test'
[ 1%] Building C object CMakeFiles/mont.dir/<<PKGBUILDDIR>>/src/mont.c.o
cc: error: unrecognized command-line option ‘-mssse3’
cc: error: unrecognized command-line option ‘-mpclmul’
cc: error: unrecognized command-line option ‘-maes’
make[4]: *** [CMakeFiles/mont.dir/build.make:76: CMakeFiles/mont.dir/<<PKGBUILDDIR>>/src/mont.c.o] Error 1

I tried to build the tests without SSE and AES disabled on ARM:

cd src/test/
export PYTHON=python3
cmake -DPYTHON=python3 -DSSE=OFF -DAESNI=OFF
make

It fails then:

[  1%] Building C object CMakeFiles/mont.dir/[...]/src/mont.c.o
cc: error: unrecognized command-line option '-mstackrealign'
make[2]: *** [CMakeFiles/mont.dir/build.make:76: CMakeFiles/mont.dir/[...]/src/mont.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:131: CMakeFiles/mont.dir/all] Error 2
make: *** [Makefile:101: all] Error 2

I disabled add_compile_options(-mstackrealign) in CMakeLists.txt and then it failed with:

[ 97%] Building C object CMakeFiles/test_aesni.dir/test_aesni.c.o
[...]/src/test/test_aesni.c:2:10: fatal error: wmmintrin.h: No such file or directory
    2 | #include <wmmintrin.h>
      |          ^~~~~~~~~~~~~

The header wmmintrin.h seems to be x86-specific.

Please support building/running the tests on non-x86 architectures.

Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1053328 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/pycryptodome/+bug/2039968

Bl4omArchie commented 6 months ago

Hello, indeed, AES New Instructions are specific to x86 architectures: https://en.wikipedia.org/wiki/AES_instruction_set#Supporting_x86_CPUs It is because instructions are implemented within your processor. If your request hasn't been fulfilled, I can look at the code and fix it for your architectures.

Legrandin commented 6 months ago

This is fixed in master

bdrung commented 6 months ago

Are you referring to those three commits?

Bl4omArchie commented 6 months ago

yes, did it solved your issue ?

bdrung commented 6 months ago

I haven't tried yet, but I will next week.

Legrandin commented 6 months ago

This is fixed in v3.20.0.

bdrung commented 5 months ago

I just uploaded pycryptodome 3.20.0+dfsg-1 to Debian unstable. In the next hours we will see if the tests succeed on non-x86:

bdrung commented 5 months ago

pycryptodome 3.20.0+dfsg-1 builds on most architectures now. So the SSE/AES config changes work. I filed two bug reports for the remaining failures: