From 1d76e458803c8c3d4e00ab538c46af310580f214 Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Tue, 6 Jul 2021 11:04:25 +0200 Subject: [PATCH] [wolfssl] Import corpora from other projects (#6001) --- projects/wolfssl/Dockerfile | 10 ++++++++++ projects/wolfssl/build.sh | 25 ++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/projects/wolfssl/Dockerfile b/projects/wolfssl/Dockerfile index dd23a4e33..5b8f90c99 100644 --- a/projects/wolfssl/Dockerfile +++ b/projects/wolfssl/Dockerfile @@ -27,6 +27,16 @@ RUN git clone --depth 1 https://github.com/google/wycheproof.git RUN wget https://boostorg.jfrog.io/artifactory/main/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 +# Retrieve corpora from other projects +RUN wget https://storage.googleapis.com/pub/gsutil.tar.gz -O $SRC/gsutil.tar.gz +RUN tar zxf $SRC/gsutil.tar.gz +ENV PATH="${PATH}:$SRC/gsutil" +RUN gsutil cp gs://bearssl-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/bearssl_cryptofuzz-bearssl/public.zip $SRC/corpus_bearssl.zip +RUN gsutil cp gs://nettle-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/nettle_cryptofuzz-nettle-with-mini-gmp/public.zip $SRC/corpus_nettle.zip +RUN gsutil cp gs://libecc-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/libecc_cryptofuzz-libecc/public.zip $SRC/corpus_libecc.zip +RUN gsutil cp gs://relic-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/relic_cryptofuzz-relic/public.zip $SRC/corpus_relic.zip +RUN gsutil cp gs://cryptofuzz-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/cryptofuzz_cryptofuzz-openssl/public.zip $SRC/corpus_cryptofuzz.zip + WORKDIR wolfssl COPY build.sh $SRC/ diff --git a/projects/wolfssl/build.sh b/projects/wolfssl/build.sh index b052fca23..a1dbd65cb 100755 --- a/projects/wolfssl/build.sh +++ b/projects/wolfssl/build.sh @@ -202,16 +202,27 @@ then unset WOLFCRYPT_LIBWOLFSSL_A_PATH unset WOLFCRYPT_INCLUDE_PATH + mkdir $SRC/cryptofuzz-seed-corpus/ + # Convert Wycheproof test vectors to Cryptofuzz corpus format - mkdir $SRC/corpus-cryptofuzz-wycheproof/ - find $SRC/wycheproof/testvectors/ -type f -name 'ecdsa_*' -exec $SRC/cryptofuzz-disable-fastmath/cryptofuzz --from-wycheproof={},$SRC/corpus-cryptofuzz-wycheproof/ \; + find $SRC/wycheproof/testvectors/ -type f -name 'ecdsa_*' -exec $SRC/cryptofuzz-disable-fastmath/cryptofuzz --from-wycheproof={},$SRC/cryptofuzz-seed-corpus/ \; + + # Unpack corpora from other projects + unzip -n $SRC/corpus_bearssl.zip -d $SRC/cryptofuzz_seed_corpus/ + unzip -n $SRC/corpus_nettle.zip -d $SRC/cryptofuzz_seed_corpus/ + unzip -n $SRC/corpus_libecc.zip -d $SRC/cryptofuzz_seed_corpus/ + unzip -n $SRC/corpus_relic.zip -d $SRC/cryptofuzz_seed_corpus/ + unzip -n $SRC/corpus_cryptofuzz.zip -d $SRC/cryptofuzz_seed_corpus/ + # Pack it - zip -j $SRC/cryptofuzz_wycheproof_seed_corpus.zip $SRC/corpus-cryptofuzz-wycheproof/* + cd $SRC/cryptofuzz_seed_corpus + zip -r $SRC/cryptofuzz_seed_corpus.zip . + # Use it as the seed corpus for each Cryptofuzz-based fuzzer - cp $SRC/cryptofuzz_wycheproof_seed_corpus.zip $OUT/cryptofuzz-sp-math-all_seed_corpus.zip - cp $SRC/cryptofuzz_wycheproof_seed_corpus.zip $OUT/cryptofuzz-sp-math-all-8bit_seed_corpus.zip - cp $SRC/cryptofuzz_wycheproof_seed_corpus.zip $OUT/cryptofuzz-sp-math_seed_corpus.zip - cp $SRC/cryptofuzz_wycheproof_seed_corpus.zip $OUT/cryptofuzz-disable-fastmath_seed_corpus.zip + cp $SRC/cryptofuzz_seed_corpus.zip $OUT/cryptofuzz-sp-math-all_seed_corpus.zip + 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-disable-fastmath_seed_corpus.zip # Build SSL/SSH fuzzers NEW_SRC=$SRC/wolf-ssl-ssh-fuzzers/oss-fuzz/projects/wolf-ssl-ssh/