From 5eb069e6f0bbcac2b386b95ce259d0fa8ded470d Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Thu, 10 Feb 2022 20:03:29 +0100 Subject: [PATCH 1/5] [circl] Project integration --- projects/circl/Dockerfile | 27 ++++++++++++ projects/circl/build.sh | 82 +++++++++++++++++++++++++++++++++++++ projects/circl/project.yaml | 12 ++++++ 3 files changed, 121 insertions(+) create mode 100644 projects/circl/Dockerfile create mode 100755 projects/circl/build.sh create mode 100644 projects/circl/project.yaml diff --git a/projects/circl/Dockerfile b/projects/circl/Dockerfile new file mode 100644 index 00000000000..0af6c24e021 --- /dev/null +++ b/projects/circl/Dockerfile @@ -0,0 +1,27 @@ +# Copyright 2022 Google LLC +# +# 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 gcr.io/oss-fuzz-base/base-builder-go + +ENV GO111MODULE off + +RUN apt-get update && apt-get install -y make autoconf automake libtool wget +RUN git clone --depth 1 https://github.com/guidovranken/cryptofuzz +RUN git clone --depth 1 https://github.com/randombit/botan.git +RUN git clone --depth 1 https://github.com/supranational/blst.git +RUN cd $SRC/cryptofuzz/modules/circl && go get ./... || true +RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.74.0/source/boost_1_74_0.tar.bz2 +COPY build.sh $SRC/ diff --git a/projects/circl/build.sh b/projects/circl/build.sh new file mode 100755 index 00000000000..e5d11d160ea --- /dev/null +++ b/projects/circl/build.sh @@ -0,0 +1,82 @@ +#!/bin/bash -eu +# Copyright 2022 Google LLC +# +# 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. +# +################################################################################ + +export CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_NO_OPENSSL -DCRYPTOFUZZ_CIRCL" +export LIBFUZZER_LINK="$LIB_FUZZING_ENGINE" +export LINK_FLAGS="" + +# Install Boost headers +cd $SRC/ +tar jxf boost_1_74_0.tar.bz2 +cd boost_1_74_0/ +CFLAGS="" CXXFLAGS="" ./bootstrap.sh +CFLAGS="" CXXFLAGS="" ./b2 headers +cp -R boost/ /usr/include/ + +# Configure Cryptofuzz +cd $SRC/cryptofuzz/ +python gen_repository.py +echo -n '"' >>extra_options.h +echo -n "--force-module=circl " >>extra_options.h +echo -n "--curves=secp384r1,bls12_381 " >>extra_options.h +echo -n "--operations=" >>extra_options.h +echo -n "ECC_PrivateToPublic," >>extra_options.h +echo -n "ECC_Point_Add," >>extra_options.h +echo -n "ECC_Point_Mul," >>extra_options.h +echo -n "ECC_Point_Dbl," >>extra_options.h +echo -n "BLS_PrivateToPublic," >>extra_options.h +echo -n "BLS_G1_Add," >>extra_options.h +echo -n "BLS_G1_Mul," >>extra_options.h +echo -n "BLS_G1_Neg," >>extra_options.h +echo -n "BLS_IsG1OnCurve," >>extra_options.h +echo -n "BLS_Compress_G1," >>extra_options.h +echo -n "BLS_Decompress_G1," >>extra_options.h +echo -n "BignumCalc_Mod_BLS12_381_P," >>extra_options.h +echo -n "BignumCalc_Mod_BLS12_381_R" >>extra_options.h +echo -n '"' >>extra_options.h + +# Build Botan +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 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" +cd $SRC/cryptofuzz/modules/botan/ +make -f Makefile-oracle -j $(nproc) + +# Build blst +cd $SRC/blst/ +./build.sh +export BLST_LIBBLST_A_PATH=$(realpath libblst.a) +export BLST_INCLUDE_PATH=$(realpath bindings/) +export CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_BLST" +cd $SRC/cryptofuzz/modules/blst/ +make -j $(nproc) + +cd $SRC/cryptofuzz/modules/circl/ +make -j $(nproc) + +cd $SRC/cryptofuzz/ +make -j $(nproc) + +cp cryptofuzz $OUT/ diff --git a/projects/circl/project.yaml b/projects/circl/project.yaml new file mode 100644 index 00000000000..c4e3e78a673 --- /dev/null +++ b/projects/circl/project.yaml @@ -0,0 +1,12 @@ +homepage: "https://github.com/cloudflare/circl" +language: c++ +primary_contact: "guidovranken@gmail.com" +main_repo: "https://github.com/cloudflare/circl.git" +auto_ccs: + - "armfazh@cloudflare.com" + - "chriswood@cloudflare.com" + - "bas@cloudflare.com" +sanitizers: + - address +architectures: + - x86_64 From dd5f0a1c034be66108422857a90ae4abe4c92bce Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Sun, 13 Feb 2022 22:21:18 +0100 Subject: [PATCH 2/5] [circl] Enable more operations --- projects/circl/build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/circl/build.sh b/projects/circl/build.sh index e5d11d160ea..b96a586fabd 100755 --- a/projects/circl/build.sh +++ b/projects/circl/build.sh @@ -43,8 +43,12 @@ echo -n "BLS_G1_Add," >>extra_options.h echo -n "BLS_G1_Mul," >>extra_options.h echo -n "BLS_G1_Neg," >>extra_options.h echo -n "BLS_IsG1OnCurve," >>extra_options.h +echo -n "BLS_G2_Add," >>extra_options.h +echo -n "BLS_G2_Mul," >>extra_options.h +echo -n "BLS_G2_Neg," >>extra_options.h echo -n "BLS_Compress_G1," >>extra_options.h echo -n "BLS_Decompress_G1," >>extra_options.h +echo -n "BLS_Pairing," >>extra_options.h echo -n "BignumCalc_Mod_BLS12_381_P," >>extra_options.h echo -n "BignumCalc_Mod_BLS12_381_R" >>extra_options.h echo -n '"' >>extra_options.h From d2f3bf6e310e97665d6830a2a6c455f7cbfd8431 Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Mon, 14 Feb 2022 11:00:13 +0100 Subject: [PATCH 3/5] [circl] Enable more operations --- projects/circl/build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/circl/build.sh b/projects/circl/build.sh index b96a586fabd..18b19d35c5c 100755 --- a/projects/circl/build.sh +++ b/projects/circl/build.sh @@ -43,9 +43,12 @@ echo -n "BLS_G1_Add," >>extra_options.h echo -n "BLS_G1_Mul," >>extra_options.h echo -n "BLS_G1_Neg," >>extra_options.h echo -n "BLS_IsG1OnCurve," >>extra_options.h +echo -n "BLS_HashToG1," >>extra_options.h echo -n "BLS_G2_Add," >>extra_options.h echo -n "BLS_G2_Mul," >>extra_options.h echo -n "BLS_G2_Neg," >>extra_options.h +echo -n "BLS_IsG2OnCurve," >>extra_options.h +echo -n "BLS_HashToG2," >>extra_options.h echo -n "BLS_Compress_G1," >>extra_options.h echo -n "BLS_Decompress_G1," >>extra_options.h echo -n "BLS_Pairing," >>extra_options.h From 5b3842c78516582597e64932ebc41c4e815af9c5 Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Mon, 14 Feb 2022 11:13:50 +0100 Subject: [PATCH 4/5] [circl] Retrieve seed corpus from bls-signatures project --- projects/circl/Dockerfile | 5 +++++ projects/circl/build.sh | 2 ++ 2 files changed, 7 insertions(+) diff --git a/projects/circl/Dockerfile b/projects/circl/Dockerfile index 0af6c24e021..771de0e706f 100644 --- a/projects/circl/Dockerfile +++ b/projects/circl/Dockerfile @@ -24,4 +24,9 @@ RUN git clone --depth 1 https://github.com/randombit/botan.git RUN git clone --depth 1 https://github.com/supranational/blst.git RUN cd $SRC/cryptofuzz/modules/circl && go get ./... || true RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.74.0/source/boost_1_74_0.tar.bz2 +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://bls-signatures-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/bls-signatures_cryptofuzz-bls-signatures/public.zip $SRC/cryptofuzz_seed_corpus.zip + COPY build.sh $SRC/ diff --git a/projects/circl/build.sh b/projects/circl/build.sh index 18b19d35c5c..2e7e146a4c0 100755 --- a/projects/circl/build.sh +++ b/projects/circl/build.sh @@ -87,3 +87,5 @@ cd $SRC/cryptofuzz/ make -j $(nproc) cp cryptofuzz $OUT/ + +cp $SRC/cryptofuzz_seed_corpus.zip $OUT/ From 1ca9c7d157d70fa2996b9fce4a281601de298198 Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Mon, 14 Feb 2022 16:50:18 +0100 Subject: [PATCH 5/5] [circl] Enable more operations --- projects/circl/build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/circl/build.sh b/projects/circl/build.sh index 2e7e146a4c0..bdbedcf6b5d 100755 --- a/projects/circl/build.sh +++ b/projects/circl/build.sh @@ -42,11 +42,14 @@ echo -n "BLS_PrivateToPublic," >>extra_options.h echo -n "BLS_G1_Add," >>extra_options.h echo -n "BLS_G1_Mul," >>extra_options.h echo -n "BLS_G1_Neg," >>extra_options.h +echo -n "BLS_G1_IsEq," >>extra_options.h echo -n "BLS_IsG1OnCurve," >>extra_options.h echo -n "BLS_HashToG1," >>extra_options.h +echo -n "BLS_PrivateToPublic_G2," >>extra_options.h echo -n "BLS_G2_Add," >>extra_options.h echo -n "BLS_G2_Mul," >>extra_options.h echo -n "BLS_G2_Neg," >>extra_options.h +echo -n "BLS_G2_IsEq," >>extra_options.h echo -n "BLS_IsG2OnCurve," >>extra_options.h echo -n "BLS_HashToG2," >>extra_options.h echo -n "BLS_Compress_G1," >>extra_options.h