diff --git a/projects/botan/Dockerfile b/projects/botan/Dockerfile new file mode 100644 index 000000000..7fa7afe33 --- /dev/null +++ b/projects/botan/Dockerfile @@ -0,0 +1,23 @@ +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +FROM ossfuzz/base-libfuzzer +MAINTAINER jack@randombit.net +RUN apt-get install -y make python +RUN git clone --depth 1 https://github.com/randombit/botan.git botan +WORKDIR botan +COPY build.sh $SRC/ +RUN ls -R $SRC/ diff --git a/projects/botan/build.sh b/projects/botan/build.sh new file mode 100755 index 000000000..38533f6a2 --- /dev/null +++ b/projects/botan/build.sh @@ -0,0 +1,43 @@ +#!/bin/bash -eu +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +cd $SRC/botan + +# This assumes $CC is set to either 'clang' or 'gcc' +./configure.py --cc=$CC --cc-bin=$CXX --cc-abi-flags="$CXXFLAGS" \ + --unsafe-fuzzer-mode --disable-shared +make -j$(nproc) libbotan-1.11.a + +jigs=$(find $SRC/botan/src/extra_tests/fuzzers/jigs -name "*.cpp") + +for fuzzer_src in $jigs; do + fuzzer_name=$(basename $fuzzer_src .cpp) + $CXX $CXXFLAGS -DUSE_LLVM_FUZZER -std=c++11 -I$SRC/botan/build/include \ + -o $OUT/$fuzzer_name $fuzzer_src -L$SRC/botan -lbotan-1.11 -lFuzzingEngine + + max_len=1024 # default max_len + if [ $fuzzer_name = 'ecc_bp256' ] || [ $fuzzer_name = 'ecc_p256' ] || [ $fuzzer_name = 'redc_p256' ]; then + max_len=64 + elif [ $fuzzer_name = 'ecc_p384' ] || [ $fuzzer_name = 'redc_p384' ]; then + max_len=96 + elif [ $fuzzer_name = 'ecc_p521' ] || [ $fuzzer_name = 'redc_p521' ]; then + max_len=132 + fi + + echo -en "[libfuzzer]\nmax_len = $max_len\n" > $OUT/${fuzzer_name}.options + +done