Skip to content

Commit 6834572

Browse files
committed
Work with boringssl
Work with boringssl
1 parent 6dd9ef9 commit 6834572

File tree

11 files changed

+90
-20
lines changed

11 files changed

+90
-20
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ addons:
1414
sources: &common_sources
1515
- ubuntu-toolchain-r-test
1616
- llvm-toolchain-precise-3.6
17+
- kalakris-cmake
1718
packages: &common_packages
1819
- autoconf
1920
- automake
2021
- build-essential
2122
- python-dev
2223
- libstdc++-4.9-dev
2324
- tcl8.5
25+
- cmake
2426

2527
matrix:
2628
include:
@@ -74,6 +76,7 @@ before_install:
7476
- echo "leak:InitModule" > ${HOME}/lsan.supp
7577
- echo "leak:SetExitLoopHandler" >> ${HOME}/lsan.supp
7678
- echo "leak:masterelection_test" >> ${HOME}/lsan.supp
79+
- if [ "${CLEAR_CACHE}" != "" ]; then echo "Clearing cache"; rm -fr ${TRAVIS_BUILD_DIR}/../ct ${TRAVIS_BUILD_DIR}/../install ${HOME}/.ccache; fi
7780
- mkdir -p ${INSTALL_DIR}/include ${INSTALL_DIR}/lib ${INSTALL_DIR}/java
7881
- echo "INSTALL_DIR=${INSTALL_DIR}"
7982
- mkdir -p $GOPATH/src/github.com/google

DEPS

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1+
vars = {
2+
# Change this variable to the name of one of the alterniative SSL
3+
# implementations below.
4+
# If you change this in an existing client, you should probably rm -fr
5+
# all the deps and rebuild everything from scratch.
6+
"ssl_impl": "openssl",
7+
8+
# SSL implementation alternatives:
9+
"openssl": "https://github.com/openssl/openssl.git@OpenSSL_1_0_2d",
10+
"boringssl": "https://boringssl.googlesource.com/boringssl.git@2661"
11+
}
12+
113
deps = {
14+
Var("ssl_impl"): Var(Var("ssl_impl")),
215
"gflags": "https://github.com/gflags/gflags.git@v2.1.2",
316
"glog": "https://github.com/benlaurie/glog.git@0.3.4-fix",
417
"googlemock": "https://github.com/google/googlemock.git@release-1.7.0",
@@ -11,7 +24,6 @@ deps = {
1124
"libevhtp": "https://github.com/ellzey/libevhtp.git@a89d9b3f9fdf2ebef41893b3d5e4466f4b0ecfda",
1225
"certificate-transparency/third_party/objecthash":
1326
"https://github.com/benlaurie/objecthash.git@798f66bd8c5313da226aa7a60c114147910a7407",
14-
"openssl": "https://github.com/openssl/openssl.git@OpenSSL_1_0_2d",
1527
"protobuf": "https://github.com/google/protobuf.git@v2.6.1",
1628
"protobuf/gtest": "https://github.com/google/googletest.git@release-1.7.0",
1729
"libsnappy": "https://github.com/google/snappy.git@1.1.3",
@@ -58,6 +70,7 @@ else:
5870

5971
num_cores = multiprocessing.cpu_count()
6072

73+
print("Building with %s", Var("ssl_impl"))
6174
print("Using make %s with %d jobs" % (make, num_cores))
6275

6376
here = os.getcwd()
@@ -74,9 +87,9 @@ hooks = [
7487
"action": [ make, "-f", os.path.join(here, "certificate-transparency/build.gclient"), "_tcmalloc" ],
7588
},
7689
{
77-
"name": "openssl",
78-
"pattern": "^openssl/",
79-
"action": [ make, "-f", os.path.join(here, "certificate-transparency/build.gclient"), "_openssl" ],
90+
"name": "ssl",
91+
"pattern": Var("ssl_impl") + "/",
92+
"action": [ make, "-f", os.path.join(here, "certificate-transparency/build.gclient"), "_" + Var("ssl_impl") ],
8093
},
8194
{
8295
"name": "libevent",
@@ -103,11 +116,6 @@ hooks = [
103116
"pattern": "^protobuf/",
104117
"action": [ make, "-f", os.path.join(here, "certificate-transparency/build.gclient"), "_protobuf" ],
105118
},
106-
{
107-
"name": "ldns",
108-
"pattern": "^ldns/",
109-
"action": [ make, "-f", os.path.join(here, "certificate-transparency/build.gclient"), "_ldns" ],
110-
},
111119
{
112120
"name": "sqlite3",
113121
"pattern": "^sqlite3/",
@@ -137,11 +145,23 @@ hooks = [
137145
"name": "objecthash",
138146
"pattern": "^certificate-transparency/third_party/objecthash/",
139147
"action": [ make, "-f", os.path.join(here, "certificate-transparency/build.gclient"), "_objecthash" ],
140-
},
141-
# Do this last
148+
}]
149+
150+
# Currently only Openssl is supported for building the DNS server due to LDNS's dependency.
151+
if Var("ssl_impl") == 'openssl':
152+
hooks.append(
153+
{
154+
"name": "ldns",
155+
"pattern": "^ldns/",
156+
"action": [ make, "-f", os.path.join(here, "certificate-transparency/build.gclient"), "_ldns" ],
157+
})
158+
else:
159+
print("NOT building DNS server since we're using BoringSSL.")
160+
161+
# Do this last
162+
hooks.append(
142163
{
143164
"name": "ct",
144165
"pattern": "^certificate-transparency/",
145166
"action": [ make, "-j", str(num_cores), "-f", os.path.join(here, "certificate-transparency/build.gclient"), "_configure-ct" ],
146-
}
147-
]
167+
})

