Use BSSL_NAMESPACE_{BEGIN,END} macros more consistently

The macros will participate in symbol prefixing. Not that symbol
prefixing particularly works, but let's be consistent.

Change-Id: I54043a849682e2ba2b8576b59241035e4d4effbe
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/70387
Commit-Queue: David Benjamin <davidben@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
diff --git a/crypto/hpke/hpke_test.cc b/crypto/hpke/hpke_test.cc
index ce68adc..2e22e33 100644
--- a/crypto/hpke/hpke_test.cc
+++ b/crypto/hpke/hpke_test.cc
@@ -34,7 +34,7 @@
 #include "../test/test_util.h"
 
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 namespace {
 
 const decltype(&EVP_hpke_aes_128_gcm) kAllAEADs[] = {
@@ -635,5 +635,4 @@
   ASSERT_FALSE(ParseIntSafe(&u16, "65536"));
 }
 
-
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/include/openssl/pki/certificate.h b/include/openssl/pki/certificate.h
index 782a70a..9fc6e7b 100644
--- a/include/openssl/pki/certificate.h
+++ b/include/openssl/pki/certificate.h
@@ -22,7 +22,7 @@
 #include <openssl/base.h>
 #include <openssl/span.h>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 struct CertificateInternals;
 
@@ -78,6 +78,6 @@
   std::unique_ptr<CertificateInternals> internals_;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // OPENSSL_HEADER_BSSL_PKI_CERTIFICATE_H_ && __cplusplus
diff --git a/include/openssl/pki/signature_verify_cache.h b/include/openssl/pki/signature_verify_cache.h
index ae73765..7068883 100644
--- a/include/openssl/pki/signature_verify_cache.h
+++ b/include/openssl/pki/signature_verify_cache.h
@@ -8,7 +8,7 @@
 #include <openssl/base.h>
 #include <string>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 class OPENSSL_EXPORT SignatureVerifyCache {
  public:
@@ -36,6 +36,6 @@
   virtual Value Check(const std::string &key) = 0;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_SIGNATURE_VERIFY_CACHE_H_ && __cplusplus
diff --git a/include/openssl/pki/verify.h b/include/openssl/pki/verify.h
index 0c1b551..06ca1af 100644
--- a/include/openssl/pki/verify.h
+++ b/include/openssl/pki/verify.h
@@ -10,7 +10,8 @@
 #include <openssl/pki/signature_verify_cache.h>
 #include <openssl/pki/verify_error.h>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
+
 class CertIssuerSourceStatic;
 class TrustStoreInMemory;
 class CertificateVerifyOptions;
@@ -165,6 +166,6 @@
 OPENSSL_EXPORT std::optional<std::vector<std::vector<std::string>>>
 CertificateVerifyAllPaths(const CertificateVerifyOptions &opts);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_VERIFY_H_
diff --git a/include/openssl/pki/verify_error.h b/include/openssl/pki/verify_error.h
index 34b5dc5..6bfb826 100644
--- a/include/openssl/pki/verify_error.h
+++ b/include/openssl/pki/verify_error.h
@@ -15,10 +15,11 @@
 #if !defined(OPENSSL_HEADER_BSSL_PKI_VERIFY_ERROR_H_) && defined(__cplusplus)
 #define OPENSSL_HEADER_BSSL_PKI_VERIFY_ERROR_H_
 
-#include <string>
-#include <string_view>
+#include <openssl/base.h>
 
-namespace bssl {
+#include <string>
+
+BSSL_NAMESPACE_BEGIN
 
 // VerifyError describes certificate chain validation result.
 class OPENSSL_EXPORT VerifyError {
@@ -132,6 +133,6 @@
   std::string diagnostic_;
 };
 
-} // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // OPENSSL_HEADER_BSSL_PKI_VERIFY_ERROR_H_
diff --git a/include/openssl/service_indicator.h b/include/openssl/service_indicator.h
index 33b38b2..e426e05 100644
--- a/include/openssl/service_indicator.h
+++ b/include/openssl/service_indicator.h
@@ -56,7 +56,7 @@
     return func;                                                \
   }()
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 enum class FIPSStatus {
   NOT_APPROVED = 0,
@@ -87,7 +87,7 @@
   const uint64_t before_;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 }  // extern "C++"
 
 #endif  // !BORINGSSL_NO_CXX
diff --git a/pki/cert_error_id.cc b/pki/cert_error_id.cc
index 81add1d..6c041d9 100644
--- a/pki/cert_error_id.cc
+++ b/pki/cert_error_id.cc
@@ -4,11 +4,11 @@
 
 #include "cert_error_id.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 const char *CertErrorIdToDebugString(CertErrorId id) {
   // The CertErrorId is simply a pointer for a C-string literal.
   return reinterpret_cast<const char *>(id);
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/cert_error_id.h b/pki/cert_error_id.h
index d325b1b..6f71a86 100644
--- a/pki/cert_error_id.h
+++ b/pki/cert_error_id.h
@@ -7,7 +7,7 @@
 
 #include <openssl/base.h>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 // Each "class" of certificate error/warning has its own unique ID. This is
 // essentially like an error code, however the value is not stable. Under the
@@ -32,6 +32,6 @@
 // string literal given to DEFINE_CERT_ERROR_ID(), which is human-readable.
 OPENSSL_EXPORT const char *CertErrorIdToDebugString(CertErrorId id);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_CERT_ERROR_ID_H_
diff --git a/pki/cert_error_params.cc b/pki/cert_error_params.cc
index dd962c4..e258e98 100644
--- a/pki/cert_error_params.cc
+++ b/pki/cert_error_params.cc
@@ -11,7 +11,7 @@
 #include "input.h"
 #include "string_util.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -132,4 +132,4 @@
   return std::make_unique<CertErrorParams2SizeT>(name1, value1, name2, value2);
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/cert_error_params.h b/pki/cert_error_params.h
index c407782..d960435 100644
--- a/pki/cert_error_params.h
+++ b/pki/cert_error_params.h
@@ -10,7 +10,7 @@
 
 #include <openssl/base.h>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace der {
 class Input;
@@ -54,6 +54,6 @@
 OPENSSL_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams2SizeT(
     const char *name1, size_t value1, const char *name2, size_t value2);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_CERT_ERROR_PARAMS_H_
diff --git a/pki/cert_errors.cc b/pki/cert_errors.cc
index f54903e..8bd7084 100644
--- a/pki/cert_errors.cc
+++ b/pki/cert_errors.cc
@@ -10,7 +10,7 @@
 
 #include <sstream>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -232,4 +232,4 @@
   return result.str();
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/cert_errors.h b/pki/cert_errors.h
index 43ea7fc..23b88ba 100644
--- a/pki/cert_errors.h
+++ b/pki/cert_errors.h
@@ -54,7 +54,7 @@
 #include "cert_error_id.h"
 #include "parsed_certificate.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 class CertErrorParams;
 class CertPathErrors;
@@ -176,6 +176,6 @@
   CertErrors other_errors_;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_CERT_ERRORS_H_
diff --git a/pki/cert_issuer_source.h b/pki/cert_issuer_source.h
index 7de0fa4..cffad9d 100644
--- a/pki/cert_issuer_source.h
+++ b/pki/cert_issuer_source.h
@@ -12,7 +12,7 @@
 
 #include "parsed_certificate.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 // Interface for looking up issuers of a certificate during path building.
 // Provides a synchronous and asynchronous method for retrieving issuers, so the
