ph4r05 / Whitebox-crypto-AES

Whitebox AES implementation in C++. Chow, Karroumi.
https://is.muni.cz/th/325219/fi_m/
337 stars 112 forks source link

Build fails in Debian container #5

Closed edermi closed 8 years ago

edermi commented 8 years ago

I'm trying to build the whitebox in a Debian docker container.

All required boost libraries, git, cmake, wget and build-essentials are installed. Unfortunately linking fails:

root@c8510048fa43:/Whitebox-crypto-AES# make
[  4%] Building CXX object CMakeFiles/main.dir/base.cpp.o
[  8%] Building CXX object CMakeFiles/main.dir/BGEAttack.cpp.o
[ 12%] Building CXX object CMakeFiles/main.dir/BGEAttack_test.cpp.o
[ 16%] Building CXX object CMakeFiles/main.dir/GenericAES.cpp.o
[ 20%] Building CXX object CMakeFiles/main.dir/LinearAffineEq.cpp.o
[ 25%] Building CXX object CMakeFiles/main.dir/LinearAffineEq_test.cpp.o
[ 29%] Building C object CMakeFiles/main.dir/md5.c.o
[ 33%] Building CXX object CMakeFiles/main.dir/MixingBijections.cpp.o
[ 37%] Building CXX object CMakeFiles/main.dir/NTLUtils.cpp.o
[ 41%] Building CXX object CMakeFiles/main.dir/WBAES.cpp.o
[ 45%] Building CXX object CMakeFiles/main.dir/WBAESGenerator.cpp.o
[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
Linking CXX executable main
CMakeFiles/main.dir/BGEAttack.cpp.o: In function `NTL::MemoryError()':
BGEAttack.cpp:(.text._ZN3NTL11MemoryErrorEv[_ZN3NTL11MemoryErrorEv]+0xa): undefined reference to `NTL::TerminalError(char const*)'
CMakeFiles/main.dir/BGEAttack.cpp.o: In function `NTL::LogicError(char const*)':
BGEAttack.cpp:(.text._ZN3NTL10LogicErrorEPKc[_ZN3NTL10LogicErrorEPKc]+0x14): undefined reference to `NTL::TerminalError(char const*)'
CMakeFiles/main.dir/BGEAttack.cpp.o: In function `NTL::ResourceError(char const*)':
BGEAttack.cpp:(.text._ZN3NTL13ResourceErrorEPKc[_ZN3NTL13ResourceErrorEPKc]+0x14): undefined reference to `NTL::TerminalError(char const*)'
CMakeFiles/main.dir/BGEAttack.cpp.o: In function `NTL::Mat<NTL::GF2>::Mat(NTL::Mat<NTL::GF2> const&)':
BGEAttack.cpp:(.text._ZN3NTL3MatINS_3GF2EEC2ERKS2_[_ZN3NTL3MatINS_3GF2EEC5ERKS2_]+0x65): undefined reference to `NTL::Vec<NTL::GF2>::FixAtCurrentLength()'
CMakeFiles/main.dir/BGEAttack.cpp.o: In function `NTL::Mat<NTL::GF2>::operator=(NTL::Mat<NTL::GF2> const&)':
BGEAttack.cpp:(.text._ZN3NTL3MatINS_3GF2EEaSERKS2_[_ZN3NTL3MatINS_3GF2EEaSERKS2_]+0x11c): undefined reference to `NTL::Vec<NTL::GF2>::FixAtCurrentLength()'
CMakeFiles/main.dir/MixingBijections.cpp.o: In function `NTL::Error(char const*)':
MixingBijections.cpp:(.text._ZN3NTL5ErrorEPKc[_ZN3NTL5ErrorEPKc]+0x14): undefined reference to `NTL::TerminalError(char const*)'
CMakeFiles/main.dir/MixingBijections.cpp.o: In function `NTL::GF2X::swap(NTL::GF2X&)':
MixingBijections.cpp:(.text._ZN3NTL4GF2X4swapERS0_[_ZN3NTL4GF2X4swapERS0_]+0x1f): undefined reference to `NTL::WordVector::swap(NTL::WordVector&)'
collect2: error: ld returned 1 exit status
CMakeFiles/main.dir/build.make:365: recipe for target 'main' failed
make[2]: *** [main] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/main.dir/all' failed
make[1]: *** [CMakeFiles/main.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2

I cloned the repo, ran the ntl-installer, cmake . and make.

g++ version is 4.9.2 binutils 2.25 ntl 9.6.2

Am I missing something?

ph4r05 commented 8 years ago

Hello,

thanks for interest in my repo.

The thing is you are probably missing NTL library or it is not configured properly (linker is not able to find NTL symbols) NTL install script is configured to work with Travis CI. In this environment the build works.

Maybe just try to install NTL by hand by executing install-ntl.sh It should get installed to /usr/local

Please check that out, if it is correct.

edermi commented 8 years ago

Hi,

libntl-dev from the repositories was installed. I also ran install-ntl.sh before running cmake. The ntl build was succesfull (or at least I didn't see any errors).

Is it possible to provide a download of the binary created by Travis CI?

ph4r05 commented 8 years ago

Could you please check where is libntl.a or libntl.so installed? I've added /usr to search paths in Cmake config, can you try it again?

ph4r05 commented 8 years ago

And another thing: you've mentioned you installed libntl-dev from repositories. What is the particular version of this NTL lib? It can be too old and it could take precedence before that one installed manually.

For this purpose try running install-ntl-cached.sh to install NTL to your home directory. This exact script is used in Travis CI and it works with it. It should be taken in preference to the system one.

edermi commented 8 years ago

The version from the repo is 6.2.1-1 which seems horribly outdated?

Your latest git commit fixed it, everything works fine now :) Thanks for your quick response and fix.