Support symbol prefixes
- In base.h, if BORINGSSL_PREFIX is defined, include
boringssl_prefix_symbols.h
- In all .S files, if BORINGSSL_PREFIX is defined, include
boringssl_prefix_symbols_asm.h
- In base.h, BSSL_NAMESPACE_BEGIN and BSSL_NAMESPACE_END are
defined with appropriate values depending on whether
BORINGSSL_PREFIX is defined; these macros are used in place
of 'namespace bssl {' and '}'
- Add util/make_prefix_headers.go, which takes a list of symbols
and auto-generates the header files mentioned above
- In CMakeLists.txt, if BORINGSSL_PREFIX and BORINGSSL_PREFIX_SYMBOLS
are defined, run util/make_prefix_headers.go to generate header
files
- In various CMakeLists.txt files, add "global_target" that all
targets depend on to give us a place to hook logic that must run
before all other targets (in particular, the header file generation
logic)
- Document this in BUILDING.md, including the fact that it is
the caller's responsibility to provide the symbol list and keep it
up to date
- Note that this scheme has not been tested on Windows, and likely
does not work on it; Windows support will need to be added in a
future commit
Change-Id: If66a7157f46b5b66230ef91e15826b910cf979a2
Reviewed-on: https://boringssl-review.googlesource.com/31364
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
diff --git a/ssl/CMakeLists.txt b/ssl/CMakeLists.txt
index 6881089..d6c1294 100644
--- a/ssl/CMakeLists.txt
+++ b/ssl/CMakeLists.txt
@@ -41,6 +41,8 @@
tls13_server.cc
)
+add_dependencies(ssl global_target)
+
target_link_libraries(ssl crypto)
add_executable(
@@ -53,6 +55,8 @@
$<TARGET_OBJECTS:test_support>
)
+add_dependencies(ssl_test global_target)
+
target_link_libraries(ssl_test ssl crypto boringssl_gtest)
if(WIN32)
target_link_libraries(ssl_test ws2_32)
diff --git a/ssl/d1_both.cc b/ssl/d1_both.cc
index f22a498..3f7739e 100644
--- a/ssl/d1_both.cc
+++ b/ssl/d1_both.cc
@@ -127,7 +127,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
// TODO(davidben): 28 comes from the size of IP + UDP header. Is this reasonable
// for these values? Notably, why is kMinMTU a function of the transport
@@ -848,4 +848,4 @@
return kMinMTU;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/d1_lib.cc b/ssl/d1_lib.cc
index d73e538..0e0b211 100644
--- a/ssl/d1_lib.cc
+++ b/ssl/d1_lib.cc
@@ -68,7 +68,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
// DTLS1_MTU_TIMEOUTS is the maximum number of timeouts to expire
// before starting to decrease the MTU.
@@ -187,7 +187,7 @@
return true;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
using namespace bssl;
diff --git a/ssl/d1_pkt.cc b/ssl/d1_pkt.cc
index a694c5f..be595b0 100644
--- a/ssl/d1_pkt.cc
+++ b/ssl/d1_pkt.cc
@@ -126,7 +126,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
ssl_open_record_t dtls1_open_app_data(SSL *ssl, Span<uint8_t> *out,
size_t *out_consumed, uint8_t *out_alert,
@@ -271,4 +271,4 @@
return 1;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/dtls_record.cc b/ssl/dtls_record.cc
index d348601..3950ae2 100644
--- a/ssl/dtls_record.cc
+++ b/ssl/dtls_record.cc
@@ -121,7 +121,7 @@
#include "../crypto/internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
// to_u64_be treats |in| as a 8-byte big-endian integer and returns the value as
// a |uint64_t|.
@@ -350,4 +350,4 @@
return 1;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/handoff.cc b/ssl/handoff.cc
index 68cac5b..a47b7c1 100644
--- a/ssl/handoff.cc
+++ b/ssl/handoff.cc
@@ -19,7 +19,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
constexpr int kHandoffVersion = 0;
constexpr int kHandbackVersion = 0;
@@ -359,4 +359,4 @@
return CBS_len(&seq) == 0;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/handshake.cc b/ssl/handshake.cc
index 8e5c62c..963038f 100644
--- a/ssl/handshake.cc
+++ b/ssl/handshake.cc
@@ -122,7 +122,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
SSL_HANDSHAKE::SSL_HANDSHAKE(SSL *ssl_arg)
: ssl(ssl_arg),
@@ -667,4 +667,4 @@
}
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/handshake_client.cc b/ssl/handshake_client.cc
index ae6670f..ae96bcf 100644
--- a/ssl/handshake_client.cc
+++ b/ssl/handshake_client.cc
@@ -172,7 +172,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
enum ssl_client_hs_state_t {
state_start_connect = 0,
@@ -1820,4 +1820,4 @@
return "TLS client unknown";
}
-}
+BSSL_NAMESPACE_END
diff --git a/ssl/handshake_server.cc b/ssl/handshake_server.cc
index f0ed0d8..c546088 100644
--- a/ssl/handshake_server.cc
+++ b/ssl/handshake_server.cc
@@ -170,7 +170,7 @@
#include "../crypto/internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
bool ssl_client_cipher_list_contains_cipher(
const SSL_CLIENT_HELLO *client_hello, uint16_t id) {
@@ -1626,4 +1626,4 @@
return "TLS server unknown";
}
-}
+BSSL_NAMESPACE_END
diff --git a/ssl/internal.h b/ssl/internal.h
index 2877896..98ce6e0 100644
--- a/ssl/internal.h
+++ b/ssl/internal.h
@@ -173,7 +173,7 @@
#endif
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
struct SSL_CONFIG;
struct SSL_HANDSHAKE;
@@ -414,7 +414,7 @@
// Cipher suites.
-} // namespace bssl
+BSSL_NAMESPACE_END
struct ssl_cipher_st {
// name is the OpenSSL name for the cipher.
@@ -432,7 +432,7 @@
uint32_t algorithm_prf;
};
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
// Bits for |algorithm_mkey| (key exchange algorithm).
#define SSL_kRSA 0x00000001u
@@ -2015,13 +2015,13 @@
uint16_t alg_id = 0;
};
-} // namespace bssl
+BSSL_NAMESPACE_END
DECLARE_LHASH_OF(SSL_SESSION)
DEFINE_NAMED_STACK_OF(CertCompressionAlg, bssl::CertCompressionAlg);
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
// An ssl_shutdown_t describes the shutdown state of one end of the connection,
// whether it is alive or has been shutdown via close_notify or fatal alert.
@@ -2749,7 +2749,7 @@
// current state of the error queue.
void ssl_set_read_error(SSL *ssl);
-} // namespace bssl
+BSSL_NAMESPACE_END
// Opaque C types.
diff --git a/ssl/s3_both.cc b/ssl/s3_both.cc
index 98896a3..c1d4b65 100644
--- a/ssl/s3_both.cc
+++ b/ssl/s3_both.cc
@@ -130,7 +130,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
static bool add_record_to_flight(SSL *ssl, uint8_t type,
Span<const uint8_t> in) {
@@ -636,4 +636,4 @@
}
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/s3_lib.cc b/ssl/s3_lib.cc
index 0b24f94..0e0770c 100644
--- a/ssl/s3_lib.cc
+++ b/ssl/s3_lib.cc
@@ -162,7 +162,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
SSL3_STATE::SSL3_STATE()
: skip_early_data(false),
@@ -215,4 +215,4 @@
ssl->s3 = NULL;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/s3_pkt.cc b/ssl/s3_pkt.cc
index 50e709b..1ccbf9f 100644
--- a/ssl/s3_pkt.cc
+++ b/ssl/s3_pkt.cc
@@ -122,7 +122,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
static int do_ssl3_write(SSL *ssl, int type, const uint8_t *in, unsigned len);
@@ -425,4 +425,4 @@
return 1;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/span_test.cc b/ssl/span_test.cc
index 0aa7f3d..7db3d70 100644
--- a/ssl/span_test.cc
+++ b/ssl/span_test.cc
@@ -19,7 +19,7 @@
#include <openssl/ssl.h>
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
namespace {
static void TestCtor(Span<int> s, const int *ptr, size_t size) {
@@ -87,4 +87,4 @@
}
} // namespace
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/ssl_aead_ctx.cc b/ssl/ssl_aead_ctx.cc
index 322b1b5..6a25780 100644
--- a/ssl/ssl_aead_ctx.cc
+++ b/ssl/ssl_aead_ctx.cc
@@ -31,7 +31,7 @@
#define FUZZER_MODE false
#endif
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
SSLAEADContext::SSLAEADContext(uint16_t version_arg, bool is_dtls_arg,
const SSL_CIPHER *cipher_arg)
@@ -433,4 +433,4 @@
EVP_AEAD_CTX_get_iv(ctx_.get(), out_iv, out_iv_len);
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/ssl_asn1.cc b/ssl/ssl_asn1.cc
index 5dfacb2..caccef4 100644
--- a/ssl/ssl_asn1.cc
+++ b/ssl/ssl_asn1.cc
@@ -104,7 +104,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
// An SSL_SESSION is serialized as the following ASN.1 structure:
//
@@ -751,7 +751,7 @@
return SSL_SESSION_to_bytes_full(in, cbb, 0);
}
-} // namespace bssl
+BSSL_NAMESPACE_END
using namespace bssl;
diff --git a/ssl/ssl_buffer.cc b/ssl/ssl_buffer.cc
index 72647a4..b94f081 100644
--- a/ssl/ssl_buffer.cc
+++ b/ssl/ssl_buffer.cc
@@ -27,7 +27,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
// BIO uses int instead of size_t. No lengths will exceed uint16_t, so this will
// not overflow.
@@ -284,4 +284,4 @@
}
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/ssl_cert.cc b/ssl/ssl_cert.cc
index 4842974..3f3a1c5 100644
--- a/ssl/ssl_cert.cc
+++ b/ssl/ssl_cert.cc
@@ -133,7 +133,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
CERT::CERT(const SSL_X509_METHOD *x509_method_arg)
: x509_method(x509_method_arg) {}
@@ -750,7 +750,7 @@
return hs->local_pubkey != NULL;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
using namespace bssl;
diff --git a/ssl/ssl_cipher.cc b/ssl/ssl_cipher.cc
index 5899500..1e5320c 100644
--- a/ssl/ssl_cipher.cc
+++ b/ssl/ssl_cipher.cc
@@ -154,7 +154,7 @@
#include "../crypto/internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
// kCiphers is an array of all supported ciphers, sorted by id.
static constexpr SSL_CIPHER kCiphers[] = {
@@ -1306,7 +1306,7 @@
return ret;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
using namespace bssl;
diff --git a/ssl/ssl_key_share.cc b/ssl/ssl_key_share.cc
index c7f6f88..866da67 100644
--- a/ssl/ssl_key_share.cc
+++ b/ssl/ssl_key_share.cc
@@ -31,7 +31,7 @@
#include "../crypto/internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
namespace {
@@ -292,7 +292,7 @@
return 0;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
using namespace bssl;
diff --git a/ssl/ssl_lib.cc b/ssl/ssl_lib.cc
index 120c276..13b9cac 100644
--- a/ssl/ssl_lib.cc
+++ b/ssl/ssl_lib.cc
@@ -162,7 +162,7 @@
#endif
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
// |SSL_R_UNKNOWN_PROTOCOL| is no longer emitted, but continue to define it
// to avoid downstream churn.
@@ -506,7 +506,7 @@
ssl->config->handoff = on;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
using namespace bssl;
diff --git a/ssl/ssl_privkey.cc b/ssl/ssl_privkey.cc
index fecac39..b2f8177 100644
--- a/ssl/ssl_privkey.cc
+++ b/ssl/ssl_privkey.cc
@@ -69,7 +69,7 @@
#include "../crypto/internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
int ssl_is_key_type_supported(int key_type) {
return key_type == EVP_PKEY_RSA || key_type == EVP_PKEY_EC ||
@@ -287,7 +287,7 @@
return true;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
using namespace bssl;
diff --git a/ssl/ssl_session.cc b/ssl/ssl_session.cc
index 1b0b68a..927dd1b 100644
--- a/ssl/ssl_session.cc
+++ b/ssl/ssl_session.cc
@@ -151,7 +151,7 @@
#include "../crypto/internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
// The address of this is a magic value, a pointer to which is returned by
// SSL_magic_pending_session_ptr(). It allows a session callback to indicate
@@ -838,7 +838,7 @@
}
}
-} // namespace bssl
+BSSL_NAMESPACE_END
using namespace bssl;
diff --git a/ssl/ssl_test.cc b/ssl/ssl_test.cc
index 2f78032..bb47b70 100644
--- a/ssl/ssl_test.cc
+++ b/ssl/ssl_test.cc
@@ -53,7 +53,7 @@
#endif
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
namespace {
@@ -4443,4 +4443,4 @@
}
} // namespace
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/ssl_transcript.cc b/ssl/ssl_transcript.cc
index 24b86bf..8bb513d 100644
--- a/ssl/ssl_transcript.cc
+++ b/ssl/ssl_transcript.cc
@@ -141,7 +141,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
SSLTranscript::SSLTranscript() {}
@@ -261,4 +261,4 @@
return true;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/ssl_versions.cc b/ssl/ssl_versions.cc
index 212c3ac..911fb7e 100644
--- a/ssl/ssl_versions.cc
+++ b/ssl/ssl_versions.cc
@@ -23,7 +23,7 @@
#include "../crypto/internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
bool ssl_protocol_version_from_wire(uint16_t *out, uint16_t version) {
switch (version) {
@@ -360,7 +360,7 @@
return version == TLS1_3_DRAFT28_VERSION || version == TLS1_3_VERSION;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
using namespace bssl;
diff --git a/ssl/ssl_x509.cc b/ssl/ssl_x509.cc
index ef09589..9fa800f 100644
--- a/ssl/ssl_x509.cc
+++ b/ssl/ssl_x509.cc
@@ -155,7 +155,7 @@
#include "../crypto/internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
// check_ssl_x509_method asserts that |ssl| has the X509-based method
// installed. Calling an X509-based method on an |ssl| with a different method
@@ -506,7 +506,7 @@
ssl_crypto_x509_ssl_ctx_flush_cached_client_CA,
};
-} // namespace bssl
+BSSL_NAMESPACE_END
using namespace bssl;
diff --git a/ssl/t1_enc.cc b/ssl/t1_enc.cc
index 93170b9..c6b2844 100644
--- a/ssl/t1_enc.cc
+++ b/ssl/t1_enc.cc
@@ -153,7 +153,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
bool tls1_prf(const EVP_MD *digest, Span<uint8_t> out,
Span<const uint8_t> secret, Span<const char> label,
@@ -277,7 +277,7 @@
return SSL3_MASTER_SECRET_SIZE;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
using namespace bssl;
diff --git a/ssl/t1_lib.cc b/ssl/t1_lib.cc
index 32ea2d4..3f4818f 100644
--- a/ssl/t1_lib.cc
+++ b/ssl/t1_lib.cc
@@ -129,7 +129,7 @@
#include "../crypto/internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
static bool ssl_check_clienthello_tlsext(SSL_HANDSHAKE *hs);
@@ -3836,7 +3836,7 @@
return true;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
using namespace bssl;
diff --git a/ssl/test/CMakeLists.txt b/ssl/test/CMakeLists.txt
index 425b43b..d86464c 100644
--- a/ssl/test/CMakeLists.txt
+++ b/ssl/test/CMakeLists.txt
@@ -14,6 +14,8 @@
$<TARGET_OBJECTS:test_support>
)
+add_dependencies(bssl_shim global_target)
+
target_link_libraries(bssl_shim ssl crypto)
if(UNIX AND NOT APPLE AND NOT ANDROID)
@@ -31,6 +33,8 @@
$<TARGET_OBJECTS:test_support>
)
+ add_dependencies(handshaker global_target)
+
target_link_libraries(handshaker ssl crypto)
else()
# Declare a dummy target for run_tests to depend on.
diff --git a/ssl/tls13_both.cc b/ssl/tls13_both.cc
index faaa88d..a02d35d 100644
--- a/ssl/tls13_both.cc
+++ b/ssl/tls13_both.cc
@@ -30,7 +30,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
// kMaxKeyUpdates is the number of consecutive KeyUpdates that will be
// processed. Without this limit an attacker could force unbounded processing
@@ -665,4 +665,4 @@
return false;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/tls13_client.cc b/ssl/tls13_client.cc
index 7de70b0..26f5fb9 100644
--- a/ssl/tls13_client.cc
+++ b/ssl/tls13_client.cc
@@ -31,7 +31,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
enum client_hs_state_t {
state_read_hello_retry_request = 0,
@@ -929,4 +929,4 @@
return true;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/tls13_enc.cc b/ssl/tls13_enc.cc
index 84bc5d2..e451838 100644
--- a/ssl/tls13_enc.cc
+++ b/ssl/tls13_enc.cc
@@ -30,7 +30,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
static int init_key_schedule(SSL_HANDSHAKE *hs, uint16_t version,
const SSL_CIPHER *cipher) {
@@ -487,4 +487,4 @@
return 1;
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/tls13_server.cc b/ssl/tls13_server.cc
index bf3e2cf..b1940d8 100644
--- a/ssl/tls13_server.cc
+++ b/ssl/tls13_server.cc
@@ -36,7 +36,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
enum server_hs_state_t {
state_select_parameters = 0,
@@ -1028,4 +1028,4 @@
return "TLS 1.3 server unknown";
}
-} // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/ssl/tls_method.cc b/ssl/tls_method.cc
index 2af5171..116f027 100644
--- a/ssl/tls_method.cc
+++ b/ssl/tls_method.cc
@@ -65,7 +65,7 @@
#include "internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
static void ssl3_on_handshake_complete(SSL *ssl) {
// The handshake should have released its final message.
@@ -182,7 +182,7 @@
ssl_noop_x509_ssl_ctx_flush_cached_client_CA,
};
-} // namespace bssl
+BSSL_NAMESPACE_END
using namespace bssl;
diff --git a/ssl/tls_record.cc b/ssl/tls_record.cc
index a2e4a20..452b0cf 100644
--- a/ssl/tls_record.cc
+++ b/ssl/tls_record.cc
@@ -119,7 +119,7 @@
#include "../crypto/internal.h"
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
// kMaxEmptyRecords is the number of consecutive, empty records that will be
// processed. Without this limit an attacker could send empty records at a
@@ -674,7 +674,7 @@
in.data(), in.size());
}
-} // namespace bssl
+BSSL_NAMESPACE_END
using namespace bssl;