@@ -63,6 +63,6 @@
                                  std::unique_ptr<Request> *out_req) = 0;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_CERT_ISSUER_SOURCE_H_
diff --git a/pki/cert_issuer_source_static.cc b/pki/cert_issuer_source_static.cc
index 162b8de..1c15594 100644
--- a/pki/cert_issuer_source_static.cc
+++ b/pki/cert_issuer_source_static.cc
@@ -4,7 +4,7 @@
 
 #include "cert_issuer_source_static.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 CertIssuerSourceStatic::CertIssuerSourceStatic() = default;
 CertIssuerSourceStatic::~CertIssuerSourceStatic() = default;
@@ -42,4 +42,4 @@
   out_req->reset();
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/cert_issuer_source_static.h b/pki/cert_issuer_source_static.h
index a0395ef..a0e11a0 100644
--- a/pki/cert_issuer_source_static.h
+++ b/pki/cert_issuer_source_static.h
@@ -12,7 +12,7 @@
 
 #include "cert_issuer_source.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 // Synchronously returns issuers from a pre-supplied set.
 class OPENSSL_EXPORT CertIssuerSourceStatic : public CertIssuerSource {
@@ -50,6 +50,6 @@
       intermediates_;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_CERT_ISSUER_SOURCE_STATIC_H_
diff --git a/pki/cert_issuer_source_static_unittest.cc b/pki/cert_issuer_source_static_unittest.cc
index 8b0a36c..39ba2a8 100644
--- a/pki/cert_issuer_source_static_unittest.cc
+++ b/pki/cert_issuer_source_static_unittest.cc
@@ -9,7 +9,7 @@
 #include "cert_issuer_source_sync_unittest.h"
 #include "parsed_certificate.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -72,4 +72,4 @@
 
 }  // namespace
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/cert_issuer_source_sync_unittest.h b/pki/cert_issuer_source_sync_unittest.h
index c9e25c1..d00bd63 100644
--- a/pki/cert_issuer_source_sync_unittest.h
+++ b/pki/cert_issuer_source_sync_unittest.h
@@ -13,7 +13,7 @@
 #include "cert_issuer_source.h"
 #include "test_helpers.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -211,6 +211,6 @@
 REGISTER_TYPED_TEST_SUITE_P(CertIssuerSourceSyncNotNormalizedTest,
                             OneMatchWithoutNormalization);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_CERT_ISSUER_SOURCE_SYNC_UNITTEST_H_
diff --git a/pki/certificate.cc b/pki/certificate.cc
index db1c627..5cb746c 100644
--- a/pki/certificate.cc
+++ b/pki/certificate.cc
@@ -24,7 +24,7 @@
 #include "pem.h"
 #include "parse_values.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -114,4 +114,4 @@
   return internals_->cert->tbs().serial_number;
 }
 
-}  // namespace boringssl
+BSSL_NAMESPACE_END
diff --git a/pki/certificate_policies.cc b/pki/certificate_policies.cc
index 198e348..70536b8 100644
--- a/pki/certificate_policies.cc
+++ b/pki/certificate_policies.cc
@@ -13,7 +13,7 @@
 #include "parse_values.h"
 #include "parser.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -388,4 +388,4 @@
   return true;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/certificate_policies.h b/pki/certificate_policies.h
index ccba1e9..a6c7368 100644
--- a/pki/certificate_policies.h
+++ b/pki/certificate_policies.h
@@ -12,7 +12,7 @@
 #include <optional>
 #include "input.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 class CertErrors;
 
@@ -123,6 +123,6 @@
 [[nodiscard]] OPENSSL_EXPORT bool ParsePolicyMappings(
     der::Input policy_mappings_tlv, std::vector<ParsedPolicyMapping> *mappings);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_CERTIFICATE_POLICIES_H_
diff --git a/pki/certificate_policies_unittest.cc b/pki/certificate_policies_unittest.cc
index 9458659..f66b748 100644
--- a/pki/certificate_policies_unittest.cc
+++ b/pki/certificate_policies_unittest.cc
@@ -9,7 +9,7 @@
 #include "parser.h"
 #include "test_helpers.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 namespace {
 
 ::testing::AssertionResult LoadTestData(const std::string &name,
@@ -309,4 +309,4 @@
 // parsed_certificate_unittest.cc
 
 }  // namespace
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/common_cert_errors.cc b/pki/common_cert_errors.cc
index 00f5743..0e6ad0f 100644
--- a/pki/common_cert_errors.cc
+++ b/pki/common_cert_errors.cc
@@ -4,7 +4,8 @@
 
 #include "common_cert_errors.h"
 
-namespace bssl::cert_errors {
+BSSL_NAMESPACE_BEGIN
+namespace cert_errors {
 
 DEFINE_CERT_ERROR_ID(kInternalError, "Internal error");
 DEFINE_CERT_ERROR_ID(kValidityFailedNotAfter, "Time is after notAfter");
@@ -79,4 +80,5 @@
 DEFINE_CERT_ERROR_ID(kIterationLimitExceeded, "Iteration limit exceeded");
 DEFINE_CERT_ERROR_ID(kDepthLimitExceeded, "Depth limit exceeded");
 
-}  // namespace bssl::cert_errors
+}  // namespace cert_errors
+BSSL_NAMESPACE_END
diff --git a/pki/common_cert_errors.h b/pki/common_cert_errors.h
index d2b37ba..81d67f0 100644
--- a/pki/common_cert_errors.h
+++ b/pki/common_cert_errors.h
@@ -13,7 +13,8 @@
 // defined by the core verification/path building code).
 //
 // Errors may be defined for other domains.
-namespace bssl::cert_errors {
+BSSL_NAMESPACE_BEGIN
+namespace cert_errors {
 
 // An internal error occurred which prevented path building or verification
 // from finishing.
@@ -155,6 +156,7 @@
 // Depth limit was reached during path building.
 OPENSSL_EXPORT extern const CertErrorId kDepthLimitExceeded;
 
-}  // namespace bssl::cert_errors
+}  // namespace cert_errors
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_COMMON_CERT_ERRORS_H_
diff --git a/pki/crl.cc b/pki/crl.cc
index 63e1cc6..70ab07a 100644
--- a/pki/crl.cc
+++ b/pki/crl.cc
@@ -18,7 +18,7 @@
 #include "verify_name_match.h"
 #include "verify_signed_data.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -670,4 +670,4 @@
   return CRLRevocationStatus::UNKNOWN;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/crl.h b/pki/crl.h
index d527de9..2fd3b2f 100644
--- a/pki/crl.h
+++ b/pki/crl.h
@@ -14,7 +14,7 @@
 #include "parse_values.h"
 #include "parsed_certificate.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 struct ParsedCrlTbsCertList;
 struct ParsedDistributionPoint;
@@ -215,6 +215,6 @@
     size_t target_cert_index, const ParsedDistributionPoint &cert_dp,
     int64_t verify_time_epoch_seconds, std::optional<int64_t> max_age_seconds);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_CRL_H_
diff --git a/pki/crl_unittest.cc b/pki/crl_unittest.cc
index b9be70f..f8f26d2 100644
--- a/pki/crl_unittest.cc
+++ b/pki/crl_unittest.cc
@@ -13,7 +13,7 @@
 #include "string_util.h"
 #include "test_helpers.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -205,4 +205,4 @@
 
 }  // namespace
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/encode_values.cc b/pki/encode_values.cc
index 0054fa2..b2dbb83 100644
--- a/pki/encode_values.cc
+++ b/pki/encode_values.cc
@@ -8,7 +8,8 @@
 
 #include <openssl/posix_time.h>
 
