2018-06-08 18:07:56 +00:00
|
|
|
#!/bin/bash -eu
|
|
|
|
# Copyright 2018 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.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# build projects
|
2018-08-23 09:47:30 +00:00
|
|
|
#nettle
|
|
|
|
(
|
|
|
|
cd nettle
|
|
|
|
tar -xvf ../gmp-6.1.2.tar.bz2
|
|
|
|
cd gmp-6.1.2
|
2018-08-24 16:46:54 +00:00
|
|
|
#do not use assembly instructions as we do not know if they will be available on the machine who will run the fuzzer
|
|
|
|
#we could do instead --enable-fat
|
|
|
|
./configure --disable-assembly
|
2018-08-23 09:47:30 +00:00
|
|
|
make
|
|
|
|
make install
|
|
|
|
cd ..
|
|
|
|
autoreconf
|
|
|
|
./configure
|
|
|
|
make
|
|
|
|
)
|
|
|
|
|
2018-08-10 14:53:09 +00:00
|
|
|
#cryptopp
|
|
|
|
(
|
|
|
|
cd cryptopp
|
|
|
|
make
|
|
|
|
)
|
|
|
|
|
2018-08-09 16:26:47 +00:00
|
|
|
#gcrypt
|
|
|
|
(
|
|
|
|
cd gcrypt
|
2019-09-13 16:52:40 +00:00
|
|
|
tar -xvf ../libgpg-error-1.36.tar.bz2
|
|
|
|
cd libgpg-error-1.36
|
2018-08-09 16:26:47 +00:00
|
|
|
./configure --enable-static --disable-shared
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cd ..
|
|
|
|
./autogen.sh
|
|
|
|
./configure --enable-static --disable-shared --disable-doc --enable-maintainer-mode
|
|
|
|
make
|
|
|
|
)
|
|
|
|
|
2018-06-08 18:07:56 +00:00
|
|
|
#mbedtls
|
|
|
|
(
|
|
|
|
cd mbedtls
|
|
|
|
cmake . -DENABLE_PROGRAMS=0 -DENABLE_TESTING=0
|
|
|
|
make -j$(nproc) all
|
|
|
|
)
|
|
|
|
|
|
|
|
#openssl
|
|
|
|
(
|
|
|
|
cd openssl
|
2018-08-09 16:26:47 +00:00
|
|
|
#option to not have the same exported function poly1305_blocks as in gcrypt
|
2018-10-14 17:03:11 +00:00
|
|
|
./config no-poly1305 no-shared no-threads
|
2018-06-08 18:07:56 +00:00
|
|
|
make build_generated libcrypto.a
|
|
|
|
)
|
|
|
|
|
|
|
|
#libecc
|
|
|
|
(
|
|
|
|
cd libecc
|
|
|
|
#required by libecc
|
|
|
|
(export CFLAGS="$CFLAGS -fPIC"; make)
|
|
|
|
)
|
|
|
|
|
2019-09-13 16:52:40 +00:00
|
|
|
#botan
|
|
|
|
(
|
|
|
|
cd botan
|
|
|
|
#help it find libstdc++
|
|
|
|
cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/x86_64-linux-gnu/libstdc++.so
|
|
|
|
export LDFLAGS=$CXXFLAGS
|
|
|
|
./configure.py --disable-shared-library
|
|
|
|
make
|
|
|
|
)
|
|
|
|
|
2018-06-08 18:07:56 +00:00
|
|
|
#build fuzz target
|
|
|
|
cd ecfuzzer
|
2018-08-09 16:26:47 +00:00
|
|
|
zip -r fuzz_ec_seed_corpus.zip corpus/
|
|
|
|
cp fuzz_ec_seed_corpus.zip $OUT/
|
2018-06-12 05:07:46 +00:00
|
|
|
cp fuzz_ec.dict $OUT/
|
2018-08-09 16:26:47 +00:00
|
|
|
|
2018-06-08 18:07:56 +00:00
|
|
|
$CC $CFLAGS -I. -c fuzz_ec.c -o fuzz_ec.o
|
2019-08-26 14:25:38 +00:00
|
|
|
$CC $CFLAGS -I. -I../mbedtls/include -I../mbedtls/crypto/include -c modules/mbedtls.c -o mbedtls.o
|
2018-06-08 18:07:56 +00:00
|
|
|
$CC $CFLAGS -I. -I../openssl/include -c modules/openssl.c -o openssl.o
|
|
|
|
$CC $CFLAGS -DWITH_STDLIB -I. -I../libecc/src -c modules/libecc.c -o libecc.o
|
2018-08-09 16:26:47 +00:00
|
|
|
$CC $CFLAGS -I. -I../gcrypt/src -c modules/gcrypt.c -o gcrypt.o
|
2018-08-10 14:53:09 +00:00
|
|
|
$CXX $CXXFLAGS -I. -I../ -c modules/cryptopp.cpp -o cryptopp.o
|
2018-08-23 09:47:30 +00:00
|
|
|
$CC $CFLAGS -I. -I../ -c modules/nettle.c -o nettle.o
|
2019-09-13 16:52:40 +00:00
|
|
|
$CXX $CXXFLAGS -std=c++11 -I. -I../ -I../botan/build/include -c modules/botan.cpp -o botan.o
|
2018-06-08 18:07:56 +00:00
|
|
|
|
2019-09-13 16:52:40 +00:00
|
|
|
$CXX $CXXFLAGS fuzz_ec.o mbedtls.o libecc.o openssl.o gcrypt.o cryptopp.o nettle.o botan.o -o $OUT/fuzz_ec ../mbedtls/crypto/library/libmbedcrypto.a ../libecc/build/libec.a ../libecc/src/external_deps/rand.o ../openssl/libcrypto.a ../nettle/libhogweed.a ../nettle/libnettle.a ../nettle/gmp-6.1.2/.libs/libgmp.a ../gcrypt/src/.libs/libgcrypt.a ../cryptopp/libcryptopp.a ../botan/libbotan-2.a -lgpg-error $LIB_FUZZING_ENGINE
|