[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
This commit is contained in:
Guido Vranken 2021-01-22 16:06:02 +01:00 committed by GitHub
parent 8fcb4659e3
commit bbc1aa0a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -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

View File

@ -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