-namespace bssl::der {
+BSSL_NAMESPACE_BEGIN
+namespace der {
 
 namespace {
 
@@ -104,4 +105,5 @@
   return true;
 }
 
-}  // namespace bssl::der
+}  // namespace der
+BSSL_NAMESPACE_END
diff --git a/pki/encode_values.h b/pki/encode_values.h
index 030c864..f175eeb 100644
--- a/pki/encode_values.h
+++ b/pki/encode_values.h
@@ -10,7 +10,8 @@
 
 #include <openssl/base.h>
 
-namespace bssl::der {
+BSSL_NAMESPACE_BEGIN
+namespace der {
 
 struct GeneralizedTime;
 
@@ -40,6 +41,7 @@
 OPENSSL_EXPORT bool EncodeUTCTime(const GeneralizedTime &time,
                                   uint8_t out[kUTCTimeLength]);
 
-}  // namespace bssl::der
+}  // namespace der
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_DER_ENCODE_VALUES_H_
diff --git a/pki/encode_values_unittest.cc b/pki/encode_values_unittest.cc
index e0a7820..2e60a43 100644
--- a/pki/encode_values_unittest.cc
+++ b/pki/encode_values_unittest.cc
@@ -9,7 +9,8 @@
 #include <gtest/gtest.h>
 #include "parse_values.h"
 
-namespace bssl::der::test {
+BSSL_NAMESPACE_BEGIN
+namespace der::test {
 
 namespace {
 
@@ -166,4 +167,5 @@
   EXPECT_FALSE(EncodeUTCTime(time, out));
 }
 
-}  // namespace bssl::der::test
+}  // namespace der::test
+BSSL_NAMESPACE_END
diff --git a/pki/extended_key_usage.cc b/pki/extended_key_usage.cc
index 1aeeb6a..a3bb1d4 100644
--- a/pki/extended_key_usage.cc
+++ b/pki/extended_key_usage.cc
@@ -9,7 +9,7 @@
 #include "input.h"
 #include "parser.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 bool ParseEKUExtension(der::Input extension_value,
                        std::vector<der::Input> *eku_oids) {
@@ -42,4 +42,4 @@
   return true;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/extended_key_usage.h b/pki/extended_key_usage.h
index c78f157..63f937a 100644
--- a/pki/extended_key_usage.h
+++ b/pki/extended_key_usage.h
@@ -11,7 +11,7 @@
 
 #include "input.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 // The arc for the anyExtendedKeyUsage OID is found under the id-ce arc,
 // defined in section 4.2.1 of RFC 5280:
@@ -78,6 +78,6 @@
 OPENSSL_EXPORT bool ParseEKUExtension(der::Input extension_value,
                                       std::vector<der::Input> *eku_oids);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_EXTENDED_KEY_USAGE_H_
diff --git a/pki/extended_key_usage_unittest.cc b/pki/extended_key_usage_unittest.cc
index b5229a1..b65b49d 100644
--- a/pki/extended_key_usage_unittest.cc
+++ b/pki/extended_key_usage_unittest.cc
@@ -8,7 +8,7 @@
 #include "extended_key_usage.h"
 #include "input.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -164,4 +164,4 @@
 
 }  // namespace
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/general_names.cc b/pki/general_names.cc
index c446287..f88efbb 100644
--- a/pki/general_names.cc
+++ b/pki/general_names.cc
@@ -17,7 +17,7 @@
 #include "parser.h"
 #include "string_util.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 DEFINE_CERT_ERROR_ID(kFailedParsingGeneralName, "Failed parsing GeneralName");
 
@@ -216,4 +216,4 @@
   return true;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/general_names.h b/pki/general_names.h
index 838a2d7..701927e 100644
--- a/pki/general_names.h
+++ b/pki/general_names.h
@@ -14,7 +14,7 @@
 
 #include "cert_error_id.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 class CertErrors;
 
@@ -126,6 +126,6 @@
     GeneralNames::ParseGeneralNameIPAddressType ip_address_type,
     GeneralNames *subtrees, CertErrors *errors);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_GENERAL_NAMES_H_
diff --git a/pki/general_names_unittest.cc b/pki/general_names_unittest.cc
index be508a2..1836c98 100644
--- a/pki/general_names_unittest.cc
+++ b/pki/general_names_unittest.cc
@@ -7,7 +7,7 @@
 #include <gtest/gtest.h>
 #include "test_helpers.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 namespace {
 
 ::testing::AssertionResult LoadTestData(const char *token,
@@ -223,4 +223,4 @@
   EXPECT_EQ(der::Input(expected_der), general_names->registered_ids[0]);
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/input.cc b/pki/input.cc
index 2f5a8b1..f68ece2 100644
--- a/pki/input.cc
+++ b/pki/input.cc
@@ -4,9 +4,8 @@
 
 #include "input.h"
 
-#include <openssl/base.h>
-
-namespace bssl::der {
+BSSL_NAMESPACE_BEGIN
+namespace der {
 
 std::string Input::AsString() const { return std::string(AsStringView()); }
 
@@ -42,4 +41,5 @@
   data_ = data_.subspan(len);
 }
 
-}  // namespace bssl::der
+}  // namespace der
+BSSL_NAMESPACE_END
diff --git a/pki/input.h b/pki/input.h
index 15bdbd6..9337d38 100644
--- a/pki/input.h
+++ b/pki/input.h
@@ -22,9 +22,11 @@
 
 #if defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 201911L
 #include <ranges>
-namespace bssl::der {
+BSSL_NAMESPACE_BEGIN
+namespace der {
 class OPENSSL_EXPORT Input;
 }
+BSSL_NAMESPACE_END
 
 // Mark `Input` as satisfying the `view` and `borrowed_range` concepts. This
 // should be done before the definition of `Input`, so that any inlined calls to
@@ -36,7 +38,8 @@
     true;
 #endif
 
-namespace bssl::der {
+BSSL_NAMESPACE_BEGIN
+namespace der {
 
 // An opaque class that represents a fixed buffer of data of a fixed length,
 // to be used as an input to other operations. An Input object does not own
@@ -188,6 +191,7 @@
   bssl::Span<const uint8_t> data_;
 };
 
-}  // namespace bssl::der
+}  // namespace der
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_DER_INPUT_H_
diff --git a/pki/input_unittest.cc b/pki/input_unittest.cc
index 655a808..6aa009d 100644
--- a/pki/input_unittest.cc
+++ b/pki/input_unittest.cc
@@ -6,7 +6,8 @@
 
 #include <gtest/gtest.h>
 
