[libressl] Add libgmp, Botan (#8403)

This commit is contained in:
Guido Vranken 2022-09-05 08:01:56 +02:00 committed by GitHub
parent 37cf22b6c7
commit f72a0a659a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 1 deletions

View File

@ -17,12 +17,14 @@
# Held back because of github.com/google/oss-fuzz/pull/8313
# Please fix failure and upgrade.
FROM gcr.io/oss-fuzz-base/base-builder@sha256:111d6b9d3a52bd3392602c71dc8936c628607a7a9bc86d381db7586f9b1e840f
RUN apt-get update && apt-get install -y make cmake wget
RUN apt-get update && apt-get install -y make cmake wget autoconf automake libtool bison flex texinfo lzip
RUN git clone --depth 1 https://github.com/libressl-portable/portable.git libressl
RUN git clone --depth 1 https://github.com/libressl-portable/fuzz.git libressl.fuzzers
RUN git clone --depth 1 https://github.com/guidovranken/cryptofuzz
RUN git clone --depth 1 https://github.com/guidovranken/cryptofuzz-corpora
RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.74.0/source/boost_1_74_0.tar.bz2
RUN git clone --depth 1 https://github.com/randombit/botan.git
RUN wget https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz
WORKDIR libressl
RUN ./update.sh
COPY build.sh *.options $SRC/

View File

@ -74,11 +74,52 @@ if [[ $CFLAGS = *sanitize=memory* ]]
then
export CXXFLAGS="$CXXFLAGS -DMSAN"
fi
# Build Botan
cd $SRC/botan
if [[ $CFLAGS != *-m32* ]]
then
./configure.py --cc-bin=$CXX --cc-abi-flags="$CXXFLAGS" --disable-shared --disable-modules=locking_allocator,x509,tls --build-targets=static --without-documentation
else
./configure.py --cpu=x86_32 --cc-bin=$CXX --cc-abi-flags="$CXXFLAGS" --disable-shared --disable-modules=locking_allocator,x509,tls --build-targets=static --without-documentation
fi
make -j$(nproc)
export CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_BOTAN -DCRYPTOFUZZ_BOTAN_IS_ORACLE"
export LIBBOTAN_A_PATH="$SRC/botan/libbotan-3.a"
export BOTAN_INCLUDE_PATH="$SRC/botan/build/include"
# Compile libgmp
cd $SRC/
tar --lzip -xvf gmp-6.2.1.tar.lz
cd $SRC/gmp-6.2.1/
autoreconf -ivf
if [[ $CFLAGS = *-m32* ]]
then
setarch i386 ./configure --enable-maintainer-mode --enable-assert
elif [[ $CFLAGS = *sanitize=memory* ]]
then
./configure --enable-maintainer-mode --enable-assert --disable-assembly
else
./configure --enable-maintainer-mode --enable-assert
fi
make -j$(nproc)
export CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_LIBGMP"
export LIBGMP_INCLUDE_PATH=$(realpath .)
export LIBGMP_A_PATH=$(realpath .libs/libgmp.a)
cd $SRC/cryptofuzz/
# Generate lookup tables
python3 gen_repository.py
# Compile Cryptofuzz LibreSSL module
cd $SRC/cryptofuzz/modules/openssl
OPENSSL_INCLUDE_PATH="$SRC/libressl/include" OPENSSL_LIBCRYPTO_A_PATH="$WORK/libressl/crypto/libcrypto.a" CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_LIBRESSL" make
# Compile Cryptofuzz libgmp module
cd ../libgmp/
make -B -j$(nproc)
# Compile Cryptofuzz Botan module
cd ../botan/
make -B -f Makefile-oracle -j$(nproc)
# Compile Cryptofuzz
cd $SRC/cryptofuzz/
LIBFUZZER_LINK="$LIB_FUZZING_ENGINE" CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_LIBRESSL -I $SRC/libressl/include" make -j$(nproc)