From bbc1aa0a9da1c25c5db91602e3f56fd6bd375108 Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Fri, 22 Jan 2021 16:06:02 +0100 Subject: [PATCH] [wolfssl] Add Botan to Cryptofuzz-based fuzzers for comparing outputs against (#5037) * [wolfssl] Add Botan to Cryptofuzz-based fuzzers for comparing outputs against * [wolfssl] Build Botan module in oracle mode For more information see: https://github.com/guidovranken/cryptofuzz/tree/master/modules/botan#using-botan-as-an-oracle --- projects/wolfssl/Dockerfile | 1 + projects/wolfssl/build.sh | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/projects/wolfssl/Dockerfile b/projects/wolfssl/Dockerfile index ed5e04631..39742cc7e 100644 --- a/projects/wolfssl/Dockerfile +++ b/projects/wolfssl/Dockerfile @@ -22,6 +22,7 @@ RUN git clone --depth 1 https://github.com/wolfSSL/wolfssh.git RUN git clone --depth 1 https://github.com/guidovranken/fuzzing-headers.git RUN git clone --depth 1 https://github.com/guidovranken/wolf-ssl-ssh-fuzzers RUN git clone --depth 1 https://github.com/guidovranken/cryptofuzz +RUN git clone --depth 1 https://github.com/randombit/botan.git RUN wget https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.tar.bz2 RUN git clone https://github.com/wolfssl/oss-fuzz-targets --depth 1 $SRC/fuzz-targets diff --git a/projects/wolfssl/build.sh b/projects/wolfssl/build.sh index aefa68372..c70005a34 100755 --- a/projects/wolfssl/build.sh +++ b/projects/wolfssl/build.sh @@ -78,6 +78,19 @@ then echo -n '--operations=BignumCalc,DH_GenerateKeyPair,DH_Derive,ECC_GenerateKeyPair,ECC_PrivateToPublic,ECC_ValidatePubkey,ECDSA_Verify,ECDSA_Sign' >>extra_options.h echo -n '"' >>extra_options.h + # Build Botan + export CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_BOTAN_IS_ORACLE" + cd $SRC/botan + if [[ $CFLAGS != *-m32* ]] + then + ./configure.py --cc-bin=$CXX --cc-abi-flags="$CXXFLAGS" --disable-shared --disable-modules=locking_allocator --build-targets=static --without-documentation + else + ./configure.py --cpu=x86_32 --cc-bin=$CXX --cc-abi-flags="$CXXFLAGS" --disable-shared --disable-modules=locking_allocator --build-targets=static --without-documentation + fi + make -j$(nproc) + export LIBBOTAN_A_PATH="$SRC/botan/libbotan-3.a" + export BOTAN_INCLUDE_PATH="$SRC/botan/build/include" + # Build sp-math-all fuzzer cp -R $SRC/cryptofuzz/ $SRC/cryptofuzz-sp-math-all/ cp -R $SRC/wolfssl/ $SRC/wolfssl-sp-math-all/ @@ -86,11 +99,13 @@ then 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-sp-math-all make -j$(nproc) - export CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_NO_OPENSSL -DCRYPTOFUZZ_WOLFCRYPT" + export CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_NO_OPENSSL -DCRYPTOFUZZ_WOLFCRYPT -DCRYPTOFUZZ_BOTAN" export WOLFCRYPT_LIBWOLFSSL_A_PATH="$SRC/wolfssl-sp-math-all/src/.libs/libwolfssl.a" export WOLFCRYPT_INCLUDE_PATH="$SRC/wolfssl-sp-math-all/" cd $SRC/cryptofuzz-sp-math-all/modules/wolfcrypt make -j$(nproc) + cd $SRC/cryptofuzz-sp-math-all/modules/botan + make -j$(nproc) cd $SRC/cryptofuzz-sp-math-all/ LIBFUZZER_LINK="$LIB_FUZZING_ENGINE" make -B -j$(nproc) cp cryptofuzz $OUT/cryptofuzz-sp-math-all @@ -107,11 +122,13 @@ then 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 --disable-fastmath make -j$(nproc) - export CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_NO_OPENSSL -DCRYPTOFUZZ_WOLFCRYPT" + export CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_NO_OPENSSL -DCRYPTOFUZZ_WOLFCRYPT -DCRYPTOFUZZ_BOTAN" export WOLFCRYPT_LIBWOLFSSL_A_PATH="$SRC/wolfssl-disable-fastmath/src/.libs/libwolfssl.a" export WOLFCRYPT_INCLUDE_PATH="$SRC/wolfssl-disable-fastmath/" cd $SRC/cryptofuzz-disable-fastmath/modules/wolfcrypt make -j$(nproc) + cd $SRC/cryptofuzz-disable-fastmath/modules/botan + make -j$(nproc) cd $SRC/cryptofuzz-disable-fastmath/ LIBFUZZER_LINK="$LIB_FUZZING_ENGINE" make -B -j$(nproc) cp cryptofuzz $OUT/cryptofuzz-disable-fastmath