-namespace bssl::der::test {
+BSSL_NAMESPACE_BEGIN
+namespace der::test {
 
 constexpr uint8_t kInput[] = {'t', 'e', 's', 't'};
 const uint8_t kInput2[] = {'t', 'e', 'a', 'l'};
@@ -104,4 +105,5 @@
   ASSERT_FALSE(reader.HasMore());
 }
 
-}  // namespace bssl::der::test
+}  // namespace der::test
+BSSL_NAMESPACE_END
diff --git a/pki/ip_util.cc b/pki/ip_util.cc
index 663669e..d4996b6 100644
--- a/pki/ip_util.cc
+++ b/pki/ip_util.cc
@@ -4,7 +4,7 @@
 
 #include "ip_util.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 bool IsValidNetmask(der::Input mask) {
   if (mask.size() != kIPv4AddressSize && mask.size() != kIPv6AddressSize) {
@@ -46,4 +46,4 @@
   return true;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/ip_util.h b/pki/ip_util.h
index 3bcc7df..22f27bf 100644
--- a/pki/ip_util.h
+++ b/pki/ip_util.h
@@ -9,7 +9,7 @@
 
 #include "input.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 inline constexpr size_t kIPv4AddressSize = 4;
 inline constexpr size_t kIPv6AddressSize = 16;
@@ -24,6 +24,6 @@
                                                 der::Input addr2,
                                                 der::Input mask);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_IP_UTIL_H_
diff --git a/pki/ip_util_unittest.cc b/pki/ip_util_unittest.cc
index 268a924..251006c 100644
--- a/pki/ip_util_unittest.cc
+++ b/pki/ip_util_unittest.cc
@@ -9,7 +9,7 @@
 #include <gtest/gtest.h>
 #include "input.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 TEST(IPUtilTest, IsValidNetmask) {
   uint8_t kWrongSize[3] = {0xff, 0xff, 0xff};
@@ -104,4 +104,4 @@
   }
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/mock_signature_verify_cache.cc b/pki/mock_signature_verify_cache.cc
index d99f690..28f6f7d 100644
--- a/pki/mock_signature_verify_cache.cc
+++ b/pki/mock_signature_verify_cache.cc
@@ -6,7 +6,7 @@
 
 #include <algorithm>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 MockSignatureVerifyCache::MockSignatureVerifyCache() = default;
 
@@ -29,4 +29,4 @@
   return iter->second;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/mock_signature_verify_cache.h b/pki/mock_signature_verify_cache.h
index f380f61..ff0dc11 100644
--- a/pki/mock_signature_verify_cache.h
+++ b/pki/mock_signature_verify_cache.h
@@ -13,7 +13,7 @@
 
 #include <openssl/pki/signature_verify_cache.h>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 // MockSignatureVerifyCache is an implementation of SignatureVerifyCache.  It is
 // intended only for testing of cache functionality.
@@ -42,6 +42,6 @@
   size_t stores_ = 0;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_MOCK_PATH_BUILDER_DELEGATE_H_
diff --git a/pki/name_constraints.cc b/pki/name_constraints.cc
index 1ce9a8f..933ac21 100644
--- a/pki/name_constraints.cc
+++ b/pki/name_constraints.cc
@@ -21,7 +21,7 @@
 #include "string_util.h"
 #include "verify_name_match.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -707,4 +707,4 @@
   return false;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/name_constraints.h b/pki/name_constraints.h
index a025985..444a40b 100644
--- a/pki/name_constraints.h
+++ b/pki/name_constraints.h
@@ -11,7 +11,7 @@
 
 #include "general_names.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 class CertErrors;
 
@@ -101,6 +101,6 @@
   int constrained_name_types_ = GENERAL_NAME_NONE;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_NAME_CONSTRAINTS_H_
diff --git a/pki/name_constraints_unittest.cc b/pki/name_constraints_unittest.cc
index a715062..1e4ed0a 100644
--- a/pki/name_constraints_unittest.cc
+++ b/pki/name_constraints_unittest.cc
@@ -11,7 +11,7 @@
 #include "common_cert_errors.h"
 #include "test_helpers.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 namespace {
 
 ::testing::AssertionResult LoadTestData(const char *token,
@@ -1901,4 +1901,4 @@
                               nullptr /* subject_alt_names */));
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/nist_pkits_unittest.cc b/pki/nist_pkits_unittest.cc
index 309cb64..5439661 100644
--- a/pki/nist_pkits_unittest.cc
+++ b/pki/nist_pkits_unittest.cc
@@ -8,7 +8,7 @@
 
 #include <sstream>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -97,4 +97,4 @@
   SetPolicySetFromString(policy_names, &user_constrained_policy_set);
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/nist_pkits_unittest.h b/pki/nist_pkits_unittest.h
index 5f9219c..28d4278 100644
--- a/pki/nist_pkits_unittest.h
+++ b/pki/nist_pkits_unittest.h
@@ -11,7 +11,7 @@
 #include "parse_values.h"
 #include "test_helpers.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 // Describes the inputs and outputs (other than the certificates) for
 // the PKITS tests.
@@ -144,6 +144,6 @@
 // Inline the generated test code:
 #include "testdata/nist-pkits/pkits_testcases-inl.h"
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_NIST_PKITS_UNITTEST_H_
diff --git a/pki/ocsp.cc b/pki/ocsp.cc
index 03d6c21..1a30b22 100644
--- a/pki/ocsp.cc
+++ b/pki/ocsp.cc
@@ -17,7 +17,7 @@
 #include "verify_name_match.h"
 #include "verify_signed_data.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 OCSPCertID::OCSPCertID() = default;
 OCSPCertID::~OCSPCertID() = default;
@@ -1120,4 +1120,4 @@
   return std::string(ocsp_responder_url) + "/" + b64_encoded;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/ocsp.h b/pki/ocsp.h
index 5b076dc..a9f11d2 100644
--- a/pki/ocsp.h
+++ b/pki/ocsp.h
@@ -19,7 +19,7 @@
 #include "parser.h"
 #include "signature_algorithm.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 class ParsedCertificate;
 
@@ -310,6 +310,6 @@
     const ParsedCertificate *cert, const ParsedCertificate *issuer,
     std::string_view ocsp_responder_url);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_OCSP_H_
diff --git a/pki/ocsp_revocation_status.h b/pki/ocsp_revocation_status.h
index 2816aad..ce47e84 100644
--- a/pki/ocsp_revocation_status.h
+++ b/pki/ocsp_revocation_status.h
@@ -5,7 +5,7 @@
 #ifndef BSSL_PKI_OCSP_REVOCATION_STATUS_H_
 #define BSSL_PKI_OCSP_REVOCATION_STATUS_H_
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 // This value is histogrammed, so do not re-order or change values, and add
 // new values at the end.
@@ -16,6 +16,6 @@
   MAX_VALUE = UNKNOWN
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_OCSP_REVOCATION_STATUS_H_
diff --git a/pki/ocsp_unittest.cc b/pki/ocsp_unittest.cc
index 98ae8dd..1a65b47 100644
--- a/pki/ocsp_unittest.cc
+++ b/pki/ocsp_unittest.cc
@@ -11,7 +11,7 @@
 #include "string_util.h"
 #include "test_helpers.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -239,4 +239,4 @@
 
 }  // namespace
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/ocsp_verify_result.cc b/pki/ocsp_verify_result.cc
index f343f8e..c094169 100644
--- a/pki/ocsp_verify_result.cc
+++ b/pki/ocsp_verify_result.cc
@@ -4,7 +4,7 @@
 
 #include "ocsp_verify_result.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 OCSPVerifyResult::OCSPVerifyResult() = default;
 OCSPVerifyResult::OCSPVerifyResult(const OCSPVerifyResult &) = default;
@@ -22,4 +22,4 @@
   return true;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/ocsp_verify_result.h b/pki/ocsp_verify_result.h
