diff --git a/projects/libecc/Dockerfile b/projects/libecc/Dockerfile index b133361af..207099f93 100644 --- a/projects/libecc/Dockerfile +++ b/projects/libecc/Dockerfile @@ -18,6 +18,7 @@ FROM gcr.io/oss-fuzz-base/base-builder RUN apt-get update && apt-get install -y make autoconf automake libtool wget python bison flex texinfo lzip RUN git clone https://github.com/ANSSI-FR/libecc.git RUN git clone --depth 1 https://github.com/randombit/botan.git +RUN git clone https://github.com/wolfssl/wolfssl RUN git clone --depth 1 https://github.com/guidovranken/cryptofuzz RUN wget https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.74.0/source/boost_1_74_0.tar.bz2 diff --git a/projects/libecc/build.sh b/projects/libecc/build.sh index ba0cde644..e4ffff1c4 100755 --- a/projects/libecc/build.sh +++ b/projects/libecc/build.sh @@ -67,6 +67,25 @@ export CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_LIBGMP" export LIBGMP_INCLUDE_PATH=$(realpath .) export LIBGMP_A_PATH=$(realpath .libs/libgmp.a) +# Compile wolfSSL +cd $SRC/wolfssl/ +# Checkout at commit that's known to be bug-free +git checkout 4b0c8c07f42abc545761c2c775c6cf22599e9b05 +# Note (to self): +# Compiling wolfCrypt with SP math instead of normal math due to symbol collisions (specifically fp_* functions) between libecc and wolfCrypt otherwise. +export CFLAGS="$CFLAGS -DHAVE_AES_ECB -DWOLFSSL_DES_ECB -DHAVE_ECC_SECPR2 -DHAVE_ECC_SECPR3 -DHAVE_ECC_BRAINPOOL -DHAVE_ECC_KOBLITZ -DWOLFSSL_ECDSA_SET_K -DWOLFSSL_ECDSA_SET_K_ONE_LOOP -DWOLFSSL_SP_INT_NEGATIVE" +autoreconf -ivf +export WOLFCRYPT_CONFIGURE_PARAMS="--enable-static --enable-md2 --enable-md4 --enable-ripemd --enable-blake2 --enable-blake2s --enable-pwdbased --enable-scrypt --enable-hkdf --enable-cmac --enable-arc4 --enable-camellia --enable-aesccm --enable-aesctr --enable-xts --enable-des3 --enable-x963kdf --enable-harden --enable-aescfb --enable-aesofb --enable-aeskeywrap --enable-aessiv --enable-keygen --enable-curve25519 --enable-curve448 --enable-shake256 --disable-crypttests --disable-examples --enable-compkey --enable-ed448 --enable-ed25519 --enable-ecccustcurves --enable-xchacha --enable-cryptocb --enable-eccencrypt --enable-smallstack --enable-ed25519-stream --enable-ed448-stream --enable-sp-math-all" +if [[ $CFLAGS = *sanitize=memory* ]] +then + export WOLFCRYPT_CONFIGURE_PARAMS="$WOLFCRYPT_CONFIGURE_PARAMS -disable-asm" +fi +./configure $WOLFCRYPT_CONFIGURE_PARAMS +make -j$(nproc) +export CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_WOLFCRYPT" +export WOLFCRYPT_LIBWOLFSSL_A_PATH=`realpath src/.libs/libwolfssl.a` +export WOLFCRYPT_INCLUDE_PATH=`realpath .` + # Build Cryptofuzz cd $SRC/cryptofuzz python gen_repository.py @@ -84,6 +103,8 @@ cd ../botan/ make -B -j$(nproc) cd ../libgmp/ make -B -j$(nproc) +cd ../wolfcrypt/ +make -B -j$(nproc) cd ../../ make -B -j$(nproc)