From f9d23f5297269520745323a014cb179f29cda476 Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Thu, 15 Apr 2021 18:34:32 +0200 Subject: [libecc] Add project libecc (#5613) --- projects/libecc/Dockerfile | 23 ++++++++++++++ projects/libecc/build.sh | 72 ++++++++++++++++++++++++++++++++++++++++++++ projects/libecc/project.yaml | 13 ++++++++ 3 files changed, 108 insertions(+) create mode 100644 projects/libecc/Dockerfile create mode 100755 projects/libecc/build.sh create mode 100644 projects/libecc/project.yaml (limited to 'projects/libecc') diff --git a/projects/libecc/Dockerfile b/projects/libecc/Dockerfile new file mode 100644 index 00000000..415478ef --- /dev/null +++ b/projects/libecc/Dockerfile @@ -0,0 +1,23 @@ +# Copyright 2021 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 +RUN apt-get update && apt-get install -y make autoconf automake libtool wget python +RUN git clone https://github.com/ANSSI-FR/libecc.git +RUN git clone --depth 1 https://github.com/randombit/botan.git +RUN git clone --depth 1 https://github.com/guidovranken/cryptofuzz +RUN wget https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.tar.bz2 +COPY build.sh $SRC/ diff --git a/projects/libecc/build.sh b/projects/libecc/build.sh new file mode 100755 index 00000000..22cccbc7 --- /dev/null +++ b/projects/libecc/build.sh @@ -0,0 +1,72 @@ +#!/bin/bash -eu +# Copyright 2021 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" +export LIBFUZZER_LINK="$LIB_FUZZING_ENGINE" + +# 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/ + +# Prevent Boost compilation error with -std=c++17 +export CXXFLAGS="$CXXFLAGS -D_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR" + +# Build libecc +cd $SRC/libecc +git checkout cryptofuzz +export CFLAGS="$CFLAGS -DUSE_CRYPTOFUZZ" +make -j$(nproc) build/libsign.a +export LIBECC_PATH=$(realpath .) +export CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_LIBECC" + +# 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" + +# Build Cryptofuzz +cd $SRC/cryptofuzz +python gen_repository.py +rm extra_options.h +echo -n '"' >>extra_options.h +echo -n '--force-module=libecc ' >>extra_options.h +echo -n '--operations=Digest,ECC_PrivateToPublic,ECDSA_Sign,ECDSA_Verify,BignumCalc ' >>extra_options.h +echo -n '--curves=brainpool224r1,brainpool256r1,brainpool384r1,brainpool512r1,secp192r1,secp224r1,secp256r1,secp384r1,secp521r1 ' >>extra_options.h +echo -n '--digests=NULL,SHA224,SHA256,SHA3-224,SHA3-256,SHA3-384,SHA3-512,SHA384,SHA512,SHA512-224,SHA512-256 ' >>extra_options.h +echo -n '--calcops=Add,AddMod,And,Bit,GCD,InvMod,IsOdd,IsOne,IsZero,LShift1,Mod,Mul,MulMod,NumBits,Or,RShift,Sqr,Sub,SubMod,Xor ' >>extra_options.h +echo -n '"' >>extra_options.h +cd modules/libecc/ +make -B -j$(nproc) +cd ../botan/ +make -B -j$(nproc) +cd ../../ +make -B -j$(nproc) + +cp cryptofuzz $OUT/cryptofuzz-libecc diff --git a/projects/libecc/project.yaml b/projects/libecc/project.yaml new file mode 100644 index 00000000..6e295ed5 --- /dev/null +++ b/projects/libecc/project.yaml @@ -0,0 +1,13 @@ +homepage: "https://github.com/ANSSI-FR/libecc" +language: c++ +primary_contact: "guidovranken@gmail.com" +main_repo: "https://github.com/ANSSI-FR/libecc.git" +auto_ccs: + - "dev.libecc@gmail.com" +sanitizers: + - address + - undefined + - memory +architectures: + - x86_64 + - i386 -- cgit v1.2.3