index 1e07f1a..0b5194c 100644
--- a/pki/ocsp_verify_result.h
+++ b/pki/ocsp_verify_result.h
@@ -9,7 +9,7 @@
 
 #include "ocsp_revocation_status.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 // The result of OCSP verification. This always contains a ResponseStatus, which
 // describes whether or not an OCSP response was provided, and response level
@@ -71,6 +71,6 @@
   OCSPRevocationStatus revocation_status = OCSPRevocationStatus::UNKNOWN;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_OCSP_VERIFY_RESULT_H_
diff --git a/pki/parse_certificate.cc b/pki/parse_certificate.cc
index 5e2ff88..2919104 100644
--- a/pki/parse_certificate.cc
+++ b/pki/parse_certificate.cc
@@ -18,7 +18,7 @@
 #include "parser.h"
 #include "string_util.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -1013,4 +1013,4 @@
   return true;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/parse_certificate.h b/pki/parse_certificate.h
index 81e267f..f133715 100644
--- a/pki/parse_certificate.h
+++ b/pki/parse_certificate.h
@@ -18,7 +18,7 @@
 #include "input.h"
 #include "parse_values.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace der {
 class Parser;
@@ -625,6 +625,6 @@
 [[nodiscard]] OPENSSL_EXPORT bool ParseSubjectKeyIdentifier(
     der::Input extension_value, der::Input *subject_key_identifier);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_PARSE_CERTIFICATE_H_
diff --git a/pki/parse_certificate_unittest.cc b/pki/parse_certificate_unittest.cc
index ec3c642..c541da9 100644
--- a/pki/parse_certificate_unittest.cc
+++ b/pki/parse_certificate_unittest.cc
@@ -12,7 +12,7 @@
 #include "parsed_certificate.h"
 #include "test_helpers.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -1173,4 +1173,4 @@
 
 }  // namespace
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/parse_name.cc b/pki/parse_name.cc
index 2c4695f..3e0821a 100644
--- a/pki/parse_name.cc
+++ b/pki/parse_name.cc
@@ -12,7 +12,7 @@
 #include "parse_values.h"
 #include "string_util.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -231,4 +231,4 @@
   return true;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/parse_name.h b/pki/parse_name.h
index be5c53e..92ebf71 100644
--- a/pki/parse_name.h
+++ b/pki/parse_name.h
@@ -13,7 +13,7 @@
 #include "input.h"
 #include "parser.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 // id-at-commonName: 2.5.4.3 (RFC 5280)
 inline constexpr uint8_t kTypeCommonNameOid[] = {0x55, 0x04, 0x03};
@@ -152,6 +152,6 @@
 // successful.
 [[nodiscard]] OPENSSL_EXPORT bool ConvertToRFC2253(
     const RDNSequence &rdn_sequence, std::string *out);
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_PARSE_NAME_H_
diff --git a/pki/parse_name_unittest.cc b/pki/parse_name_unittest.cc
index ceef9c2..0bb2c6f 100644
--- a/pki/parse_name_unittest.cc
+++ b/pki/parse_name_unittest.cc
@@ -7,7 +7,7 @@
 #include <gtest/gtest.h>
 #include "test_helpers.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 // Loads test data from file. The filename is constructed from the parameters:
@@ -363,4 +363,4 @@
   ASSERT_EQ("SN=Lu\\C4\\8Di\\C4\\87", output);
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/parse_values.cc b/pki/parse_values.cc
index 8d07b3d..d3312c7 100644
--- a/pki/parse_values.cc
+++ b/pki/parse_values.cc
@@ -12,7 +12,8 @@
 #include <openssl/bytestring.h>
 #include <openssl/mem.h>
 
-namespace bssl::der {
+BSSL_NAMESPACE_BEGIN
+namespace der {
 
 namespace {
 
@@ -470,4 +471,5 @@
   return true;
 }
 
-}  // namespace bssl::der
+}  // namespace der
+BSSL_NAMESPACE_END
diff --git a/pki/parse_values.h b/pki/parse_values.h
index 1b7ed12..8f808a8 100644
--- a/pki/parse_values.h
+++ b/pki/parse_values.h
@@ -13,7 +13,8 @@
 
 #include "input.h"
 
-namespace bssl::der {
+BSSL_NAMESPACE_BEGIN
+namespace der {
 
 // Reads a DER-encoded ASN.1 BOOLEAN value from |in| and puts the resulting
 // value in |out|. Returns whether the encoded value could successfully be
@@ -149,6 +150,7 @@
 // result in |out| as UTF-8, returning true if successful.
 [[nodiscard]] OPENSSL_EXPORT bool ParseBmpString(Input in, std::string *out);
 
-}  // namespace bssl::der
+}  // namespace der
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_DER_PARSE_VALUES_H_
diff --git a/pki/parse_values_unittest.cc b/pki/parse_values_unittest.cc
index e29b4b9..a24c4c1 100644
--- a/pki/parse_values_unittest.cc
+++ b/pki/parse_values_unittest.cc
@@ -8,7 +8,8 @@
 
 #include <gtest/gtest.h>
 
-namespace bssl::der::test {
+BSSL_NAMESPACE_BEGIN
+namespace der::test {
 
 namespace {
 
@@ -461,4 +462,5 @@
       ParseUniversalString(der::Input(invalid_non_4_multiple_der), &s));
 }
 
-}  // namespace bssl::der::test
+}  // namespace der::test
+BSSL_NAMESPACE_END
diff --git a/pki/parsed_certificate.cc b/pki/parsed_certificate.cc
index 9e23d30..402a6df 100644
--- a/pki/parsed_certificate.cc
+++ b/pki/parsed_certificate.cc
@@ -15,7 +15,7 @@
 #include "signature_algorithm.h"
 #include "verify_name_match.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -295,4 +295,4 @@
   return true;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/parsed_certificate.h b/pki/parsed_certificate.h
index a4043cb..c39d1a8 100644
--- a/pki/parsed_certificate.h
+++ b/pki/parsed_certificate.h
@@ -17,7 +17,7 @@
 #include "parse_certificate.h"
 #include "signature_algorithm.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 struct GeneralNames;
 class NameConstraints;
@@ -323,6 +323,6 @@
   ExtensionsMap extensions_;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_PARSED_CERTIFICATE_H_
diff --git a/pki/parsed_certificate_unittest.cc b/pki/parsed_certificate_unittest.cc
index f515003..2babc5b 100644
--- a/pki/parsed_certificate_unittest.cc
+++ b/pki/parsed_certificate_unittest.cc
@@ -13,7 +13,7 @@
 
 // TODO(eroman): Add tests for parsing of policy mappings.
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -594,4 +594,4 @@
 
 }  // namespace
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/parser.cc b/pki/parser.cc
index 51f2661..4ae7648 100644
--- a/pki/parser.cc
+++ b/pki/parser.cc
@@ -4,10 +4,10 @@
 
 #include "parser.h"
 
-#include <openssl/base.h>
 #include "parse_values.h"
 
-namespace bssl::der {
+BSSL_NAMESPACE_BEGIN
+namespace der {
 
 Parser::Parser() { CBS_init(&cbs_, nullptr, 0); }
 
@@ -157,4 +157,5 @@
   return ParseGeneralizedTime(value, out);
 }
 
-}  // namespace bssl::der
+}  // namespace der
+BSSL_NAMESPACE_END
diff --git a/pki/parser.h b/pki/parser.h
index 64599b5..f2cdcc8 100644
--- a/pki/parser.h
+++ b/pki/parser.h
@@ -14,7 +14,8 @@
 
 #include "input.h"
 
