diff --git a/projects/wolfssl/Dockerfile b/projects/wolfssl/Dockerfile index 2cf71fb06..46fe70f82 100644 --- a/projects/wolfssl/Dockerfile +++ b/projects/wolfssl/Dockerfile @@ -18,7 +18,7 @@ # Please fix failure and upgrade. FROM gcr.io/oss-fuzz-base/base-builder@sha256:111d6b9d3a52bd3392602c71dc8936c628607a7a9bc86d381db7586f9b1e840f -RUN apt-get update && apt-get install -y make autoconf automake libtool zip wget python bsdmainutils +RUN apt-get update && apt-get install -y make autoconf automake libtool zip wget python bsdmainutils libcrypt-dev:i386 RUN git clone https://github.com/wolfssl/wolfssl --depth 1 $SRC/wolfssl RUN git clone --depth 1 https://github.com/wolfSSL/wolfssh.git RUN git clone --depth 1 https://github.com/guidovranken/fuzzing-headers.git diff --git a/projects/wolfssl/build.sh b/projects/wolfssl/build.sh index db95adace..6c768707f 100755 --- a/projects/wolfssl/build.sh +++ b/projects/wolfssl/build.sh @@ -87,6 +87,7 @@ then # Configure Cryptofuzz cd $SRC/cryptofuzz/ python gen_repository.py + rm extra_options.h echo -n '"' >>extra_options.h echo -n '--force-module=wolfCrypt ' >>extra_options.h @@ -245,6 +246,29 @@ then unset WOLFCRYPT_LIBWOLFSSL_A_PATH unset WOLFCRYPT_INCLUDE_PATH + # Build heapmath fuzzer + cp -R $SRC/cryptofuzz/ $SRC/cryptofuzz-heapmath/ + cp -R $SRC/wolfssl/ $SRC/wolfssl-heapmath/ + cd $SRC/wolfssl-heapmath/ + autoreconf -ivf + 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" + ./configure $WOLFCRYPT_CONFIGURE_PARAMS --enable-heapmath + make -j$(nproc) + export CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_NO_OPENSSL -DCRYPTOFUZZ_WOLFCRYPT -DCRYPTOFUZZ_BOTAN" + export WOLFCRYPT_LIBWOLFSSL_A_PATH="$SRC/wolfssl-heapmath/src/.libs/libwolfssl.a" + export WOLFCRYPT_INCLUDE_PATH="$SRC/wolfssl-heapmath/" + cd $SRC/cryptofuzz-heapmath/modules/wolfcrypt + make -j$(nproc) + cd $SRC/cryptofuzz-heapmath/modules/botan + make -j$(nproc) + cd $SRC/cryptofuzz-heapmath/ + LIBFUZZER_LINK="$LIB_FUZZING_ENGINE" make -B -j$(nproc) + cp cryptofuzz $OUT/cryptofuzz-heapmath + CFLAGS="$OLD_CFLAGS" + CXXFLAGS="$OLD_CXXFLAGS" + unset WOLFCRYPT_LIBWOLFSSL_A_PATH + unset WOLFCRYPT_INCLUDE_PATH + mkdir $SRC/cryptofuzz-seed-corpus/ # Convert Wycheproof test vectors to Cryptofuzz corpus format @@ -298,7 +322,7 @@ then # Pack it cd $SRC/cryptofuzz_seed_corpus - zip -r $SRC/cryptofuzz_seed_corpus.zip . + zip -r $SRC/cryptofuzz_seed_corpus.zip . >/dev/null # Use it as the seed corpus for each Cryptofuzz-based fuzzer cp $SRC/cryptofuzz_seed_corpus.zip $OUT/cryptofuzz-normal-math_seed_corpus.zip @@ -306,6 +330,7 @@ then cp $SRC/cryptofuzz_seed_corpus.zip $OUT/cryptofuzz-sp-math-all-8bit_seed_corpus.zip cp $SRC/cryptofuzz_seed_corpus.zip $OUT/cryptofuzz-sp-math_seed_corpus.zip cp $SRC/cryptofuzz_seed_corpus.zip $OUT/cryptofuzz-fastmath_seed_corpus.zip + cp $SRC/cryptofuzz_seed_corpus.zip $OUT/cryptofuzz-heapmath_seed_corpus.zip # Remove files that are no longer needed to prevent running out of disk space rm -rf $SRC/botan-p256-corpus/