Makefile.am

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ TESTS = \
7373
cpp/log/cert_submission_handler_test \
7474
cpp/log/cert_test \
7575
cpp/log/cluster_state_controller_test \
76-
cpp/log/cms_verifier_test \
7776
cpp/log/ct_extensions_test \
7877
cpp/log/database_large_test \
7978
cpp/log/database_test \
@@ -109,6 +108,10 @@ TESTS = \
109108
cpp/util/sync_task_test \
110109
cpp/util/task_test
111110

111+
if !OPENSSL_IS_BORINGSSL
112+
TESTS += cpp/log/cms_verifier_test
113+
endif
114+
112115
all-local:
113116
$(MAKE) -C python
114117

@@ -141,7 +144,6 @@ cpp_libcore_a_SOURCES = \
141144
cpp/log/cert_checker.cc \
142145
cpp/log/cert_submission_handler.cc \
143146
cpp/log/cluster_state_controller_cert.cc \
144-
cpp/log/cms_verifier.cc \
145147
cpp/log/ct_extensions.cc \
146148
cpp/log/database.cc \
147149
cpp/log/etcd_consistent_store_cert.cc \
@@ -210,6 +212,10 @@ cpp_libcore_a_SOURCES = \
210212
proto/ct.pb.cc \
211213
proto/ct.pb.h
212214

215+
if !OPENSSL_IS_BORINGSSL
216+
cpp_libcore_a_SOURCES += cpp/log/cms_verifier.cc
217+
endif
218+
213219
cpp_libtest_a_CPPFLAGS = \
214220
-I$(GMOCK_DIR) \
215221
-I$(GTEST_DIR) \
@@ -902,6 +908,7 @@ cpp_log_cert_test_SOURCES = \
902908
cpp/log/cert_test.cc \
903909
cpp/util/util.cc
904910

911+
if !OPENSSL_IS_BORINGSSL
905912
cpp_log_cms_verifier_test_LDADD = \
906913
cpp/libcore.a \
907914
cpp/libtest.a \
@@ -910,6 +917,7 @@ cpp_log_cms_verifier_test_LDADD = \
910917
cpp_log_cms_verifier_test_SOURCES = \
911918
cpp/log/cms_verifier_test.cc \
912919
cpp/util/util.cc
920+
endif
913921

914922
cpp_log_ct_extensions_test_LDADD = \
915923
cpp/libcore.a \

build.gclient

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export INSTALL_DIR
55
PKG_CONFIG_PATH=$(shell pwd)/install/lib/pkgconfig
66
export PKG_CONFIG_PATH
77

8-
PHONY: libunwind tcmalloc objecthash openssl protobuf libevent libevhtp gflags glog ldns sqlite3 leveldb json-c configure-ct
8+
PHONY: libunwind tcmalloc objecthash borginssl openssl protobuf libevent libevhtp gflags glog ldns sqlite3 leveldb json-c configure-ct
99

1010
all: configure-ct
1111

@@ -25,6 +25,9 @@ _icu4c:
2525
_objecthash:
2626
$(MAKE) -C certificate-transparency/third_party/objecthash -f `pwd`/certificate-transparency/build/Makefile.objecthash
2727

28+
_boringssl:
29+
$(MAKE) -C boringssl -f `pwd`/certificate-transparency/build/Makefile.boringssl
30+
2831
_openssl:
2932
$(MAKE) -C openssl -f `pwd`/certificate-transparency/build/Makefile.openssl
3033
cd openssl && git checkout -- apps/progs.h crypto/bn/bn_prime.h

build/Makefile.boringssl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
all: make
2+
3+
make: build/Makefile
4+
cd build && $(MAKE) && \
5+
cp -rv ../include $(INSTALL_DIR) && \
6+
cp crypto/libcrypto.a ssl/libssl.a $(INSTALL_DIR)/lib
7+
8+
build/Makefile: build
9+
cd build && cmake -DBUILD_SHARED_LIBS=FALSE -DCMAKE_CXX_FLAGS:STRING=-fPIC -DCMAKE_C_FLAGS:STRING=-fPIC -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) ..
10+
11+
build:
12+
mkdir -p build

build/Makefile.libevent

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ endif
55
ifeq ($(UNAME),Darwin)
66
EXTRA_LDFLAGS="-ldl"
77
endif
8+
EXTRA_LDFLAGS+="-lpthread"
89