-namespace bssl::der {
+BSSL_NAMESPACE_BEGIN
+namespace der {
 
 class BitString;
 struct GeneralizedTime;
@@ -207,6 +208,7 @@
   size_t advance_len_ = 0;
 };
 
-}  // namespace bssl::der
+}  // namespace der
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_DER_PARSER_H_
diff --git a/pki/parser_unittest.cc b/pki/parser_unittest.cc
index 2deb1cd..34138bc 100644
--- a/pki/parser_unittest.cc
+++ b/pki/parser_unittest.cc
@@ -8,7 +8,8 @@
 #include "input.h"
 #include "parse_values.h"
 
-namespace bssl::der::test {
+BSSL_NAMESPACE_BEGIN
+namespace der::test {
 
 TEST(ParserTest, ConsumesAllBytesOfTLV) {
   const uint8_t der[] = {0x04 /* OCTET STRING */, 0x00};
@@ -362,4 +363,5 @@
   EXPECT_FALSE(bit_string.has_value());
 }
 
-}  // namespace bssl::der::test
+}  // namespace der::test
+BSSL_NAMESPACE_END
diff --git a/pki/path_builder.cc b/pki/path_builder.cc
index ef23172..806cef9 100644
--- a/pki/path_builder.cc
+++ b/pki/path_builder.cc
@@ -24,7 +24,7 @@
 #include "verify_certificate_chain.h"
 #include "verify_name_match.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -1044,4 +1044,4 @@
   out_result_.paths.push_back(std::move(result_path));
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/path_builder.h b/pki/path_builder.h
index fd207f7..42a16eb 100644
--- a/pki/path_builder.h
+++ b/pki/path_builder.h
@@ -18,7 +18,7 @@
 #include "trust_store.h"
 #include "verify_certificate_chain.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace der {
 struct GeneralizedTime;
@@ -258,6 +258,6 @@
   size_t valid_path_count_ = 0;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_PATH_BUILDER_H_
diff --git a/pki/path_builder_pkits_unittest.cc b/pki/path_builder_pkits_unittest.cc
index 5bc0703..ba10b58 100644
--- a/pki/path_builder_pkits_unittest.cc
+++ b/pki/path_builder_pkits_unittest.cc
@@ -22,7 +22,7 @@
 
 constexpr int64_t kOneYear = 60 * 60 * 24 * 365;
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -289,4 +289,4 @@
                                PkitsTest16PrivateCertificateExtensions,
                                PathBuilderPkitsTestDelegate);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/path_builder_unittest.cc b/pki/path_builder_unittest.cc
index 05d9619..b92cfab 100644
--- a/pki/path_builder_unittest.cc
+++ b/pki/path_builder_unittest.cc
@@ -22,7 +22,7 @@
 #include <gtest/gtest.h>
 #include <openssl/pool.h>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 // TODO(crbug.com/634443): Assert the errors for each ResultPath.
 
@@ -2921,4 +2921,4 @@
 
 }  // namespace
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/path_builder_verify_certificate_chain_unittest.cc b/pki/path_builder_verify_certificate_chain_unittest.cc
index a5aeef7..94da678 100644
--- a/pki/path_builder_verify_certificate_chain_unittest.cc
+++ b/pki/path_builder_verify_certificate_chain_unittest.cc
@@ -9,7 +9,7 @@
 #include "trust_store_in_memory.h"
 #include "verify_certificate_chain_typed_unittest.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -53,4 +53,4 @@
                                VerifyCertificateChainSingleRootTest,
                                PathBuilderTestDelegate);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/pem.cc b/pki/pem.cc
index 63d7c45..d7f5f93 100644
--- a/pki/pem.cc
+++ b/pki/pem.cc
@@ -15,7 +15,7 @@
 
 }  // namespace
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 
 
@@ -140,4 +140,4 @@
   return pem_encoded;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/pem.h b/pki/pem.h
index 1fd28fb..c9f4314 100644
--- a/pki/pem.h
+++ b/pki/pem.h
@@ -13,7 +13,7 @@
 
 #include <openssl/base.h>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 // PEMTokenizer is a utility class for the parsing of data encapsulated
 // using RFC 1421, Privacy Enhancement for Internet Electronic Mail. It
@@ -81,6 +81,6 @@
 OPENSSL_EXPORT std::string PEMEncode(std::string_view data,
                                      const std::string &type);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_PEM_H_
diff --git a/pki/pem_unittest.cc b/pki/pem_unittest.cc
index a7f9eda..5fb3d1c 100644
--- a/pki/pem_unittest.cc
+++ b/pki/pem_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <gtest/gtest.h>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 TEST(PEMTokenizerTest, BasicParsing) {
   const char data[] =
@@ -202,4 +202,4 @@
                 "WRAPPED LINE"));
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/revocation_util.cc b/pki/revocation_util.cc
index 80779d7..997f12d 100644
--- a/pki/revocation_util.cc
+++ b/pki/revocation_util.cc
@@ -7,7 +7,7 @@
 #include "encode_values.h"
 #include "parse_values.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -56,4 +56,4 @@
   return true;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/revocation_util.h b/pki/revocation_util.h
index 5b20f4c..f4226d3 100644
--- a/pki/revocation_util.h
+++ b/pki/revocation_util.h
@@ -10,7 +10,7 @@
 
 #include <openssl/base.h>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace der {
 struct GeneralizedTime;
@@ -26,6 +26,6 @@
     const der::GeneralizedTime *next_update, int64_t verify_time_epoch_seconds,
     std::optional<int64_t> max_age_seconds);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_REVOCATION_UTIL_H_
diff --git a/pki/signature_algorithm.cc b/pki/signature_algorithm.cc
index 73d8bc1..f00eee2 100644
--- a/pki/signature_algorithm.cc
+++ b/pki/signature_algorithm.cc
@@ -11,7 +11,7 @@
 #include "parse_values.h"
 #include "parser.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -422,4 +422,4 @@
   return std::nullopt;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/signature_algorithm.h b/pki/signature_algorithm.h
index be654fc..74470b7 100644
--- a/pki/signature_algorithm.h
+++ b/pki/signature_algorithm.h
@@ -12,7 +12,7 @@
 #include <openssl/base.h>
 #include <openssl/evp.h>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace der {
 class Input;
@@ -81,6 +81,6 @@
 OPENSSL_EXPORT std::optional<DigestAlgorithm>
 GetTlsServerEndpointDigestAlgorithm(SignatureAlgorithm alg);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_SIGNATURE_ALGORITHM_H_
diff --git a/pki/signature_algorithm_unittest.cc b/pki/signature_algorithm_unittest.cc
index dc0bfa6..0ca3260 100644
--- a/pki/signature_algorithm_unittest.cc
+++ b/pki/signature_algorithm_unittest.cc
@@ -10,7 +10,7 @@
 #include "input.h"
 #include "parser.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -1448,4 +1448,4 @@
 
 }  // namespace
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/simple_path_builder_delegate.cc b/pki/simple_path_builder_delegate.cc
index 89000e3..29306d5 100644
--- a/pki/simple_path_builder_delegate.cc
+++ b/pki/simple_path_builder_delegate.cc
@@ -19,7 +19,7 @@
 #include "signature_algorithm.h"
 #include "verify_signed_data.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 DEFINE_CERT_ERROR_ID(SimplePathBuilderDelegate::kRsaModulusTooSmall,
                      "RSA modulus too small");
