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
|
2020-02-14 15:36:56 +00:00
|
|
|
./configure --disable-shared --disable-assembly
|
|
|
|
make -j$(nproc)
|
2018-08-23 09:47:30 +00:00
|
|
|
make install
|
|
|
|
cd ..
|
|
|
|
autoreconf
|
2020-06-02 20:47:21 +00:00
|
|
|
./configure --disable-shared --disable-openssl
|
2020-02-14 15:36:56 +00:00
|
|
|
make -j$(nproc)
|
|
|
|
make install
|
2018-08-23 09:47:30 +00:00
|
|
|
)
|
|
|
|
|
2018-08-10 14:53:09 +00:00
|
|
|
#cryptopp
|
|
|
|
(
|
|
|
|
cd cryptopp
|
2020-02-14 15:36:56 +00:00
|
|
|
make -j$(nproc)
|
|
|
|
make install
|
2018-08-10 14:53:09 +00:00
|
|
|
)
|
|
|
|
|
2018-08-09 16:26:47 +00:00
|
|
|
#gcrypt
|
|
|
|
(
|
2019-11-15 20:02:46 +00:00
|
|
|
cd libgpg-error
|
|
|
|
./autogen.sh
|
|
|
|
if [ "$ARCHITECTURE" = 'i386' ]; then
|
|
|
|
./configure -host=i386 --disable-doc --enable-static --disable-shared
|
|
|
|
else
|
|
|
|
./configure --disable-doc --enable-static --disable-shared
|
|
|
|
fi
|
2020-02-14 15:36:56 +00:00
|
|
|
make -j$(nproc)
|
2018-08-09 16:26:47 +00:00
|
|
|
make install
|
2019-11-15 20:02:46 +00:00
|
|
|
cd ../gcrypt
|
2018-08-09 16:26:47 +00:00
|
|
|
./autogen.sh
|
2019-11-15 20:02:46 +00:00
|
|
|
if [ "$ARCHITECTURE" = 'i386' ]; then
|
|
|
|
./configure -host=i386 --enable-static --disable-shared --disable-doc --enable-maintainer-mode --disable-asm
|
|
|
|
else
|
|
|
|
./configure --enable-static --disable-shared --disable-doc --enable-maintainer-mode --disable-asm
|
|
|
|
fi
|
2020-02-14 15:36:56 +00:00
|
|
|
make -j$(nproc)
|
|
|
|
make install
|
2018-08-09 16:26:47 +00:00
|
|
|
)
|
|
|
|
|
2018-06-08 18:07:56 +00:00
|
|
|
#mbedtls
|
|
|
|
(
|
|
|
|
cd mbedtls
|
|
|
|
cmake . -DENABLE_PROGRAMS=0 -DENABLE_TESTING=0
|
|
|
|
make -j$(nproc) all
|
2020-02-14 15:36:56 +00:00
|
|
|
make install
|
2018-06-08 18:07:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
#openssl
|
|
|
|
(
|
|
|
|
cd openssl
|
2018-08-09 16:26:47 +00:00
|
|
|
#option to not have the same exported function poly1305_blocks as in gcrypt
|
2019-10-03 14:50:52 +00:00
|
|
|
if [ "$ARCHITECTURE" = 'i386' ]; then
|
|
|
|
setarch i386 ./config no-poly1305 no-shared no-threads -m32
|
|
|
|
else
|
|
|
|
./config no-poly1305 no-shared no-threads
|
|
|
|
fi
|
2018-06-08 18:07:56 +00:00
|
|
|
make build_generated libcrypto.a
|
2020-02-14 15:36:56 +00:00
|
|
|
make install
|
2018-06-08 18:07:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
#libecc
|
|
|
|
(
|
|
|
|
cd libecc
|
|
|
|
#required by libecc
|
2020-02-14 15:36:56 +00:00
|
|
|
(export CFLAGS="$CFLAGS -fPIC"; make; cp build/*.a /usr/local/lib; cp -r src/* /usr/local/include/)
|
2018-06-08 18:07:56 +00:00
|
|
|
)
|
|
|
|
|
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
|
2019-10-03 14:50:52 +00:00
|
|
|
if [ "$ARCHITECTURE" = 'i386' ]; then
|
|
|
|
./configure.py --disable-shared-library --cpu x86_32
|
|
|
|
else
|
|
|
|
./configure.py --disable-shared-library
|
|
|
|
fi
|
2020-02-14 15:36:56 +00:00
|
|
|
make -j$(nproc)
|
|
|
|
make install
|
2019-09-13 16:52:40 +00:00
|
|
|
)
|
|
|
|
|
2020-02-26 17:49:03 +00:00
|
|
|
#quickjs
|
|
|
|
(
|
|
|
|
cd quickjs
|
|
|
|
if [ "$ARCHITECTURE" = 'i386' ]; then
|
|
|
|
make qjsc
|
|
|
|
cp qjsc /usr/local/bin/
|
|
|
|
make clean
|
|
|
|
# Makefile should not override CFLAGS
|
|
|
|
sed -i -e 's/CFLAGS=/CFLAGS+=/' Makefile
|
|
|
|
CFLAGS="-m32" make libquickjs.a
|
|
|
|
else
|
|
|
|
make && make install
|
|
|
|
fi
|
|
|
|
cp quickjs*.h /usr/local/include/
|
|
|
|
cp libquickjs.a /usr/local/lib/
|
|
|
|
)
|
|
|
|
|
2018-06-08 18:07:56 +00:00
|
|
|
#build fuzz target
|
|
|
|
cd ecfuzzer
|
2020-02-26 17:49:03 +00:00
|
|
|
if [ "$ARCHITECTURE" = 'i386' ]; then
|
|
|
|
export GOARCH=386
|
|
|
|
#needed explicitly because of cross compilation cf https://golang.org/cmd/cgo/
|
|
|
|
export CGO_ENABLED=1
|
|
|
|
export CARGO_BUILD_TARGET=i686-unknown-linux-gnu
|
|
|
|
fi
|
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
|
|
|
|
2020-02-14 15:36:56 +00:00
|
|
|
mkdir build
|
|
|
|
cd build
|
2020-02-26 17:49:03 +00:00
|
|
|
#no afl with long javascript initialization
|
|
|
|
if [ "$FUZZING_ENGINE" != 'afl' ]; then
|
|
|
|
cmake ..
|
|
|
|
make -j$(nproc)
|
|
|
|
cp ecfuzzer $OUT/fuzz_ec
|
|
|
|
rm -Rf *
|
|
|
|
fi
|
|
|
|
|
|
|
|
#another target without cryptopp neither javascript
|
|
|
|
cmake -DDISABLE_CRYPTOPP=ON -DDISABLE_JS=ON ..
|
2020-02-14 15:36:56 +00:00
|
|
|
make -j$(nproc)
|
2020-02-26 17:49:03 +00:00
|
|
|
cp ecfuzzer $OUT/fuzz_ec_noblocker
|