910
all: Makefile
1011
$(MAKE)

build/Makefile.libevhtp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ Makefile: CMakeLists.txt
66
cmake \
77
-DBUILD_SHARED_LIBS=FALSE \
88
-DCMAKE_INSTALL_PREFIX:STRING=$(INSTALL_DIR) \
9-
-DLIBEVENT_LIBRARY_DIRS:STRING=$(INSTALL_DIR)/include \
9+
-DLIBEVENT_INCLUDE_DIRS:STRING=$(INSTALL_DIR)/include \
10+
-DLIBEVENT_LIBRARY_DIRS:STRING=$(INSTALL_DIR)/lib \
1011
-DLIBEVENT_LIBRARY:STRING=$(INSTALL_DIR)/lib/libevent.a \
1112
-DLIBEVENT_PTHREADS_LIBRARY:STRING=$(INSTALL_DIR)/lib/libevent-pthreads.a \
1213
-DLIBEVENT_CORE_LIBRARY:STRING=$(INSTALL_DIR)/lib/libevent-core.a \
1314
-DLIBEVENT_EXTRA_LIBRARY:STRING=$(INSTALL_DIR)/lib/libevent-extra.a \
1415
-DLIBEVENT_OPENSSL_LIBRARY:STRING=$(INSTALL_DIR)/lib/libevent-openssl.a \
16+
-DOPENSSL_INCLUDE_DIR:PATH=$(INSTALL_DIR)/include \
17+
-DOPENSSL_CRYPTO_LIBRARY:FILEPATH=$(INSTALL_DIR)/lib/libcrypto.a \
18+
-DOPENSSL_SSL_LIBRARY:FILEPATH=$(INSTALL_DIR)/lib/libssl.a \
1519
-DEVHTP_DISABLE_REGEX:STRING=ON \
1620
-DCMAKE_C_FLAGS:STRING=-fPIC .
1721

configure.ac

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,22 @@ AC_SEARCH_LIBS([SSL_CTX_new], [ssl],, [missing_openssl=1], [$save_LIBS])
134134
AS_IF([test -n "$missing_openssl"],
135135
[AC_MSG_ERROR([could not find the OpenSSL libraries])])
136136

137+
AC_MSG_CHECKING([for BoringSSL])
138+
AC_COMPILE_IFELSE([
139+
AC_LANG_PROGRAM([[
140+
#include <openssl/base.h>
141+
]],[[
142+
#ifndef OPENSSL_IS_BORINGSSL
143+
#error not boringssl
144+
#endif
145+
]])
146+
],[
147+
AC_MSG_RESULT([yes])
148+
openssl_is_boringssl=1
149+
],[
150+
AC_MSG_RESULT([no])
151+
])
152+
137153
save_LIBS="$LIBS"
138154
AS_UNSET([LIBS])
139155
AC_SEARCH_LIBS([event_base_dispatch], [event],, [missing_libevent=1],
@@ -198,6 +214,7 @@ AC_CHECK_FUNCS([alarm gettimeofday memset mkdir select socket strdup strerror st
198214

199215
AM_CONDITIONAL([HAVE_ANT], [test -n "$ANT"])
200216
AM_CONDITIONAL([HAVE_LDNS], [test -z "$missing_ldns"])
217+
AM_CONDITIONAL([OPENSSL_IS_BORINGSSL], [test -n "$openssl_is_boringssl"])
201218
AC_DEFINE_UNQUOTED([TEST_SRCDIR], ["$srcdir"], [Top of the source directory, for tests.])
202219
AC_SUBST([INSTALL_DIR])
203220
AC_CONFIG_FILES([Makefile])

cpp/client/ct.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ static void MakeCert() {
405405

406406
// Set signature algorithm
407407
// FIXME: is there an opaque way to get the algorithm structure?
408-
x->cert_info->signature->algorithm = OBJ_nid2obj(NID_sha1WithRSAEncryption);
408+
// FIXME: Sort out const/non-const OpenssL/BoringSSL mismatch.
409+
x->cert_info->signature->algorithm = const_cast<ASN1_OBJECT*>(OBJ_nid2obj(NID_sha1WithRSAEncryption));
409410
x->cert_info->signature->parameter = NULL;
410411

411412
// Set the start date to now

cpp/log/cert_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,8 @@ TEST_F(CertTest, SignatureAlgorithmMatches) {
489489

490490
TEST_F(CertTest, IllegalSignatureAlgorithmParameter) {
491491
Cert cert(kIllegalSigAlgParameterCertString);
492-
#if defined(OPENSSL_IS_BORINGSSL) && defined(BORINGSSL_201603)
492+
#if defined(OPENSSL_IS_BORINGSSL) && \
493+
(defined(BORINGSSL_201603) || defined(BORINGSSL_201512))
493494
EXPECT_FALSE(cert.IsLoaded());
494495
#else
495496
EXPECT_TRUE(cert.IsLoaded());

0 commit comments

Comments
 (0)