@@ -127,4 +127,4 @@
   return false;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/simple_path_builder_delegate.h b/pki/simple_path_builder_delegate.h
index 6d95b0d..8cfaa7f 100644
--- a/pki/simple_path_builder_delegate.h
+++ b/pki/simple_path_builder_delegate.h
@@ -13,7 +13,7 @@
 #include "path_builder.h"
 #include "signature_algorithm.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 class CertErrors;
 
@@ -78,6 +78,6 @@
   const DigestPolicy digest_policy_;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_SIMPLE_PATH_BUILDER_DELEGATE_H_
diff --git a/pki/simple_path_builder_delegate_unittest.cc b/pki/simple_path_builder_delegate_unittest.cc
index f0131fa..b9fa818 100644
--- a/pki/simple_path_builder_delegate_unittest.cc
+++ b/pki/simple_path_builder_delegate_unittest.cc
@@ -16,7 +16,7 @@
 #include "test_helpers.h"
 #include "verify_signed_data.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -103,4 +103,4 @@
 
 }  // namespace
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/string_util.cc b/pki/string_util.cc
index 423cd76..1cf8ea3 100644
--- a/pki/string_util.cc
+++ b/pki/string_util.cc
@@ -12,7 +12,8 @@
 #include <openssl/base64.h>
 #include <openssl/mem.h>
 
-namespace bssl::string_util {
+BSSL_NAMESPACE_BEGIN
+namespace string_util {
 
 bool IsAscii(std::string_view str) {
   for (unsigned char c : str) {
@@ -190,4 +191,5 @@
   return true;
 }
 
-}  // namespace bssl::string_util
+}  // namespace string_util
+BSSL_NAMESPACE_END
diff --git a/pki/string_util.h b/pki/string_util.h
index 1dad828..2a51809 100644
--- a/pki/string_util.h
+++ b/pki/string_util.h
@@ -13,7 +13,8 @@
 #include <openssl/base.h>
 #include <openssl/span.h>
 
-namespace bssl::string_util {
+BSSL_NAMESPACE_BEGIN
+namespace string_util {
 
 // Returns true if the characters in |str| are all ASCII, false otherwise.
 OPENSSL_EXPORT bool IsAscii(std::string_view str);
@@ -70,6 +71,7 @@
 OPENSSL_EXPORT bool Base64Decode(const std::string_view &input,
                                  std::string *output);
 
-}  // namespace bssl::string_util
+}  // namespace string_util
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_STRING_UTIL_H_
diff --git a/pki/string_util_unittest.cc b/pki/string_util_unittest.cc
index 32e446d..2faa561 100644
--- a/pki/string_util_unittest.cc
+++ b/pki/string_util_unittest.cc
@@ -5,7 +5,7 @@
 #include "string_util.h"
 #include <gtest/gtest.h>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -152,4 +152,4 @@
 
 }  // namespace
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/test_helpers.cc b/pki/test_helpers.cc
index 0615008..82704aa 100644
--- a/pki/test_helpers.cc
+++ b/pki/test_helpers.cc
@@ -26,7 +26,7 @@
 #include "string_util.h"
 #include "trust_store.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -483,4 +483,4 @@
   }
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/test_helpers.h b/pki/test_helpers.h
index 91d74ce..8f3594a 100644
--- a/pki/test_helpers.h
+++ b/pki/test_helpers.h
@@ -19,7 +19,7 @@
 #include "trust_store.h"
 #include "verify_certificate_chain.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace der {
 
@@ -162,6 +162,6 @@
     const std::set<der::Input> &actual_user_constrained_policy_set,
     const std::string &errors_file_path);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_TEST_HELPERS_H_
diff --git a/pki/trust_store.cc b/pki/trust_store.cc
index fc373f7..126df3e 100644
--- a/pki/trust_store.cc
+++ b/pki/trust_store.cc
@@ -8,7 +8,7 @@
 
 #include "string_util.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -174,4 +174,4 @@
   out_req->reset();
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/trust_store.h b/pki/trust_store.h
index 5493f6b..736970f 100644
--- a/pki/trust_store.h
+++ b/pki/trust_store.h
@@ -12,7 +12,7 @@
 #include "cert_issuer_source.h"
 #include "parsed_certificate.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 enum class CertificateTrustType {
   // This certificate is explicitly blocked (distrusted).
@@ -139,6 +139,6 @@
                          std::unique_ptr<Request> *out_req) final;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_TRUST_STORE_H_
diff --git a/pki/trust_store_collection.cc b/pki/trust_store_collection.cc
index 4c607b5..9540065 100644
--- a/pki/trust_store_collection.cc
+++ b/pki/trust_store_collection.cc
@@ -6,7 +6,7 @@
 
 #include <openssl/base.h>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 TrustStoreCollection::TrustStoreCollection() = default;
 TrustStoreCollection::~TrustStoreCollection() = default;
@@ -44,4 +44,4 @@
   return result;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/trust_store_collection.h b/pki/trust_store_collection.h
index 494909e..04c8f3e 100644
--- a/pki/trust_store_collection.h
+++ b/pki/trust_store_collection.h
@@ -9,7 +9,7 @@
 
 #include "trust_store.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 // TrustStoreCollection is an implementation of TrustStore which combines the
 // results from multiple TrustStores.
@@ -38,6 +38,6 @@
   std::vector<TrustStore *> stores_;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_TRUST_STORE_COLLECTION_H_
diff --git a/pki/trust_store_collection_unittest.cc b/pki/trust_store_collection_unittest.cc
index 94989ba..a04c64f 100644
--- a/pki/trust_store_collection_unittest.cc
+++ b/pki/trust_store_collection_unittest.cc
@@ -8,7 +8,7 @@
 #include "test_helpers.h"
 #include "trust_store_in_memory.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -185,4 +185,4 @@
 
 }  // namespace
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/trust_store_in_memory.cc b/pki/trust_store_in_memory.cc
index 1c77b63..89a4eb2 100644
--- a/pki/trust_store_in_memory.cc
+++ b/pki/trust_store_in_memory.cc
@@ -4,7 +4,7 @@
 
 #include "trust_store_in_memory.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 TrustStoreInMemory::TrustStoreInMemory() = default;
 TrustStoreInMemory::~TrustStoreInMemory() = default;
@@ -98,4 +98,4 @@
   return nullptr;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/trust_store_in_memory.h b/pki/trust_store_in_memory.h
index 4da26cd..03d06be 100644
--- a/pki/trust_store_in_memory.h
+++ b/pki/trust_store_in_memory.h
@@ -12,7 +12,7 @@
 
 #include "trust_store.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 // A very simple implementation of a TrustStore, which contains a set of
 // certificates and their trustedness.
@@ -96,6 +96,6 @@
   const Entry *GetEntry(const ParsedCertificate *cert) const;
 };
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_TRUST_STORE_IN_MEMORY_H_
diff --git a/pki/trust_store_in_memory_unittest.cc b/pki/trust_store_in_memory_unittest.cc
index 4292675..9020535 100644
--- a/pki/trust_store_in_memory_unittest.cc
+++ b/pki/trust_store_in_memory_unittest.cc
@@ -17,7 +17,7 @@
 #include <gtest/gtest.h>
 #include "test_helpers.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 namespace {
 
 class TrustStoreInMemoryTest : public testing::Test {
@@ -109,4 +109,4 @@
 }
 
 }  // namespace
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/verify.cc b/pki/verify.cc
index 6bd9dc2..157a6b6 100644
--- a/pki/verify.cc
+++ b/pki/verify.cc
@@ -41,7 +41,7 @@
 #include "trust_store_in_memory.h"
 #include "verify_certificate_chain.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -351,4 +351,4 @@
   return CertificateVerifyInternal(opts, nullptr, nullptr, /*all_paths=*/true);
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/verify_certificate_chain.cc b/pki/verify_certificate_chain.cc
index 4985ae9..e72915f 100644
--- a/pki/verify_certificate_chain.cc
+++ b/pki/verify_certificate_chain.cc
@@ -19,7 +19,7 @@
 #include "trust_store.h"
 #include "verify_signed_data.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -1677,4 +1677,4 @@
   return true;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/verify_certificate_chain.h b/pki/verify_certificate_chain.h
index 4603ace..8daf64f 100644
--- a/pki/verify_certificate_chain.h
+++ b/pki/verify_certificate_chain.h
@@ -15,7 +15,7 @@
 #include "input.h"
 #include "parsed_certificate.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace der {
 struct GeneralizedTime;
@@ -270,6 +270,6 @@
                                                   SignatureVerifyCache *cache,
                                                   CertErrors *errors);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_VERIFY_CERTIFICATE_CHAIN_H_
diff --git a/pki/verify_certificate_chain_pkits_unittest.cc b/pki/verify_certificate_chain_pkits_unittest.cc
index 98d1504..d3f641f 100644
--- a/pki/verify_certificate_chain_pkits_unittest.cc
+++ b/pki/verify_certificate_chain_pkits_unittest.cc
@@ -19,7 +19,7 @@
 
 #include "nist_pkits_unittest.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -126,4 +126,4 @@
 // PkitsTest05VerifyingPathswithSelfIssuedCertificates,
 // PkitsTest14DistributionPoints, PkitsTest15DeltaCRLs
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/verify_certificate_chain_typed_unittest.h b/pki/verify_certificate_chain_typed_unittest.h
index e9948e1..4f85959 100644
--- a/pki/verify_certificate_chain_typed_unittest.h
+++ b/pki/verify_certificate_chain_typed_unittest.h
@@ -13,7 +13,7 @@
 #include "trust_store.h"
 #include "verify_certificate_chain.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 template <typename TestDelegate>
 class VerifyCertificateChainTest : public ::testing::Test {
@@ -343,6 +343,6 @@
                             TrustAnchorNotSelfSigned, KeyRollover, Policies,
                             ManyNames, TargetOnly, TargetSelfSigned);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_VERIFY_CERTIFICATE_CHAIN_TYPED_UNITTEST_H_
diff --git a/pki/verify_certificate_chain_unittest.cc b/pki/verify_certificate_chain_unittest.cc
index 5ea3e08..1d9be6f 100644
--- a/pki/verify_certificate_chain_unittest.cc
+++ b/pki/verify_certificate_chain_unittest.cc
@@ -12,7 +12,7 @@
 #include "trust_store.h"
 #include "verify_certificate_chain_typed_unittest.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -125,4 +125,4 @@
   EXPECT_EQ(cache.CacheStores(), 1U);
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/verify_error.cc b/pki/verify_error.cc
index da61236..688b4e2 100644
--- a/pki/verify_error.cc
+++ b/pki/verify_error.cc
@@ -1,7 +1,7 @@
 #include <openssl/base.h>
 #include <openssl/pki/verify_error.h>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 VerifyError::VerifyError(StatusCode code, ptrdiff_t offset,
                          std::string diagnostic)
@@ -13,4 +13,4 @@
 
 VerifyError::StatusCode VerifyError::Code() const { return code_; }
 
-}  // namespacee bssl
+BSSL_NAMESPACE_END
diff --git a/pki/verify_name_match.cc b/pki/verify_name_match.cc
index 09f6102..e849d90 100644
--- a/pki/verify_name_match.cc
+++ b/pki/verify_name_match.cc
@@ -13,7 +13,7 @@
 #include "parse_name.h"
 #include "parser.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 DEFINE_CERT_ERROR_ID(kFailedConvertingAttributeValue,
                      "Failed converting AttributeValue to string");
@@ -435,4 +435,4 @@
   return true;
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/verify_name_match.h b/pki/verify_name_match.h
index 79c9ce8..188c7d5 100644
--- a/pki/verify_name_match.h
+++ b/pki/verify_name_match.h
@@ -10,7 +10,7 @@
 
 #include <openssl/base.h>
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 class CertErrors;
 
@@ -56,6 +56,6 @@
     der::Input name_rdn_sequence,
     std::vector<std::string> *contained_email_addresses);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_VERIFY_NAME_MATCH_H_
diff --git a/pki/verify_name_match_unittest.cc b/pki/verify_name_match_unittest.cc
index 53cd012..77df501 100644
--- a/pki/verify_name_match_unittest.cc
+++ b/pki/verify_name_match_unittest.cc
@@ -8,7 +8,7 @@
 #include "string_util.h"
 #include "test_helpers.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 namespace {
 
 // Loads test data from file. The filename is constructed from the parameters:
@@ -605,4 +605,4 @@
   EXPECT_EQ(SequenceValueFromString(raw_der), der::Input(normalized_der));
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/verify_signed_data.cc b/pki/verify_signed_data.cc
index 4502e2d..9c546fd 100644
--- a/pki/verify_signed_data.cc
+++ b/pki/verify_signed_data.cc
@@ -18,7 +18,7 @@
 #include "parser.h"
 #include "signature_algorithm.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -290,4 +290,4 @@
                           public_key.get(), cache);
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/verify_signed_data.h b/pki/verify_signed_data.h
index 5ecfcea..e8c4c4d 100644
--- a/pki/verify_signed_data.h
+++ b/pki/verify_signed_data.h
@@ -11,7 +11,7 @@
 
 #include "signature_algorithm.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace der {
 class BitString;
@@ -42,6 +42,6 @@
 [[nodiscard]] OPENSSL_EXPORT bool ParsePublicKey(
     der::Input public_key_spki, bssl::UniquePtr<EVP_PKEY> *public_key);
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
 
 #endif  // BSSL_PKI_VERIFY_SIGNED_DATA_H_
diff --git a/pki/verify_signed_data_unittest.cc b/pki/verify_signed_data_unittest.cc
index 1d94bb6..1a02322 100644
--- a/pki/verify_signed_data_unittest.cc
+++ b/pki/verify_signed_data_unittest.cc
@@ -17,7 +17,7 @@
 #include "signature_algorithm.h"
 #include "test_helpers.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 namespace {
 
@@ -238,4 +238,4 @@
 
 }  // namespace
 
-}  // namespace bssl
+BSSL_NAMESPACE_END
diff --git a/pki/verify_unittest.cc b/pki/verify_unittest.cc
index b724a98..0be540b 100644
--- a/pki/verify_unittest.cc
+++ b/pki/verify_unittest.cc
@@ -25,7 +25,7 @@
 
 #include "test_helpers.h"
 
-namespace bssl {
+BSSL_NAMESPACE_BEGIN
 
 static std::unique_ptr<VerifyTrustStore> MozillaRootStore() {
   std::string diagnostic;
@@ -137,4 +137,4 @@
       << error.DiagnosticString();
 }
 
-}  // namespace bssl
+BSSL_NAMESPACE_END