Namespace crypto/asn1's internal symbols.

Down from 428 to 373 unintended exported symbols.

Bug: 42220000
Change-Id: I941b1fd365b16cf621e0a6057721c7806a6a6964
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/86668
Reviewed-by: Xiangfei Ding <xfding@google.com>
Commit-Queue: Rudolf Polzer <rpolzer@google.com>
diff --git a/crypto/asn1/a_bitstr.cc b/crypto/asn1/a_bitstr.cc
index 3c97ccb..b7394c0 100644
--- a/crypto/asn1/a_bitstr.cc
+++ b/crypto/asn1/a_bitstr.cc
@@ -26,13 +26,15 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, const unsigned char *d,
                         ossl_ssize_t len) {
   return ASN1_STRING_set(x, d, len);
 }
 
-int asn1_bit_string_length(const ASN1_BIT_STRING *str,
-                           uint8_t *out_padding_bits) {
+int bssl::asn1_bit_string_length(const ASN1_BIT_STRING *str,
+                                 uint8_t *out_padding_bits) {
   int len = str->length;
   if (str->flags & ASN1_STRING_FLAG_BITS_LEFT) {
     // If the string is already empty, it cannot have padding bits.
@@ -96,8 +98,8 @@
   return ret;
 }
 
-int asn1_marshal_bit_string(CBB *out, const ASN1_BIT_STRING *in,
-                            CBS_ASN1_TAG tag) {
+int bssl::asn1_marshal_bit_string(CBB *out, const ASN1_BIT_STRING *in,
+                                  CBS_ASN1_TAG tag) {
   int len = i2c_ASN1_BIT_STRING(in, nullptr);
   if (len <= 0) {
     return 0;
@@ -111,7 +113,7 @@
          CBB_flush(out);
 }
 
-static int asn1_parse_bit_string_contents(bssl::Span<const uint8_t> in,
+static int asn1_parse_bit_string_contents(Span<const uint8_t> in,
                                           ASN1_BIT_STRING *out) {
   CBS cbs = in;
   uint8_t padding;
@@ -163,7 +165,7 @@
     ret = *a;
   }
 
-  if (!asn1_parse_bit_string_contents(bssl::Span(*pp, len), ret)) {
+  if (!asn1_parse_bit_string_contents(Span(*pp, len), ret)) {
     if (ret != nullptr && (a == nullptr || *a != ret)) {
       ASN1_BIT_STRING_free(ret);
     }
@@ -177,7 +179,8 @@
   return ret;
 }
 
-int asn1_parse_bit_string(CBS *cbs, ASN1_BIT_STRING *out, CBS_ASN1_TAG tag) {
+int bssl::asn1_parse_bit_string(CBS *cbs, ASN1_BIT_STRING *out,
+                                CBS_ASN1_TAG tag) {
   tag = tag == 0 ? CBS_ASN1_BITSTRING : tag;
   CBS child;
   if (!CBS_get_asn1(cbs, &child, tag)) {
@@ -187,7 +190,8 @@
   return asn1_parse_bit_string_contents(child, out);
 }
 
-int asn1_parse_bit_string_with_bad_length(CBS *cbs, ASN1_BIT_STRING *out) {
+int bssl::asn1_parse_bit_string_with_bad_length(CBS *cbs,
+                                                ASN1_BIT_STRING *out) {
   CBS child;
   CBS_ASN1_TAG tag;
   size_t header_len;
diff --git a/crypto/asn1/a_gentm.cc b/crypto/asn1/a_gentm.cc
index 56b6ba4..1dd22be 100644
--- a/crypto/asn1/a_gentm.cc
+++ b/crypto/asn1/a_gentm.cc
@@ -24,7 +24,11 @@
 
 #include "internal.h"
 
-int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d) {
+
+using namespace bssl;
+
+int bssl::asn1_generalizedtime_to_tm(struct tm *tm,
+                                     const ASN1_GENERALIZEDTIME *d) {
   if (d->type != V_ASN1_GENERALIZEDTIME) {
     return 0;
   }
@@ -36,8 +40,8 @@
   return 1;
 }
 
-int asn1_parse_generalized_time(CBS *cbs, ASN1_GENERALIZEDTIME *out,
-                                CBS_ASN1_TAG tag) {
+int bssl::asn1_parse_generalized_time(CBS *cbs, ASN1_GENERALIZEDTIME *out,
+                                      CBS_ASN1_TAG tag) {
   tag = tag == 0 ? CBS_ASN1_GENERALIZEDTIME : tag;
   CBS child;
   if (!CBS_get_asn1(cbs, &child, tag) ||
diff --git a/crypto/asn1/a_int.cc b/crypto/asn1/a_int.cc
index 5e6d3ff..216c9da 100644
--- a/crypto/asn1/a_int.cc
+++ b/crypto/asn1/a_int.cc
@@ -27,6 +27,8 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x) {
   return ASN1_STRING_dup(x);
 }
@@ -74,7 +76,8 @@
   return 1;
 }
 
-int asn1_marshal_integer(CBB *out, const ASN1_INTEGER *in, CBS_ASN1_TAG tag) {
+int bssl::asn1_marshal_integer(CBB *out, const ASN1_INTEGER *in,
+                               CBS_ASN1_TAG tag) {
   int len = i2c_ASN1_INTEGER(in, nullptr);
   if (len <= 0) {
     return 0;
@@ -147,7 +150,7 @@
   return len;
 }
 
-static int asn1_parse_integer_contents(bssl::Span<const uint8_t> in,
+static int asn1_parse_integer_contents(Span<const uint8_t> in,
                                        ASN1_INTEGER *out) {
   CBS cbs = in;
   int is_negative;
@@ -192,7 +195,7 @@
   return 1;
 }
 
-int asn1_parse_integer(CBS *cbs, ASN1_INTEGER *out, CBS_ASN1_TAG tag) {
+int bssl::asn1_parse_integer(CBS *cbs, ASN1_INTEGER *out, CBS_ASN1_TAG tag) {
   tag = tag == 0 ? CBS_ASN1_INTEGER : tag;
   CBS child;
   if (!CBS_get_asn1(cbs, &child, tag)) {
@@ -202,7 +205,8 @@
   return asn1_parse_integer_contents(child, out);
 }
 
-int asn1_parse_enumerated(CBS *cbs, ASN1_ENUMERATED *out, CBS_ASN1_TAG tag) {
+int bssl::asn1_parse_enumerated(CBS *cbs, ASN1_ENUMERATED *out,
+                                CBS_ASN1_TAG tag) {
   tag = tag == 0 ? CBS_ASN1_ENUMERATED : tag;
   if (!asn1_parse_integer(cbs, out, tag)) {
     return 0;
@@ -230,7 +234,7 @@
     ret = *out;
   }
 
-  if (!asn1_parse_integer_contents(bssl::Span(*inp, len), ret)) {
+  if (!asn1_parse_integer_contents(Span(*inp, len), ret)) {
     if (ret != nullptr && (out == nullptr || *out != ret)) {
       ASN1_INTEGER_free(ret);
     }
diff --git a/crypto/asn1/a_mbstr.cc b/crypto/asn1/a_mbstr.cc
index ddea75e..c70bb3b 100644
--- a/crypto/asn1/a_mbstr.cc
+++ b/crypto/asn1/a_mbstr.cc
@@ -24,6 +24,9 @@
 #include "../bytestring/internal.h"
 #include "internal.h"
 
+
+using namespace bssl;
+
 // These functions take a string in UTF8, ASCII or multibyte form and a mask
 // of permissible ASN1 string types. It then works out the minimal type
 // (using the order Printable < IA5 < T61 < BMP < Universal < UTF8) and
@@ -228,7 +231,7 @@
   return -1;
 }
 
-int asn1_is_printable(uint32_t value) {
+int bssl::asn1_is_printable(uint32_t value) {
   if (value > 0x7f) {
     return 0;
   }
diff --git a/crypto/asn1/a_object.cc b/crypto/asn1/a_object.cc
index 0f667f3..a3143b7 100644
--- a/crypto/asn1/a_object.cc
+++ b/crypto/asn1/a_object.cc
@@ -27,7 +27,10 @@
 #include "internal.h"
 
 
-int asn1_marshal_object(CBB *out, const ASN1_OBJECT *in, CBS_ASN1_TAG tag) {
+using namespace bssl;
+
+int bssl::asn1_marshal_object(CBB *out, const ASN1_OBJECT *in,
+                              CBS_ASN1_TAG tag) {
   if (in == nullptr) {
     OPENSSL_PUT_ERROR(ASN1, ERR_R_PASSED_NULL_PARAMETER);
     return 0;
@@ -43,7 +46,7 @@
 }
 
 int i2d_ASN1_OBJECT(const ASN1_OBJECT *in, unsigned char **outp) {
-  return bssl::I2DFromCBB(
+  return I2DFromCBB(
       /*initial_capacity=*/static_cast<size_t>(in->length) + 2, outp,
       [&](CBB *cbb) -> bool {
         return asn1_marshal_object(cbb, in, /*tag=*/0);
@@ -91,7 +94,7 @@
 
 ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **out, const unsigned char **inp,
                              long len) {
-  return bssl::D2IFromCBS(out, inp, len, [](CBS *cbs) -> ASN1_OBJECT * {
+  return D2IFromCBS(out, inp, len, [](CBS *cbs) -> ASN1_OBJECT * {
     CBS child;
     if (!CBS_get_asn1(cbs, &child, CBS_ASN1_OBJECT)) {
       OPENSSL_PUT_ERROR(ASN1, ASN1_R_DECODE_ERROR);
@@ -104,7 +107,7 @@
 
 ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **out, const unsigned char **inp,
                              long len) {
-  return bssl::D2IFromCBS(out, inp, len, [](CBS *cbs) -> ASN1_OBJECT * {
+  return D2IFromCBS(out, inp, len, [](CBS *cbs) -> ASN1_OBJECT * {
     if (!CBS_is_valid_asn1_oid(cbs)) {
       OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_OBJECT_ENCODING);
       return nullptr;
@@ -120,7 +123,7 @@
   });
 }
 
-ASN1_OBJECT *asn1_parse_object(CBS *cbs, CBS_ASN1_TAG tag) {
+ASN1_OBJECT *bssl::asn1_parse_object(CBS *cbs, CBS_ASN1_TAG tag) {
   tag = tag == 0 ? CBS_ASN1_OBJECT : tag;
   CBS child;
   if (!CBS_get_asn1(cbs, &child, tag)) {
@@ -135,7 +138,7 @@
                             /*sn=*/nullptr, /*ln=*/nullptr);
 }
 
-ASN1_OBJECT *ASN1_OBJECT_new() {
+ASN1_OBJECT *bssl::ASN1_OBJECT_new() {
   ASN1_OBJECT *ret;
 
   ret = (ASN1_OBJECT *)OPENSSL_malloc(sizeof(ASN1_OBJECT));
diff --git a/crypto/asn1/a_strex.cc b/crypto/asn1/a_strex.cc
index 3c9978a..bddcfcb 100644
--- a/crypto/asn1/a_strex.cc
+++ b/crypto/asn1/a_strex.cc
@@ -30,6 +30,8 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 #define ESC_FLAGS                                                           \
   (ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_QUOTE | ASN1_STRFLGS_ESC_CTRL | \
    ASN1_STRFLGS_ESC_MSB)
diff --git a/crypto/asn1/a_strnid.cc b/crypto/asn1/a_strnid.cc
index 18ae288..5c40fd9 100644
--- a/crypto/asn1/a_strnid.cc
+++ b/crypto/asn1/a_strnid.cc
@@ -46,7 +46,7 @@
 
 int ASN1_STRING_set_default_mask_asc(const char *p) { return 1; }
 
-static const ASN1_STRING_TABLE *asn1_string_table_get(int nid);
+static const bssl::ASN1_STRING_TABLE *asn1_string_table_get(int nid);
 
 // The following function generates an ASN1_STRING based on limits in a
 // table. Frequently the types and length of an ASN1_STRING are restricted by
@@ -90,7 +90,7 @@
 
 // This table must be kept in NID order
 
-static const ASN1_STRING_TABLE tbl_standard[] = {
+static const bssl::ASN1_STRING_TABLE tbl_standard[] = {
     {NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0},
     {NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
     {NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0},
@@ -133,7 +133,7 @@
   return OPENSSL_hash32(&tbl->nid, sizeof(tbl->nid));
 }
 
-static const ASN1_STRING_TABLE *asn1_string_table_get(int nid) {
+static const bssl::ASN1_STRING_TABLE *asn1_string_table_get(int nid) {
   ASN1_STRING_TABLE key;
   key.nid = nid;
   const ASN1_STRING_TABLE *tbl = reinterpret_cast<ASN1_STRING_TABLE *>(
@@ -207,8 +207,8 @@
 
 void ASN1_STRING_TABLE_cleanup() {}
 
-void asn1_get_string_table_for_testing(const ASN1_STRING_TABLE **out_ptr,
-                                       size_t *out_len) {
+void bssl::asn1_get_string_table_for_testing(const ASN1_STRING_TABLE **out_ptr,
+                                             size_t *out_len) {
   *out_ptr = tbl_standard;
   *out_len = std::size(tbl_standard);
 }
diff --git a/crypto/asn1/a_time.cc b/crypto/asn1/a_time.cc
index af240a9..a12bfd7 100644
--- a/crypto/asn1/a_time.cc
+++ b/crypto/asn1/a_time.cc
@@ -25,12 +25,19 @@
 
 #include "internal.h"
 
+
+using namespace bssl;
+
 // This is an implementation of the ASN1 Time structure which is: Time ::=
 // CHOICE { utcTime UTCTime, generalTime GeneralizedTime } written by Steve
 // Henson.
 
+BSSL_NAMESPACE_BEGIN
+
 IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME)
 
+BSSL_NAMESPACE_END
+
 IMPLEMENT_ASN1_FUNCTIONS_const(ASN1_TIME)
 
 ASN1_TIME *ASN1_TIME_set_posix(ASN1_TIME *s, int64_t posix_time) {
@@ -223,14 +230,15 @@
   return OPENSSL_tm_to_posix(&tm, out_time);
 }
 
-int asn1_parse_time(CBS *cbs, ASN1_TIME *out, int allow_utc_timezone_offset) {
+int bssl::asn1_parse_time(CBS *cbs, ASN1_TIME *out,
+                          int allow_utc_timezone_offset) {
   if (CBS_peek_asn1_tag(cbs, CBS_ASN1_UTCTIME)) {
     return asn1_parse_utc_time(cbs, out, /*tag=*/0, allow_utc_timezone_offset);
   }
   return asn1_parse_generalized_time(cbs, out, /*tag=*/0);
 }
 
-int asn1_marshal_time(CBB *cbb, const ASN1_TIME *in) {
+int bssl::asn1_marshal_time(CBB *cbb, const ASN1_TIME *in) {
   if (in->type != V_ASN1_UTCTIME && in->type != V_ASN1_GENERALIZEDTIME) {
     OPENSSL_PUT_ERROR(ASN1, ASN1_R_WRONG_TYPE);
     return 0;
diff --git a/crypto/asn1/a_type.cc b/crypto/asn1/a_type.cc
index c6f066f..5ceff3c 100644
--- a/crypto/asn1/a_type.cc
+++ b/crypto/asn1/a_type.cc
@@ -24,6 +24,8 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 int ASN1_TYPE_get(const ASN1_TYPE *a) {
   switch (a->type) {
     case V_ASN1_NULL:
@@ -36,7 +38,7 @@
   }
 }
 
-const void *asn1_type_value_as_pointer(const ASN1_TYPE *a) {
+const void *bssl::asn1_type_value_as_pointer(const ASN1_TYPE *a) {
   switch (a->type) {
     case V_ASN1_NULL:
       return nullptr;
@@ -49,7 +51,7 @@
   }
 }
 
-void asn1_type_set0_string(ASN1_TYPE *a, ASN1_STRING *str) {
+void bssl::asn1_type_set0_string(ASN1_TYPE *a, ASN1_STRING *str) {
   // |ASN1_STRING| types are almost the same as |ASN1_TYPE| types, except that
   // the negative flag is not reflected into |ASN1_TYPE|.
   int type = str->type;
@@ -66,7 +68,7 @@
   ASN1_TYPE_set(a, type, str);
 }
 
-void asn1_type_cleanup(ASN1_TYPE *a) {
+void bssl::asn1_type_cleanup(ASN1_TYPE *a) {
   switch (a->type) {
     case V_ASN1_NULL:
       a->value.ptr = nullptr;
@@ -172,7 +174,7 @@
   return result;
 }
 
-int asn1_parse_any(CBS *cbs, ASN1_TYPE *out) {
+int bssl::asn1_parse_any(CBS *cbs, ASN1_TYPE *out) {
   CBS_ASN1_TAG tag;
   CBS elem;
   size_t header_len;
@@ -183,7 +185,7 @@
 
   // Handle the non-string types.
   if (tag == CBS_ASN1_OBJECT) {
-    bssl::UniquePtr<ASN1_OBJECT> obj(asn1_parse_object(&elem, /*tag=*/0));
+    UniquePtr<ASN1_OBJECT> obj(asn1_parse_object(&elem, /*tag=*/0));
     if (obj == nullptr) {
       return 0;
     }
@@ -211,7 +213,7 @@
   }
 
   // All other cases are handled identically to the string-based ANY parser.
-  bssl::UniquePtr<ASN1_STRING> str(ASN1_STRING_new());
+  UniquePtr<ASN1_STRING> str(ASN1_STRING_new());
   if (str == nullptr || !asn1_parse_any_as_string(&elem, str.get())) {
     return 0;
   }
@@ -219,7 +221,7 @@
   return 1;
 }
 
-int asn1_parse_any_as_string(CBS *cbs, ASN1_STRING *out) {
+int bssl::asn1_parse_any_as_string(CBS *cbs, ASN1_STRING *out) {
   CBS_ASN1_TAG tag;
   CBS elem;
   size_t header_len;
@@ -349,7 +351,7 @@
 static int asn1_marshal_string_with_type(CBB *out, const ASN1_STRING *in,
                                          int type);
 
-int asn1_marshal_any(CBB *out, const ASN1_TYPE *in) {
+int bssl::asn1_marshal_any(CBB *out, const ASN1_TYPE *in) {
   switch (in->type) {
     case V_ASN1_OBJECT:
       return asn1_marshal_object(out, in->value.object, /*tag=*/0);
@@ -428,6 +430,6 @@
   }
 }
 
-int asn1_marshal_any_string(CBB *out, const ASN1_STRING *in) {
+int bssl::asn1_marshal_any_string(CBB *out, const ASN1_STRING *in) {
   return asn1_marshal_string_with_type(out, in, in->type);
 }
diff --git a/crypto/asn1/a_utctm.cc b/crypto/asn1/a_utctm.cc
index c45220c..16a1406 100644
--- a/crypto/asn1/a_utctm.cc
+++ b/crypto/asn1/a_utctm.cc
@@ -24,8 +24,11 @@
 
 #include "internal.h"
 
-int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d,
-                       int allow_timezone_offset) {
+
+using namespace bssl;
+
+int bssl::asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d,
+                             int allow_timezone_offset) {
   if (d->type != V_ASN1_UTCTIME) {
     return 0;
   }
@@ -37,8 +40,8 @@
   return 1;
 }
 
-int asn1_parse_utc_time(CBS *cbs, ASN1_UTCTIME *out, CBS_ASN1_TAG tag,
-                        int allow_timezone_offset) {
+int bssl::asn1_parse_utc_time(CBS *cbs, ASN1_UTCTIME *out, CBS_ASN1_TAG tag,
+                              int allow_timezone_offset) {
   tag = tag == 0 ? CBS_ASN1_UTCTIME : tag;
   CBS child;
   if (!CBS_get_asn1(cbs, &child, tag) ||
diff --git a/crypto/asn1/asn1_lib.cc b/crypto/asn1/asn1_lib.cc
index cf5c3f6..225361d 100644
--- a/crypto/asn1/asn1_lib.cc
+++ b/crypto/asn1/asn1_lib.cc
@@ -25,6 +25,8 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 // Cross-module errors from crypto/x509/i2d_pr.c.
 OPENSSL_DECLARE_ERROR_REASON(ASN1, UNSUPPORTED_PUBLIC_KEY_TYPE)
 
@@ -298,12 +300,12 @@
   return ret;
 }
 
-void asn1_string_init(ASN1_STRING *str, int type) {
+void bssl::asn1_string_init(ASN1_STRING *str, int type) {
   OPENSSL_memset(str, 0, sizeof(ASN1_STRING));
   str->type = type;
 }
 
-void asn1_string_cleanup(ASN1_STRING *str) {
+void bssl::asn1_string_cleanup(ASN1_STRING *str) {
   OPENSSL_free(str->data);
   str->data = nullptr;
 }
@@ -367,7 +369,8 @@
   return str->data;
 }
 
-int asn1_parse_octet_string(CBS *cbs, ASN1_STRING *out, CBS_ASN1_TAG tag) {
+int bssl::asn1_parse_octet_string(CBS *cbs, ASN1_STRING *out,
+                                  CBS_ASN1_TAG tag) {
   tag = tag == 0 ? CBS_ASN1_OCTETSTRING : tag;
   CBS child;
   if (!CBS_get_asn1(cbs, &child, tag)) {
@@ -381,8 +384,8 @@
   return 1;
 }
 
-int asn1_marshal_octet_string(CBB *out, const ASN1_STRING *in,
-                              CBS_ASN1_TAG tag) {
+int bssl::asn1_marshal_octet_string(CBB *out, const ASN1_STRING *in,
+                                    CBS_ASN1_TAG tag) {
   tag = tag == 0 ? CBS_ASN1_OCTETSTRING : tag;
   return CBB_add_asn1_element(out, tag, ASN1_STRING_get0_data(in),
                               ASN1_STRING_length(in));
@@ -412,23 +415,24 @@
   return 1;
 }
 
-int asn1_parse_bmp_string(CBS *cbs, ASN1_BMPSTRING *out, CBS_ASN1_TAG tag) {
+int bssl::asn1_parse_bmp_string(CBS *cbs, ASN1_BMPSTRING *out,
+                                CBS_ASN1_TAG tag) {
   tag = tag == 0 ? CBS_ASN1_BMPSTRING : tag;
   return asn1_parse_character_string(cbs, out, tag, V_ASN1_BMPSTRING,
                                      &CBS_get_ucs2_be,
                                      ASN1_R_INVALID_BMPSTRING);
 }
 
-int asn1_parse_universal_string(CBS *cbs, ASN1_UNIVERSALSTRING *out,
-                                CBS_ASN1_TAG tag) {
+int bssl::asn1_parse_universal_string(CBS *cbs, ASN1_UNIVERSALSTRING *out,
+                                      CBS_ASN1_TAG tag) {
   tag = tag == 0 ? CBS_ASN1_UNIVERSALSTRING : tag;
   return asn1_parse_character_string(cbs, out, tag, V_ASN1_UNIVERSALSTRING,
                                      &CBS_get_utf32_be,
                                      ASN1_R_INVALID_UNIVERSALSTRING);
 }
 
-int asn1_parse_utf8_string(CBS *cbs, ASN1_UNIVERSALSTRING *out,
-                           CBS_ASN1_TAG tag) {
+int bssl::asn1_parse_utf8_string(CBS *cbs, ASN1_UNIVERSALSTRING *out,
+                                 CBS_ASN1_TAG tag) {
   tag = tag == 0 ? CBS_ASN1_UTF8STRING : tag;
   return asn1_parse_character_string(cbs, out, tag, V_ASN1_UTF8STRING,
                                      &CBS_get_utf8, ASN1_R_INVALID_UTF8STRING);
diff --git a/crypto/asn1/asn1_test.cc b/crypto/asn1/asn1_test.cc
index e93e356..c3fe52d 100644
--- a/crypto/asn1/asn1_test.cc
+++ b/crypto/asn1/asn1_test.cc
@@ -43,13 +43,15 @@
 #endif
 
 
+BSSL_NAMESPACE_BEGIN
+
 // |obj| and |i2d_func| require different template parameters because C++ may
 // deduce, say, |ASN1_STRING*| via |obj| and |const ASN1_STRING*| via
 // |i2d_func|. Template argument deduction then fails. The language is not able
 // to resolve this by observing that |const ASN1_STRING*| works for both.
 template <typename T, typename U>
 void TestSerialize(T obj, int (*i2d_func)(U a, uint8_t **pp),
-                   bssl::Span<const uint8_t> expected) {
+                   Span<const uint8_t> expected) {
   static_assert(std::is_convertible_v<T, U>,
                 "incompatible parameter to i2d_func");
   // Test the allocating version first. It is easiest to debug.
@@ -72,7 +74,7 @@
 }
 
 static bssl::UniquePtr<BIGNUM> BIGNUMPow2(unsigned bit) {
-  bssl::UniquePtr<BIGNUM> bn(BN_new());
+  UniquePtr<BIGNUM> bn(BN_new());
   if (!bn ||  //
       !BN_set_bit(bn.get(), bit)) {
     return nullptr;
@@ -81,19 +83,19 @@
 }
 
 TEST(ASN1Test, Integer) {
-  bssl::UniquePtr<BIGNUM> int64_min = BIGNUMPow2(63);
+  UniquePtr<BIGNUM> int64_min = BIGNUMPow2(63);
   ASSERT_TRUE(int64_min);
   BN_set_negative(int64_min.get(), 1);
 
-  bssl::UniquePtr<BIGNUM> int64_max = BIGNUMPow2(63);
+  UniquePtr<BIGNUM> int64_max = BIGNUMPow2(63);
   ASSERT_TRUE(int64_max);
   ASSERT_TRUE(BN_sub_word(int64_max.get(), 1));
 
-  bssl::UniquePtr<BIGNUM> int32_min = BIGNUMPow2(31);
+  UniquePtr<BIGNUM> int32_min = BIGNUMPow2(31);
   ASSERT_TRUE(int32_min);
   BN_set_negative(int32_min.get(), 1);
 
-  bssl::UniquePtr<BIGNUM> int32_max = BIGNUMPow2(31);
+  UniquePtr<BIGNUM> int32_max = BIGNUMPow2(31);
   ASSERT_TRUE(int32_max);
   ASSERT_TRUE(BN_sub_word(int32_max.get(), 1));
 
@@ -269,10 +271,10 @@
     SCOPED_TRACE(t.bn_asc);
     // Collect a map of different ways to construct the integer. The key is the
     // method used and is only retained to aid debugging.
-    std::map<std::string, bssl::UniquePtr<ASN1_INTEGER>> objs;
+    std::map<std::string, UniquePtr<ASN1_INTEGER>> objs;
 
     // Construct |ASN1_INTEGER| by setting the type and data manually.
-    bssl::UniquePtr<ASN1_INTEGER> by_data(ASN1_STRING_type_new(t.type));
+    UniquePtr<ASN1_INTEGER> by_data(ASN1_STRING_type_new(t.type));
     ASSERT_TRUE(by_data);
     ASSERT_TRUE(ASN1_STRING_set(by_data.get(), t.data.data(), t.data.size()));
     objs["data"] = std::move(by_data);
@@ -280,14 +282,14 @@
     // Construct |ASN1_INTEGER| from a |BIGNUM|.
     BIGNUM *bn_raw = nullptr;
     ASSERT_TRUE(BN_asc2bn(&bn_raw, t.bn_asc));
-    bssl::UniquePtr<BIGNUM> bn(bn_raw);
-    bssl::UniquePtr<ASN1_INTEGER> by_bn(BN_to_ASN1_INTEGER(bn.get(), nullptr));
+    UniquePtr<BIGNUM> bn(bn_raw);
+    UniquePtr<ASN1_INTEGER> by_bn(BN_to_ASN1_INTEGER(bn.get(), nullptr));
     ASSERT_TRUE(by_bn);
     objs["bn"] = std::move(by_bn);
 
     // Construct |ASN1_INTEGER| from decoding.
     const uint8_t *ptr = t.der.data();
-    bssl::UniquePtr<ASN1_INTEGER> by_der(
+    UniquePtr<ASN1_INTEGER> by_der(
         d2i_ASN1_INTEGER(nullptr, &ptr, t.der.size()));
     ASSERT_TRUE(by_der);
     EXPECT_EQ(ptr, t.der.data() + t.der.size());
@@ -303,7 +305,7 @@
       fits_in_u64 = !BN_is_negative(bn.get());
       if (fits_in_u64) {
         u64 = abs_u64;
-        bssl::UniquePtr<ASN1_INTEGER> by_u64(ASN1_INTEGER_new());
+        UniquePtr<ASN1_INTEGER> by_u64(ASN1_INTEGER_new());
         ASSERT_TRUE(by_u64);
         ASSERT_TRUE(ASN1_INTEGER_set_uint64(by_u64.get(), u64));
         objs["u64"] = std::move(by_u64);
@@ -317,7 +319,7 @@
         } else {
           i64 = static_cast<int64_t>(abs_u64);
         }
-        bssl::UniquePtr<ASN1_INTEGER> by_i64(ASN1_INTEGER_new());
+        UniquePtr<ASN1_INTEGER> by_i64(ASN1_INTEGER_new());
         ASSERT_TRUE(by_i64);
         ASSERT_TRUE(ASN1_INTEGER_set_int64(by_i64.get(), i64));
         objs["i64"] = std::move(by_i64);
@@ -332,7 +334,7 @@
       }
       if (fits_in_long) {
         l = static_cast<long>(i64);
-        bssl::UniquePtr<ASN1_INTEGER> by_long(ASN1_INTEGER_new());
+        UniquePtr<ASN1_INTEGER> by_long(ASN1_INTEGER_new());
         ASSERT_TRUE(by_long);
         ASSERT_TRUE(ASN1_INTEGER_set(by_long.get(), l));
         objs["long"] = std::move(by_long);
@@ -341,7 +343,7 @@
 
     // Default construction should return the zero |ASN1_INTEGER|.
     if (BN_is_zero(bn.get())) {
-      bssl::UniquePtr<ASN1_INTEGER> by_default(ASN1_INTEGER_new());
+      UniquePtr<ASN1_INTEGER> by_default(ASN1_INTEGER_new());
       ASSERT_TRUE(by_default);
       objs["default"] = std::move(by_default);
     }
@@ -358,7 +360,7 @@
       // The object should encode correctly.
       TestSerialize(obj, i2d_ASN1_INTEGER, t.der);
 
-      bssl::UniquePtr<BIGNUM> bn2(ASN1_INTEGER_to_BN(obj, nullptr));
+      UniquePtr<BIGNUM> bn2(ASN1_INTEGER_to_BN(obj, nullptr));
       ASSERT_TRUE(bn2);
       EXPECT_EQ(0, BN_cmp(bn.get(), bn2.get()));
 
@@ -404,7 +406,7 @@
       data.insert(data.begin(), 0x00);
       SCOPED_TRACE(Bytes(data));
 
-      bssl::UniquePtr<ASN1_INTEGER> non_minimal(ASN1_STRING_type_new(t.type));
+      UniquePtr<ASN1_INTEGER> non_minimal(ASN1_STRING_type_new(t.type));
       ASSERT_TRUE(non_minimal);
       ASSERT_TRUE(ASN1_STRING_set(non_minimal.get(), data.data(), data.size()));
 
@@ -415,13 +417,13 @@
   for (size_t i = 0; i < std::size(kTests); i++) {
     SCOPED_TRACE(Bytes(kTests[i].der));
     const uint8_t *ptr = kTests[i].der.data();
-    bssl::UniquePtr<ASN1_INTEGER> a(
+    UniquePtr<ASN1_INTEGER> a(
         d2i_ASN1_INTEGER(nullptr, &ptr, kTests[i].der.size()));
     ASSERT_TRUE(a);
     for (size_t j = 0; j < std::size(kTests); j++) {
       SCOPED_TRACE(Bytes(kTests[j].der));
       ptr = kTests[j].der.data();
-      bssl::UniquePtr<ASN1_INTEGER> b(
+      UniquePtr<ASN1_INTEGER> b(
           d2i_ASN1_INTEGER(nullptr, &ptr, kTests[j].der.size()));
       ASSERT_TRUE(b);
 
@@ -453,7 +455,7 @@
     SCOPED_TRACE(Bytes(invalid));
 
     const uint8_t *ptr = invalid.data();
-    bssl::UniquePtr<ASN1_INTEGER> integer(
+    UniquePtr<ASN1_INTEGER> integer(
         d2i_ASN1_INTEGER(nullptr, &ptr, invalid.size()));
     EXPECT_FALSE(integer);
   }
@@ -466,8 +468,7 @@
 
 // Although invalid, a negative zero should encode correctly.
 TEST(ASN1Test, NegativeZero) {
-  bssl::UniquePtr<ASN1_INTEGER> neg_zero(
-      ASN1_STRING_type_new(V_ASN1_NEG_INTEGER));
+  UniquePtr<ASN1_INTEGER> neg_zero(ASN1_STRING_type_new(V_ASN1_NEG_INTEGER));
   ASSERT_TRUE(neg_zero);
   EXPECT_EQ(0, ASN1_INTEGER_get(neg_zero.get()));
 
@@ -531,7 +532,7 @@
 
 // The templates go through a different codepath, so test them separately.
 TEST(ASN1Test, SerializeEmbeddedBoolean) {
-  bssl::UniquePtr<BASIC_CONSTRAINTS> val(BASIC_CONSTRAINTS_new());
+  UniquePtr<BASIC_CONSTRAINTS> val(BASIC_CONSTRAINTS_new());
   ASSERT_TRUE(val);
 
   // BasicConstraints defaults to FALSE, so the encoding should be empty.
@@ -551,8 +552,8 @@
 }
 
 static std::vector<uint8_t> EmbedParamInAlgorithmIdentifier(
-    bssl::Span<const uint8_t> param) {
-  bssl::ScopedCBB cbb;
+    Span<const uint8_t> param) {
+  ScopedCBB cbb;
   CBB seq;
   BSSL_CHECK(CBB_init(cbb.get(), 64));
   BSSL_CHECK(CBB_add_asn1(cbb.get(), &seq, CBS_ASN1_SEQUENCE));
@@ -633,7 +634,7 @@
 
     // The input should successfully parse.
     const uint8_t *ptr = t.der.data();
-    bssl::UniquePtr<ASN1_TYPE> val(d2i_ASN1_TYPE(nullptr, &ptr, t.der.size()));
+    UniquePtr<ASN1_TYPE> val(d2i_ASN1_TYPE(nullptr, &ptr, t.der.size()));
     ASSERT_TRUE(val);
 
     check_asn1_type(val.get());
@@ -642,8 +643,7 @@
     // Test the same thing wrapped in an AlgorithmIdentifier.
     std::vector<uint8_t> alg_der = EmbedParamInAlgorithmIdentifier(t.der);
     ptr = alg_der.data();
-    bssl::UniquePtr<X509_ALGOR> alg(
-        d2i_X509_ALGOR(nullptr, &ptr, alg_der.size()));
+    UniquePtr<X509_ALGOR> alg(d2i_X509_ALGOR(nullptr, &ptr, alg_der.size()));
     ASSERT_TRUE(alg);
 
     check_asn1_type(alg->parameter);
@@ -698,14 +698,13 @@
   for (const auto &t : kInvalidTests) {
     SCOPED_TRACE(Bytes(t));
     const uint8_t *ptr = t.data();
-    bssl::UniquePtr<ASN1_TYPE> val(d2i_ASN1_TYPE(nullptr, &ptr, t.size()));
+    UniquePtr<ASN1_TYPE> val(d2i_ASN1_TYPE(nullptr, &ptr, t.size()));
     EXPECT_FALSE(val);
     ERR_clear_error();
 
     std::vector<uint8_t> alg_der = EmbedParamInAlgorithmIdentifier(t);
     ptr = alg_der.data();
-    bssl::UniquePtr<X509_ALGOR> alg(
-        d2i_X509_ALGOR(nullptr, &ptr, alg_der.size()));
+    UniquePtr<X509_ALGOR> alg(d2i_X509_ALGOR(nullptr, &ptr, alg_der.size()));
     EXPECT_FALSE(alg);
     ERR_clear_error();
   }
@@ -718,7 +717,7 @@
   // OCTET_STRING { "a" }
   static const uint8_t kDER[] = {0x04, 0x01, 0x61};
   const uint8_t *ptr = kDER;
-  bssl::UniquePtr<ASN1_TYPE> val(d2i_ASN1_TYPE(nullptr, &ptr, sizeof(kDER)));
+  UniquePtr<ASN1_TYPE> val(d2i_ASN1_TYPE(nullptr, &ptr, sizeof(kDER)));
   ASSERT_TRUE(val);
   EXPECT_EQ(V_ASN1_OCTET_STRING, val->type);
   EXPECT_TRUE(val->value.ptr);
@@ -811,7 +810,7 @@
     SCOPED_TRACE(Bytes(test.in));
     // The input should parse and round-trip correctly.
     const uint8_t *ptr = test.in.data();
-    bssl::UniquePtr<ASN1_BIT_STRING> val(
+    UniquePtr<ASN1_BIT_STRING> val(
         d2i_ASN1_BIT_STRING(nullptr, &ptr, test.in.size()));
     ASSERT_TRUE(val);
     TestSerialize(val.get(), i2d_ASN1_BIT_STRING, test.in);
@@ -842,14 +841,14 @@
   for (const auto &test : kInvalidInputs) {
     SCOPED_TRACE(Bytes(test));
     const uint8_t *ptr = test.data();
-    bssl::UniquePtr<ASN1_BIT_STRING> val(
+    UniquePtr<ASN1_BIT_STRING> val(
         d2i_ASN1_BIT_STRING(nullptr, &ptr, test.size()));
     EXPECT_FALSE(val);
   }
 }
 
 TEST(ASN1Test, SetBit) {
-  bssl::UniquePtr<ASN1_BIT_STRING> val(ASN1_BIT_STRING_new());
+  UniquePtr<ASN1_BIT_STRING> val(ASN1_BIT_STRING_new());
   ASSERT_TRUE(val);
   static const uint8_t kBitStringEmpty[] = {0x03, 0x01, 0x00};
   TestSerialize(val.get(), i2d_ASN1_BIT_STRING, kBitStringEmpty);
@@ -990,7 +989,7 @@
   for (const auto &test : kTests) {
     SCOPED_TRACE(Bytes(test.in));
     SCOPED_TRACE(test.type);
-    bssl::UniquePtr<ASN1_STRING> s(ASN1_STRING_type_new(test.type));
+    UniquePtr<ASN1_STRING> s(ASN1_STRING_type_new(test.type));
     ASSERT_TRUE(s);
     ASSERT_TRUE(ASN1_STRING_set(s.get(), test.in.data(), test.in.size()));
 
@@ -1044,7 +1043,7 @@
                                                       const ASN1_STRING *)) {
   const uint8_t *data;
   size_t len;
-  bssl::UniquePtr<BIO> bio(BIO_new(BIO_s_mem()));
+  UniquePtr<BIO> bio(BIO_new(BIO_s_mem()));
   if (!bio ||  //
       !print_func(bio.get(), str) ||
       !BIO_mem_contents(bio.get(), &data, &len)) {
@@ -1087,7 +1086,7 @@
     int64_t tt;
     SCOPED_TRACE(t.time);
 
-    bssl::UniquePtr<ASN1_UTCTIME> utc(ASN1_UTCTIME_set(nullptr, t.time));
+    UniquePtr<ASN1_UTCTIME> utc(ASN1_UTCTIME_set(nullptr, t.time));
     if (t.utc) {
       ASSERT_TRUE(utc);
       EXPECT_EQ(V_ASN1_UTCTIME, ASN1_STRING_type(utc.get()));
@@ -1101,7 +1100,7 @@
       EXPECT_FALSE(utc);
     }
 
-    bssl::UniquePtr<ASN1_GENERALIZEDTIME> generalized(
+    UniquePtr<ASN1_GENERALIZEDTIME> generalized(
         ASN1_GENERALIZEDTIME_set(nullptr, t.time));
     if (t.generalized) {
       ASSERT_TRUE(generalized);
@@ -1119,7 +1118,7 @@
       EXPECT_FALSE(generalized);
     }
 
-    bssl::UniquePtr<ASN1_TIME> choice(ASN1_TIME_set_posix(nullptr, t.time));
+    UniquePtr<ASN1_TIME> choice(ASN1_TIME_set_posix(nullptr, t.time));
     if (t.generalized) {
       ASSERT_TRUE(choice);
       if (t.utc) {
@@ -1139,7 +1138,7 @@
 }
 
 TEST(ASN1Test, TimeSetString) {
-  bssl::UniquePtr<ASN1_STRING> s(ASN1_STRING_new());
+  UniquePtr<ASN1_STRING> s(ASN1_STRING_new());
   ASSERT_TRUE(s);
 
   ASSERT_TRUE(ASN1_UTCTIME_set_string(s.get(), "700101000000Z"));
@@ -1220,7 +1219,7 @@
 }
 
 TEST(ASN1Test, UTCTimeZoneOffsets) {
-  bssl::UniquePtr<ASN1_STRING> s(ASN1_STRING_new());
+  UniquePtr<ASN1_STRING> s(ASN1_STRING_new());
   ASSERT_TRUE(s);
 
   ASSERT_TRUE(ASN1_UTCTIME_set_string(s.get(), "700101000000Z"));
@@ -1246,8 +1245,7 @@
 
   // Conscrypt expects a utc time with an arbitrary offset to be
   // accepted by ASN1_TIME_to_generalizedtime.
-  bssl::UniquePtr<ASN1_STRING> g(
-      ASN1_TIME_to_generalizedtime(s.get(), nullptr));
+  UniquePtr<ASN1_STRING> g(ASN1_TIME_to_generalizedtime(s.get(), nullptr));
   ASSERT_TRUE(g);
   EXPECT_EQ(V_ASN1_GENERALIZEDTIME, ASN1_STRING_type(g.get()));
   // crbug.com/389147378
@@ -1515,7 +1513,7 @@
     SCOPED_TRACE(t.str_flags);
     SCOPED_TRACE(t.flags);
 
-    bssl::UniquePtr<ASN1_STRING> str(ASN1_STRING_type_new(t.type));
+    UniquePtr<ASN1_STRING> str(ASN1_STRING_type_new(t.type));
     ASSERT_TRUE(str);
     ASSERT_TRUE(ASN1_STRING_set(str.get(), t.data.data(), t.data.size()));
     str->flags = t.str_flags;
@@ -1529,7 +1527,7 @@
     EXPECT_EQ(len, static_cast<int>(t.expected.size()));
 
     // Actually print the string.
-    bssl::UniquePtr<BIO> bio(BIO_new(BIO_s_mem()));
+    UniquePtr<BIO> bio(BIO_new(BIO_s_mem()));
     ASSERT_TRUE(bio);
     len = ASN1_STRING_print_ex(bio.get(), str.get(), t.flags);
     EXPECT_EQ(len, static_cast<int>(t.expected.size()));
@@ -1570,7 +1568,7 @@
     SCOPED_TRACE(t.str_flags);
     SCOPED_TRACE(t.flags);
 
-    bssl::UniquePtr<ASN1_STRING> str(ASN1_STRING_type_new(t.type));
+    UniquePtr<ASN1_STRING> str(ASN1_STRING_type_new(t.type));
     ASSERT_TRUE(str);
     ASSERT_TRUE(ASN1_STRING_set(str.get(), t.data.data(), t.data.size()));
     str->flags = t.str_flags;
@@ -1586,7 +1584,7 @@
     ERR_clear_error();
 
     // Actually print the string.
-    bssl::UniquePtr<BIO> bio(BIO_new(BIO_s_mem()));
+    UniquePtr<BIO> bio(BIO_new(BIO_s_mem()));
     ASSERT_TRUE(bio);
     len = ASN1_STRING_print_ex(bio.get(), str.get(), t.flags);
     EXPECT_EQ(len, -1);
@@ -1858,7 +1856,7 @@
     SCOPED_TRACE(t.in);
 
     // Test allocating a new object.
-    bssl::UniquePtr<ASN1_STRING> str(ASN1_STRING_set_by_NID(
+    UniquePtr<ASN1_STRING> str(ASN1_STRING_set_by_NID(
         nullptr, reinterpret_cast<const uint8_t *>(t.in.data()), t.in.size(),
         MBSTRING_UTF8, t.nid));
     ASSERT_TRUE(str);
@@ -1923,7 +1921,7 @@
   for (const auto &t : kInvalidTests) {
     SCOPED_TRACE(t.nid);
     SCOPED_TRACE(t.in);
-    bssl::UniquePtr<ASN1_STRING> str(ASN1_STRING_set_by_NID(
+    UniquePtr<ASN1_STRING> str(ASN1_STRING_set_by_NID(
         nullptr, reinterpret_cast<const uint8_t *>(t.in.data()), t.in.size(),
         MBSTRING_UTF8, t.nid));
     EXPECT_FALSE(str);
@@ -1944,7 +1942,7 @@
   // Values registered in the string table should be picked up.
   ASSERT_TRUE(ASN1_STRING_TABLE_add(nid1, 5, 10, V_ASN1_PRINTABLESTRING,
                                     STABLE_NO_MASK));
-  bssl::UniquePtr<ASN1_STRING> str(ASN1_STRING_set_by_NID(
+  UniquePtr<ASN1_STRING> str(ASN1_STRING_set_by_NID(
       nullptr, reinterpret_cast<const uint8_t *>("12345"), 5, MBSTRING_UTF8,
       nid1));
   ASSERT_TRUE(str);
@@ -1996,7 +1994,7 @@
   threads.emplace_back([&] {
     ASSERT_TRUE(ASN1_STRING_TABLE_add(nid1, 5, 10, V_ASN1_PRINTABLESTRING,
                                       STABLE_NO_MASK));
-    bssl::UniquePtr<ASN1_STRING> str(ASN1_STRING_set_by_NID(
+    UniquePtr<ASN1_STRING> str(ASN1_STRING_set_by_NID(
         nullptr, reinterpret_cast<const uint8_t *>("12345"), 5, MBSTRING_UTF8,
         nid1));
     ASSERT_TRUE(str);
@@ -2007,7 +2005,7 @@
   threads.emplace_back([&] {
     ASSERT_TRUE(ASN1_STRING_TABLE_add(nid2, 5, 10, V_ASN1_PRINTABLESTRING,
                                       STABLE_NO_MASK));
-    bssl::UniquePtr<ASN1_STRING> str(ASN1_STRING_set_by_NID(
+    UniquePtr<ASN1_STRING> str(ASN1_STRING_set_by_NID(
         nullptr, reinterpret_cast<const uint8_t *>("12345"), 5, MBSTRING_UTF8,
         nid2));
     ASSERT_TRUE(str);
@@ -2023,7 +2021,7 @@
 
 // Encoding a CHOICE type with an invalid selector should fail.
 TEST(ASN1Test, InvalidChoice) {
-  bssl::UniquePtr<GENERAL_NAME> name(GENERAL_NAME_new());
+  UniquePtr<GENERAL_NAME> name(GENERAL_NAME_new());
   ASSERT_TRUE(name);
   // CHOICE types are initialized with an invalid selector.
   EXPECT_EQ(-1, name->type);
@@ -2031,9 +2029,9 @@
   EXPECT_EQ(-1, i2d_GENERAL_NAME(name.get(), nullptr));
 
   // The error should be propagated through types containing |name|.
-  bssl::UniquePtr<GENERAL_NAMES> names(GENERAL_NAMES_new());
+  UniquePtr<GENERAL_NAMES> names(GENERAL_NAMES_new());
   ASSERT_TRUE(names);
-  EXPECT_TRUE(bssl::PushToStack(names.get(), std::move(name)));
+  EXPECT_TRUE(PushToStack(names.get(), std::move(name)));
   EXPECT_EQ(-1, i2d_GENERAL_NAMES(names.get(), nullptr));
 }
 
@@ -2041,7 +2039,7 @@
 TEST(ASN1Test, InvalidObject) {
   EXPECT_EQ(-1, i2d_ASN1_OBJECT(OBJ_nid2obj(NID_kx_ecdhe), nullptr));
 
-  bssl::UniquePtr<X509_ALGOR> alg(X509_ALGOR_new());
+  UniquePtr<X509_ALGOR> alg(X509_ALGOR_new());
   ASSERT_TRUE(alg);
   ASSERT_TRUE(X509_ALGOR_set0(alg.get(), OBJ_nid2obj(NID_kx_ecdhe),
                               V_ASN1_UNDEF, nullptr));
@@ -2051,7 +2049,7 @@
 // Encoding invalid |ASN1_TYPE|s should fail. |ASN1_TYPE|s are
 // default-initialized to an invalid type.
 TEST(ASN1Test, EncodeInvalidASN1Type) {
-  bssl::UniquePtr<ASN1_TYPE> obj(ASN1_TYPE_new());
+  UniquePtr<ASN1_TYPE> obj(ASN1_TYPE_new());
   ASSERT_TRUE(obj);
   EXPECT_EQ(-1, obj->type);
   EXPECT_EQ(-1, i2d_ASN1_TYPE(obj.get(), nullptr));
@@ -2070,7 +2068,7 @@
 // Encoding invalid MSTRING types should fail. An MSTRING is a CHOICE of
 // string-like types. They are initialized to an invalid type.
 TEST(ASN1Test, InvalidMSTRING) {
-  bssl::UniquePtr<ASN1_STRING> obj(ASN1_TIME_new());
+  UniquePtr<ASN1_STRING> obj(ASN1_TIME_new());
   ASSERT_TRUE(obj);
   EXPECT_EQ(-1, obj->type);
   EXPECT_EQ(-1, i2d_ASN1_TIME(obj.get(), nullptr));
@@ -2083,9 +2081,9 @@
 
 TEST(ASN1Test, TypeMismatch) {
   // Pack PSS parameters into an |ASN1_STRING|. This makes an OCTET STRING.
-  bssl::UniquePtr<RSA_PSS_PARAMS> pss(RSA_PSS_PARAMS_new());
+  UniquePtr<RSA_PSS_PARAMS> pss(RSA_PSS_PARAMS_new());
   ASSERT_TRUE(pss);
-  bssl::UniquePtr<ASN1_STRING> str(
+  UniquePtr<ASN1_STRING> str(
       ASN1_item_pack(pss.get(), ASN1_ITEM_rptr(RSA_PSS_PARAMS), nullptr));
   ASSERT_TRUE(str);
   EXPECT_EQ(ASN1_STRING_type(str.get()), V_ASN1_OCTET_STRING);
@@ -2093,7 +2091,7 @@
   // Pass this to |X509_ALGOR_set0| as a |V_ASN1_SEQUENCE|, which uses the
   // |ASN1_TYPE_set0| calling convention. This leads to an ambiguous state:
   // whether this should be a SEQUENCE or OCTET STRING value.
-  bssl::UniquePtr<X509_ALGOR> alg(X509_ALGOR_new());
+  UniquePtr<X509_ALGOR> alg(X509_ALGOR_new());
   ASSERT_TRUE(alg);
   ASSERT_TRUE(X509_ALGOR_set0(alg.get(), OBJ_nid2obj(NID_rsassaPss),
                               V_ASN1_SEQUENCE, str.release()));
@@ -2158,8 +2156,7 @@
   // Although the standalone representation of NULL is a non-null pointer, the
   // |ASN1_TYPE| representation is a null pointer.
   ptr = kNull;
-  bssl::UniquePtr<ASN1_TYPE> null_type(
-      d2i_ASN1_TYPE(nullptr, &ptr, sizeof(kNull)));
+  UniquePtr<ASN1_TYPE> null_type(d2i_ASN1_TYPE(nullptr, &ptr, sizeof(kNull)));
   ASSERT_TRUE(null_type);
   EXPECT_EQ(ptr, kNull + sizeof(kNull));
   EXPECT_EQ(V_ASN1_NULL, ASN1_TYPE_get(null_type.get()));
@@ -2167,13 +2164,13 @@
 }
 
 TEST(ASN1Test, Pack) {
-  bssl::UniquePtr<BASIC_CONSTRAINTS> val(BASIC_CONSTRAINTS_new());
+  UniquePtr<BASIC_CONSTRAINTS> val(BASIC_CONSTRAINTS_new());
   ASSERT_TRUE(val);
   val->ca = 0;
 
   // Test all three calling conventions.
   static const uint8_t kExpected[] = {0x30, 0x00};
-  bssl::UniquePtr<ASN1_STRING> str(
+  UniquePtr<ASN1_STRING> str(
       ASN1_item_pack(val.get(), ASN1_ITEM_rptr(BASIC_CONSTRAINTS), nullptr));
   ASSERT_TRUE(str);
   EXPECT_EQ(ASN1_STRING_type(str.get()), V_ASN1_OCTET_STRING);
@@ -2203,12 +2200,12 @@
 }
 
 TEST(ASN1Test, Unpack) {
-  bssl::UniquePtr<ASN1_STRING> str(ASN1_STRING_new());
+  UniquePtr<ASN1_STRING> str(ASN1_STRING_new());
   ASSERT_TRUE(str);
 
   static const uint8_t kValid[] = {0x30, 0x00};
   ASSERT_TRUE(ASN1_STRING_set(str.get(), kValid, sizeof(kValid)));
-  bssl::UniquePtr<BASIC_CONSTRAINTS> val(static_cast<BASIC_CONSTRAINTS *>(
+  UniquePtr<BASIC_CONSTRAINTS> val(static_cast<BASIC_CONSTRAINTS *>(
       ASN1_item_unpack(str.get(), ASN1_ITEM_rptr(BASIC_CONSTRAINTS))));
   ASSERT_TRUE(val);
   EXPECT_EQ(val->ca, 0);
@@ -2302,7 +2299,7 @@
       {V_ASN1_OCTET_STRING, {0xff, 0x00}, 0, false},
       {V_ASN1_UTF8STRING, {0xff, 0x00}, 0, false},
   };
-  std::vector<bssl::UniquePtr<ASN1_STRING>> strs;
+  std::vector<UniquePtr<ASN1_STRING>> strs;
   strs.reserve(std::size(kInputs));
   for (const auto &input : kInputs) {
     strs.emplace_back(ASN1_STRING_type_new(input.type));
@@ -2391,10 +2388,10 @@
   };
   for (const auto &t : kDataTests) {
     SCOPED_TRACE(Bytes(t.in));
-    bssl::UniquePtr<ASN1_OBJECT> obj(ASN1_OBJECT_create(
+    UniquePtr<ASN1_OBJECT> obj(ASN1_OBJECT_create(
         NID_undef, t.in.data(), t.in.size(), /*sn=*/nullptr, /*ln=*/nullptr));
     ASSERT_TRUE(obj);
-    bssl::UniquePtr<BIO> bio(BIO_new(BIO_s_mem()));
+    UniquePtr<BIO> bio(BIO_new(BIO_s_mem()));
     ASSERT_TRUE(bio);
 
     int len = i2a_ASN1_OBJECT(bio.get(), obj.get());
@@ -2408,7 +2405,7 @@
   }
 
   // Test writing NULL.
-  bssl::UniquePtr<BIO> bio(BIO_new(BIO_s_mem()));
+  UniquePtr<BIO> bio(BIO_new(BIO_s_mem()));
   ASSERT_TRUE(bio);
   int len = i2a_ASN1_OBJECT(bio.get(), nullptr);
   EXPECT_EQ(len, 4);
@@ -2454,7 +2451,7 @@
                    const std::vector<uint8_t> &in) {
   SCOPED_TRACE(Bytes(in));
   const uint8_t *ptr = in.data();
-  bssl::UniquePtr<T> obj(d2i(nullptr, &ptr, in.size()));
+  UniquePtr<T> obj(d2i(nullptr, &ptr, in.size()));
   EXPECT_FALSE(obj);
 }
 
@@ -2548,13 +2545,13 @@
 
     if (t.d2i != nullptr) {
       inp = t.in.data();
-      bssl::UniquePtr<ASN1_STRING> str(t.d2i(nullptr, &inp, t.in.size()));
+      UniquePtr<ASN1_STRING> str(t.d2i(nullptr, &inp, t.in.size()));
       EXPECT_EQ(t.valid, str != nullptr);
     }
 
     // Also test with the ANY parser.
     inp = t.in.data();
-    bssl::UniquePtr<ASN1_TYPE> any(d2i_ASN1_TYPE(nullptr, &inp, t.in.size()));
+    UniquePtr<ASN1_TYPE> any(d2i_ASN1_TYPE(nullptr, &inp, t.in.size()));
     EXPECT_EQ(t.valid, any != nullptr);
   }
 }
@@ -2607,7 +2604,7 @@
 }
 
 TEST(ASN1Test, LargeString) {
-  bssl::UniquePtr<ASN1_STRING> str(ASN1_STRING_type_new(V_ASN1_OCTET_STRING));
+  UniquePtr<ASN1_STRING> str(ASN1_STRING_type_new(V_ASN1_OCTET_STRING));
   ASSERT_TRUE(str);
   // Very large strings should be rejected by |ASN1_STRING_set|. Strictly
   // speaking, this is an invalid call because the buffer does not have that
@@ -2721,9 +2718,9 @@
 
 IMPLEMENT_ASN1_FUNCTIONS(ASN1_LINKED_LIST)
 
-static bool MakeLinkedList(bssl::UniquePtr<uint8_t> *out, size_t *out_len,
+static bool MakeLinkedList(UniquePtr<uint8_t> *out, size_t *out_len,
                            size_t count) {
-  bssl::ScopedCBB cbb;
+  ScopedCBB cbb;
   std::vector<CBB> cbbs(count);
   if (!CBB_init(cbb.get(), 2 * count) ||
       !CBB_add_asn1(cbb.get(), &cbbs[0], CBS_ASN1_SEQUENCE)) {
@@ -2743,7 +2740,7 @@
 }
 
 TEST(ASN1Test, Recursive) {
-  bssl::UniquePtr<uint8_t> data;
+  UniquePtr<uint8_t> data;
   size_t len;
 
   // Sanity-check that MakeLinkedList can be parsed.
@@ -3108,7 +3105,7 @@
 IMPLEMENT_ASN1_FUNCTIONS(EMBED_X509)
 
 template <typename EmbedT, typename T, typename MaybeConstT, typename StackT>
-void TestEmbedType(bssl::Span<const uint8_t> inp,
+void TestEmbedType(Span<const uint8_t> inp,
                    int (*i2d)(MaybeConstT *, uint8_t **),
                    EmbedT *(*embed_new)(), void (*embed_free)(EmbedT *),
                    EmbedT *(*d2i_embed)(EmbedT **, const uint8_t **, long),
@@ -3118,7 +3115,7 @@
   std::unique_ptr<EmbedT, decltype(embed_free)> obj(nullptr, embed_free);
 
   // Test only the first field present.
-  bssl::ScopedCBB cbb;
+  ScopedCBB cbb;
   ASSERT_TRUE(CBB_init(cbb.get(), 64));
   ASSERT_TRUE(CBB_add_asn1_element(cbb.get(), CBS_ASN1_SEQUENCE, inp.data(),
                                    inp.size()));
@@ -3236,3 +3233,5 @@
 }
 
 #endif  // !WINDOWS || !SHARED_LIBRARY
+
+BSSL_NAMESPACE_END
diff --git a/crypto/asn1/internal.h b/crypto/asn1/internal.h
index 0988ca6..c4a4941 100644
--- a/crypto/asn1/internal.h
+++ b/crypto/asn1/internal.h
@@ -20,10 +20,8 @@
 #include <openssl/asn1.h>
 #include <openssl/asn1t.h>
 
-#if defined(__cplusplus)
-extern "C" {
-#endif
 
+BSSL_NAMESPACE_BEGIN
 
 // Wrapper functions for time functions.
 
@@ -57,6 +55,8 @@
 #define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04  // internal use
 #define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08     // internal use
 
+BSSL_NAMESPACE_END
+
 // An asn1_object_st (aka |ASN1_OBJECT|) represents an ASN.1 OBJECT IDENTIFIER.
 // Note: Mutating an |ASN1_OBJECT| is only permitted when initializing it. The
 // library maintains a table of static |ASN1_OBJECT|s, which may be referenced
@@ -71,6 +71,8 @@
   int flags;                  // Should we free this one
 };
 
+BSSL_NAMESPACE_BEGIN
+
 ASN1_OBJECT *ASN1_OBJECT_new();
 
 // asn1_parse_object parses a DER-encoded ASN.1 OBJECT IDENTIFIER from |cbs| and
@@ -365,9 +367,6 @@
 // 5280) and C type is |ASN1_STRING*|.
 DECLARE_ASN1_ITEM(DISPLAYTEXT)
 
-
-#if defined(__cplusplus)
-}  // extern C
-#endif
+BSSL_NAMESPACE_END
 
 #endif  // OPENSSL_HEADER_CRYPTO_ASN1_INTERNAL_H
diff --git a/crypto/asn1/posix_time.cc b/crypto/asn1/posix_time.cc
index 6361a0e..d6162a6 100644
--- a/crypto/asn1/posix_time.cc
+++ b/crypto/asn1/posix_time.cc
@@ -29,6 +29,8 @@
 #define SECS_PER_DAY (INT64_C(24) * SECS_PER_HOUR)
 
 
+using namespace bssl;
+
 // Is a year/month/day combination valid, in the range from year 0000
 // to 9999?
 static int is_valid_date(int64_t year, int64_t month, int64_t day) {
@@ -183,7 +185,7 @@
   return 1;
 }
 
-struct tm *OPENSSL_gmtime(const time_t *time, struct tm *out_tm) {
+struct tm *bssl::OPENSSL_gmtime(const time_t *time, struct tm *out_tm) {
   static_assert(
       sizeof(time_t) == sizeof(int32_t) || sizeof(time_t) == sizeof(int64_t),
       "time_t is broken");
@@ -194,7 +196,8 @@
   return out_tm;
 }
 
-int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, int64_t offset_sec) {
+int bssl::OPENSSL_gmtime_adj(struct tm *tm, int offset_day,
+                             int64_t offset_sec) {
   int64_t posix_time;
   if (!OPENSSL_tm_to_posix(tm, &posix_time)) {
     return 0;
@@ -221,8 +224,8 @@
   return 1;
 }
 
-int OPENSSL_gmtime_diff(int *out_days, int *out_secs, const struct tm *from,
-                        const struct tm *to) {
+int bssl::OPENSSL_gmtime_diff(int *out_days, int *out_secs,
+                              const struct tm *from, const struct tm *to) {
   int64_t time_to, time_from;
   if (!OPENSSL_tm_to_posix(to, &time_to) ||
       !OPENSSL_tm_to_posix(from, &time_from)) {
diff --git a/crypto/asn1/tasn_dec.cc b/crypto/asn1/tasn_dec.cc
index 8928bf4..20701df 100644
--- a/crypto/asn1/tasn_dec.cc
+++ b/crypto/asn1/tasn_dec.cc
@@ -27,6 +27,9 @@
 #include "../internal.h"
 #include "internal.h"
 
+
+using namespace bssl;
+
 // Constructed types with a recursive definition (such as can be found in PKCS7)
 // could eventually exceed the stack given malicious input with excessive
 // recursion. Therefore we limit the stack depth. This is the maximum number of
@@ -433,8 +436,9 @@
   return 0;
 }
 
-int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
-                     const ASN1_ITEM *it, int tag, int aclass, char opt) {
+int bssl::ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in,
+                           long len, const ASN1_ITEM *it, int tag, int aclass,
+                           char opt) {
   return asn1_item_ex_d2i(pval, in, len, it, tag, aclass, opt, /*depth=*/0);
 }
 
@@ -696,7 +700,7 @@
   // Handle non-|ASN1_STRING| types.
   switch (utype) {
     case V_ASN1_OBJECT: {
-      bssl::UniquePtr<ASN1_OBJECT> obj(asn1_parse_object(cbs, cbs_tag));
+      UniquePtr<ASN1_OBJECT> obj(asn1_parse_object(cbs, cbs_tag));
       if (obj == nullptr) {
         return 0;
       }
diff --git a/crypto/asn1/tasn_enc.cc b/crypto/asn1/tasn_enc.cc
index 07d74a8..1d1ad97 100644
--- a/crypto/asn1/tasn_enc.cc
+++ b/crypto/asn1/tasn_enc.cc
@@ -25,6 +25,8 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 static int asn1_item_ex_i2d_opt(ASN1_VALUE **pval, unsigned char **out,
                                 const ASN1_ITEM *it, int tag, int aclass,
                                 int optional);
@@ -69,8 +71,8 @@
 // Encode an item, taking care of IMPLICIT tagging (if any). This function
 // performs the normal item handling: it can be used in external types.
 
-int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
-                     const ASN1_ITEM *it, int tag, int aclass) {
+int bssl::ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
+                           const ASN1_ITEM *it, int tag, int aclass) {
   int ret = asn1_item_ex_i2d_opt(pval, out, it, tag, aclass, /*optional=*/0);
   assert(ret != 0);
   return ret;
diff --git a/crypto/asn1/tasn_fre.cc b/crypto/asn1/tasn_fre.cc
index b2ea466..7b5164b 100644
--- a/crypto/asn1/tasn_fre.cc
+++ b/crypto/asn1/tasn_fre.cc
@@ -21,13 +21,16 @@
 
 #include "internal.h"
 
+
+using namespace bssl;
+
 // Free up an ASN1 structure
 
 void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it) {
   ASN1_item_ex_free(&val, it);
 }
 
-void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
+void bssl::ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
   if (!pval) {
     return;
   }
@@ -112,7 +115,7 @@
   }
 }
 
-void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) {
+void bssl::ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) {
   if (tt->flags & ASN1_TFLG_SK_MASK) {
     STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval;
     for (size_t i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
@@ -126,7 +129,7 @@
   }
 }
 
-void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
+void bssl::ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
   // Historically, |it->funcs| for primitive types contained an
   // |ASN1_PRIMITIVE_FUNCS| table of callbacks.
   assert(it->funcs == nullptr);
diff --git a/crypto/asn1/tasn_new.cc b/crypto/asn1/tasn_new.cc
index 8756830..8278c87 100644
--- a/crypto/asn1/tasn_new.cc
+++ b/crypto/asn1/tasn_new.cc
@@ -25,6 +25,8 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it);
 static int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
 static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
@@ -41,7 +43,7 @@
 
 // Allocate an ASN1 structure
 
-int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it) {
+int bssl::ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it) {
   const ASN1_TEMPLATE *tt = nullptr;
   const ASN1_EXTERN_FUNCS *ef;
   ASN1_VALUE **pseqval;
diff --git a/crypto/asn1/tasn_typ.cc b/crypto/asn1/tasn_typ.cc
index faa82bc..0c3f6e2 100644
--- a/crypto/asn1/tasn_typ.cc
+++ b/crypto/asn1/tasn_typ.cc
@@ -19,6 +19,8 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 // TODO(crbug.com/42290417): While we need |ASN1_ITEM|s, the exposed new, free,
 // i2d, and d2i functions should call the underlying implementations directly.
 
@@ -55,10 +57,20 @@
 
 IMPLEMENT_ASN1_FUNCTIONS_const_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)
 
+BSSL_NAMESPACE_BEGIN
+
 IMPLEMENT_ASN1_MSTRING(DISPLAYTEXT, B_ASN1_DISPLAYTEXT)
+
+BSSL_NAMESPACE_END
+
 IMPLEMENT_ASN1_FUNCTIONS_const_fname(ASN1_STRING, DISPLAYTEXT, DISPLAYTEXT)
 
+BSSL_NAMESPACE_BEGIN
+
 IMPLEMENT_ASN1_MSTRING(DIRECTORYSTRING, B_ASN1_DIRECTORYSTRING)
+
+BSSL_NAMESPACE_END
+
 IMPLEMENT_ASN1_FUNCTIONS_const_fname(ASN1_STRING, DIRECTORYSTRING,
                                      DIRECTORYSTRING)
 
diff --git a/crypto/asn1/tasn_utl.cc b/crypto/asn1/tasn_utl.cc
index 981fba4..1cd8116 100644
--- a/crypto/asn1/tasn_utl.cc
+++ b/crypto/asn1/tasn_utl.cc
@@ -27,20 +27,22 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 // Utility functions for manipulating fields and offsets
 
 // Add 'offset' to 'addr'
 #define offset2ptr(addr, offset) (void *)(((char *)(addr)) + (offset))
 
 // Given an ASN1_ITEM CHOICE type return the selector value
-int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it) {
+int bssl::asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it) {
   int *sel = reinterpret_cast<int *>(offset2ptr(*pval, it->utype));
   return *sel;
 }
 
 // Given an ASN1_ITEM CHOICE type set the selector value, return old value.
-int asn1_set_choice_selector(ASN1_VALUE **pval, int value,
-                             const ASN1_ITEM *it) {
+int bssl::asn1_set_choice_selector(ASN1_VALUE **pval, int value,
+                                   const ASN1_ITEM *it) {
   int *sel, ret;
   sel = reinterpret_cast<int *>(offset2ptr(*pval, it->utype));
   ret = *sel;
@@ -61,14 +63,15 @@
       offset2ptr(*pval, aux->ref_offset));
 }
 
-void asn1_refcount_set_one(ASN1_VALUE **pval, const ASN1_ITEM *it) {
+void bssl::asn1_refcount_set_one(ASN1_VALUE **pval, const ASN1_ITEM *it) {
   CRYPTO_refcount_t *references = asn1_get_references(pval, it);
   if (references != nullptr) {
     *references = 1;
   }
 }
 
-int asn1_refcount_dec_and_test_zero(ASN1_VALUE **pval, const ASN1_ITEM *it) {
+int bssl::asn1_refcount_dec_and_test_zero(ASN1_VALUE **pval,
+                                          const ASN1_ITEM *it) {
   CRYPTO_refcount_t *references = asn1_get_references(pval, it);
   if (references != nullptr) {
     return CRYPTO_refcount_dec_and_test_zero(references);
@@ -76,7 +79,8 @@
   return 1;
 }
 
-static ASN1_ENCODING *asn1_get_enc_ptr(ASN1_VALUE **pval, const ASN1_ITEM *it) {
+static bssl::ASN1_ENCODING *asn1_get_enc_ptr(ASN1_VALUE **pval,
+                                             const ASN1_ITEM *it) {
   assert(it->itype == ASN1_ITYPE_SEQUENCE);
   const ASN1_AUX *aux;
   if (!pval || !*pval) {
@@ -89,7 +93,7 @@
   return reinterpret_cast<ASN1_ENCODING *>(offset2ptr(*pval, aux->enc_offset));
 }
 
-void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it) {
+void bssl::asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it) {
   ASN1_ENCODING *enc = asn1_get_enc_ptr(pval, it);
   if (enc) {
     enc->enc = nullptr;
@@ -97,15 +101,15 @@
   }
 }
 
-void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
+void bssl::asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
   ASN1_ENCODING *enc = asn1_get_enc_ptr(pval, it);
   if (enc) {
     asn1_encoding_clear(enc);
   }
 }
 
-int asn1_enc_save(ASN1_VALUE **pval, const uint8_t *in, size_t in_len,
-                  const ASN1_ITEM *it) {
+int bssl::asn1_enc_save(ASN1_VALUE **pval, const uint8_t *in, size_t in_len,
+                        const ASN1_ITEM *it) {
   ASN1_ENCODING *enc;
   enc = asn1_get_enc_ptr(pval, it);
   if (!enc) {
@@ -122,14 +126,14 @@
   return 1;
 }
 
-void asn1_encoding_clear(ASN1_ENCODING *enc) {
+void bssl::asn1_encoding_clear(ASN1_ENCODING *enc) {
   OPENSSL_free(enc->enc);
   enc->enc = nullptr;
   enc->len = 0;
 }
 
-int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,
-                     const ASN1_ITEM *it) {
+int bssl::asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,
+                           const ASN1_ITEM *it) {
   ASN1_ENCODING *enc = asn1_get_enc_ptr(pval, it);
   if (!enc || enc->len == 0) {
     return 0;
@@ -145,7 +149,8 @@
 }
 
 // Given an ASN1_TEMPLATE get a pointer to a field
-ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) {
+ASN1_VALUE **bssl::asn1_get_field_ptr(ASN1_VALUE **pval,
+                                      const ASN1_TEMPLATE *tt) {
   ASN1_VALUE **pvaltmp =
       reinterpret_cast<ASN1_VALUE **>(offset2ptr(*pval, tt->offset));
   // NOTE for BOOLEAN types the field is just a plain int so we can't return
@@ -155,8 +160,8 @@
 
 // Handle ANY DEFINED BY template, find the selector, look up the relevant
 // ASN1_TEMPLATE in the table and return it.
-const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,
-                                 int nullerr) {
+const ASN1_TEMPLATE *bssl::asn1_do_adb(ASN1_VALUE **pval,
+                                       const ASN1_TEMPLATE *tt, int nullerr) {
   const ASN1_ADB *adb;
   const ASN1_ADB_TABLE *atbl;
   ASN1_VALUE **sfld;
diff --git a/crypto/bytestring/cbs.cc b/crypto/bytestring/cbs.cc
index 671914d..167a0cd 100644
--- a/crypto/bytestring/cbs.cc
+++ b/crypto/bytestring/cbs.cc
@@ -26,6 +26,8 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 static int cbs_get(CBS *cbs, const uint8_t **p, size_t n) {
   if (cbs->len < n) {
     return 0;
@@ -760,7 +762,7 @@
 
 char *CBS_asn1_relative_oid_to_text(const CBS *cbs) {
   CBS copy = *cbs;
-  bssl::ScopedCBB cbb;
+  ScopedCBB cbb;
   if (!CBB_init(cbb.get(), 32)) {
     return nullptr;
   }
diff --git a/crypto/x509/internal.h b/crypto/x509/internal.h
index 4310089..ddb1471 100644
--- a/crypto/x509/internal.h
+++ b/crypto/x509/internal.h
@@ -152,7 +152,7 @@
 DECLARE_ASN1_ITEM(X509)
 
 typedef struct {
-  ASN1_ENCODING enc;
+  bssl::ASN1_ENCODING enc;
   ASN1_INTEGER *version;
   X509_NAME *subject;
   X509_PUBKEY *pubkey;
@@ -193,7 +193,7 @@
   ASN1_TIME *nextUpdate;
   STACK_OF(X509_REVOKED) *revoked;
   STACK_OF(X509_EXTENSION) /* [0] */ *extensions;
-  ASN1_ENCODING enc;
+  bssl::ASN1_ENCODING enc;
 } X509_CRL_INFO;
 
 DECLARE_ASN1_FUNCTIONS_const(X509_CRL_INFO)
diff --git a/crypto/x509/v3_cpols.cc b/crypto/x509/v3_cpols.cc
index 2d65775..8bfd919 100644
--- a/crypto/x509/v3_cpols.cc
+++ b/crypto/x509/v3_cpols.cc
@@ -26,6 +26,9 @@
 
 #include "internal.h"
 
+
+using namespace bssl;
+
 // Certificate policies extension support: this one is a bit complex...
 
 static int i2r_certpol(const X509V3_EXT_METHOD *method, void *ext, BIO *out,
diff --git a/crypto/x509/v3_genn.cc b/crypto/x509/v3_genn.cc
index 5d0d4e4..872dce5 100644
--- a/crypto/x509/v3_genn.cc
+++ b/crypto/x509/v3_genn.cc
@@ -22,6 +22,8 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 ASN1_SEQUENCE(OTHERNAME) = {
     ASN1_SIMPLE(OTHERNAME, type_id, ASN1_OBJECT),
     // Maybe have a true ANY DEFINED BY later
diff --git a/crypto/x509/x509_att.cc b/crypto/x509/x509_att.cc
index 3afcf48..654db94 100644
--- a/crypto/x509/x509_att.cc
+++ b/crypto/x509/x509_att.cc
@@ -21,6 +21,8 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
                                              int attrtype, const void *data,
                                              int len) {
diff --git a/crypto/x509/x_algor.cc b/crypto/x509/x_algor.cc
index 6f8c270..1e64b46 100644
--- a/crypto/x509/x_algor.cc
+++ b/crypto/x509/x_algor.cc
@@ -28,6 +28,8 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 void x509_algor_init(X509_ALGOR *alg) {
   OPENSSL_memset(alg, 0, sizeof(X509_ALGOR));
   alg->algorithm = const_cast<ASN1_OBJECT *>(OBJ_get_undef());
@@ -39,7 +41,7 @@
 }
 
 X509_ALGOR *X509_ALGOR_new() {
-  bssl::UniquePtr<X509_ALGOR> ret = bssl::MakeUnique<X509_ALGOR>();
+  UniquePtr<X509_ALGOR> ret = MakeUnique<X509_ALGOR>();
   if (ret == nullptr) {
     return nullptr;
   }
@@ -61,7 +63,7 @@
     return 0;
   }
 
-  bssl::UniquePtr<ASN1_OBJECT> obj(asn1_parse_object(&seq, /*tag=*/0));
+  UniquePtr<ASN1_OBJECT> obj(asn1_parse_object(&seq, /*tag=*/0));
   if (obj == nullptr) {
     return 0;
   }
@@ -95,18 +97,17 @@
 }
 
 X509_ALGOR *d2i_X509_ALGOR(X509_ALGOR **out, const uint8_t **inp, long len) {
-  return bssl::D2IFromCBS(
-      out, inp, len, [](CBS *cbs) -> bssl::UniquePtr<X509_ALGOR> {
-        bssl::UniquePtr<X509_ALGOR> ret(X509_ALGOR_new());
-        if (ret == nullptr || !x509_parse_algorithm(cbs, ret.get())) {
-          return nullptr;
-        }
-        return ret;
-      });
+  return D2IFromCBS(out, inp, len, [](CBS *cbs) -> UniquePtr<X509_ALGOR> {
+    UniquePtr<X509_ALGOR> ret(X509_ALGOR_new());
+    if (ret == nullptr || !x509_parse_algorithm(cbs, ret.get())) {
+      return nullptr;
+    }
+    return ret;
+  });
 }
 
 int i2d_X509_ALGOR(const X509_ALGOR *in, uint8_t **outp) {
-  return bssl::I2DFromCBB(/*initial_capacity=*/32, outp, [&](CBB *cbb) -> bool {
+  return I2DFromCBB(/*initial_capacity=*/32, outp, [&](CBB *cbb) -> bool {
     return x509_marshal_algorithm(cbb, in);
   });
 }
@@ -116,7 +117,7 @@
                              i2d_X509_ALGOR)
 
 X509_ALGOR *X509_ALGOR_dup(const X509_ALGOR *alg) {
-  bssl::UniquePtr<X509_ALGOR> copy(X509_ALGOR_new());
+  UniquePtr<X509_ALGOR> copy(X509_ALGOR_new());
   if (copy == nullptr || !X509_ALGOR_copy(copy.get(), alg)) {
     return nullptr;
   }
@@ -124,11 +125,11 @@
 }
 
 int X509_ALGOR_copy(X509_ALGOR *dst, const X509_ALGOR *src) {
-  bssl::UniquePtr<ASN1_OBJECT> algorithm(OBJ_dup(src->algorithm));
+  UniquePtr<ASN1_OBJECT> algorithm(OBJ_dup(src->algorithm));
   if (algorithm == nullptr) {
     return 0;
   }
-  bssl::UniquePtr<ASN1_TYPE> parameter;
+  UniquePtr<ASN1_TYPE> parameter;
   if (src->parameter != nullptr) {
     parameter.reset(ASN1_TYPE_new());
     if (parameter == nullptr ||
diff --git a/crypto/x509/x_crl.cc b/crypto/x509/x_crl.cc
index 1d22ed6..23770e5 100644
--- a/crypto/x509/x_crl.cc
+++ b/crypto/x509/x_crl.cc
@@ -28,6 +28,9 @@
 #include "../internal.h"
 #include "internal.h"
 
+
+using namespace bssl;
+
 static int X509_REVOKED_cmp(const X509_REVOKED *const *a,
                             const X509_REVOKED *const *b);
 static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp);
diff --git a/crypto/x509/x_name.cc b/crypto/x509/x_name.cc
index 12ab827..3f49dbf 100644
--- a/crypto/x509/x_name.cc
+++ b/crypto/x509/x_name.cc
@@ -35,13 +35,15 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 // X509_NAME_MAX is the length of the maximum encoded |X509_NAME| we accept.
 #define X509_NAME_MAX (1024 * 1024)
 
 static int asn1_marshal_string_canon(CBB *cbb, const ASN1_STRING *in);
 
 X509_NAME_ENTRY *X509_NAME_ENTRY_new() {
-  bssl::UniquePtr<X509_NAME_ENTRY> ret = bssl::MakeUnique<X509_NAME_ENTRY>();
+  UniquePtr<X509_NAME_ENTRY> ret = MakeUnique<X509_NAME_ENTRY>();
   if (ret == nullptr) {
     return nullptr;
   }
@@ -92,7 +94,7 @@
 }
 
 static int i2d_x509_name_entry(const X509_NAME_ENTRY *entry, uint8_t **out) {
-  return bssl::I2DFromCBB(/*initial_capacity=*/16, out, [&](CBB *cbb) -> bool {
+  return I2DFromCBB(/*initial_capacity=*/16, out, [&](CBB *cbb) -> bool {
     return x509_marshal_name_entry(cbb, entry, /*canonicalize=*/0);
   });
 }
@@ -102,14 +104,14 @@
                              x509_parse_name_entry, i2d_x509_name_entry)
 
 X509_NAME_ENTRY *X509_NAME_ENTRY_dup(const X509_NAME_ENTRY *entry) {
-  bssl::ScopedCBB cbb;
+  ScopedCBB cbb;
   if (!CBB_init(cbb.get(), 16) ||
       !x509_marshal_name_entry(cbb.get(), entry, /*canonicalize=*/0)) {
     return nullptr;
   }
   CBS cbs;
   CBS_init(&cbs, CBB_data(cbb.get()), CBB_len(cbb.get()));
-  bssl::UniquePtr<X509_NAME_ENTRY> copy(X509_NAME_ENTRY_new());
+  UniquePtr<X509_NAME_ENTRY> copy(X509_NAME_ENTRY_new());
   if (copy == nullptr || !x509_parse_name_entry(&cbs, copy.get())) {
     return nullptr;
   }
@@ -168,12 +170,12 @@
       return 0;
     }
     while (CBS_len(&rdn) != 0) {
-      bssl::UniquePtr<X509_NAME_ENTRY> entry(X509_NAME_ENTRY_new());
+      UniquePtr<X509_NAME_ENTRY> entry(X509_NAME_ENTRY_new());
       if (entry == nullptr || !x509_parse_name_entry(&rdn, entry.get())) {
         return 0;
       }
       entry->set = set;
-      if (!bssl::PushToStack(out->entries, std::move(entry))) {
+      if (!PushToStack(out->entries, std::move(entry))) {
         return 0;
       }
     }
@@ -222,7 +224,7 @@
   X509_NAME_CACHE *new_cache =
       static_cast<X509_NAME_CACHE *>(OPENSSL_zalloc(sizeof(X509_NAME_CACHE)));
   // Cache the DER encoding, including the outer TLV.
-  bssl::ScopedCBB cbb;
+  ScopedCBB cbb;
   CBB seq;
   if (!CBB_init(cbb.get(), 16) ||
       !CBB_add_asn1(cbb.get(), &seq, CBS_ASN1_SEQUENCE) ||
@@ -286,7 +288,7 @@
 }
 
 X509_NAME *X509_NAME_dup(const X509_NAME *name) {
-  bssl::UniquePtr<X509_NAME> copy(X509_NAME_new());
+  UniquePtr<X509_NAME> copy(X509_NAME_new());
   if (copy == nullptr || !x509_name_copy(copy.get(), name)) {
     return nullptr;
   }
@@ -294,14 +296,13 @@
 }
 
 X509_NAME *d2i_X509_NAME(X509_NAME **out, const uint8_t **inp, long len) {
-  return bssl::D2IFromCBS(
-      out, inp, len, [](CBS *cbs) -> bssl::UniquePtr<X509_NAME> {
-        bssl::UniquePtr<X509_NAME> name(X509_NAME_new());
-        if (name == nullptr || !x509_parse_name(cbs, name.get())) {
-          return nullptr;
-        }
-        return name;
-      });
+  return D2IFromCBS(out, inp, len, [](CBS *cbs) -> UniquePtr<X509_NAME> {
+    UniquePtr<X509_NAME> name(X509_NAME_new());
+    if (name == nullptr || !x509_parse_name(cbs, name.get())) {
+      return nullptr;
+    }
+    return name;
+  });
 }
 
 int i2d_X509_NAME(const X509_NAME *in, uint8_t **outp) {
@@ -404,7 +405,7 @@
 }
 
 int X509_NAME_set(X509_NAME **xn, const X509_NAME *name) {
-  bssl::UniquePtr<X509_NAME> copy(X509_NAME_dup(name));
+  UniquePtr<X509_NAME> copy(X509_NAME_dup(name));
   if (copy == nullptr) {
     return 0;
   }
diff --git a/crypto/x509/x_pubkey.cc b/crypto/x509/x_pubkey.cc
index 4b0f3d6..11b7269 100644
--- a/crypto/x509/x_pubkey.cc
+++ b/crypto/x509/x_pubkey.cc
@@ -33,6 +33,8 @@
 #include "internal.h"
 
 
+using namespace bssl;
+
 void x509_pubkey_init(X509_PUBKEY *key) {
   OPENSSL_memset(key, 0, sizeof(X509_PUBKEY));
   x509_algor_init(&key->algor);
@@ -40,7 +42,7 @@
 }
 
 X509_PUBKEY *X509_PUBKEY_new() {
-  bssl::UniquePtr<X509_PUBKEY> ret = bssl::MakeUnique<X509_PUBKEY>();
+  UniquePtr<X509_PUBKEY> ret = MakeUnique<X509_PUBKEY>();
   if (ret == nullptr) {
     return nullptr;
   }
@@ -62,19 +64,19 @@
 }
 
 static void x509_pubkey_changed(X509_PUBKEY *pub,
-                                bssl::Span<const EVP_PKEY_ALG *const> algs) {
+                                Span<const EVP_PKEY_ALG *const> algs) {
   EVP_PKEY_free(pub->pkey);
   pub->pkey = nullptr;
 
   // Re-encode the |X509_PUBKEY| to DER and parse it with EVP's APIs. If the
   // operation fails, clear errors. An |X509_PUBKEY| whose key we cannot parse
   // is still a valid SPKI. It just cannot be converted to an |EVP_PKEY|.
-  bssl::ScopedCBB cbb;
+  ScopedCBB cbb;
   if (!CBB_init(cbb.get(), 64) || !x509_marshal_public_key(cbb.get(), pub)) {
     ERR_clear_error();
     return;
   }
-  bssl::UniquePtr<EVP_PKEY> pkey(EVP_PKEY_from_subject_public_key_info(
+  UniquePtr<EVP_PKEY> pkey(EVP_PKEY_from_subject_public_key_info(
       CBB_data(cbb.get()), CBB_len(cbb.get()), algs.data(), algs.size()));
   if (pkey == nullptr) {
     ERR_clear_error();
@@ -85,7 +87,7 @@
 }
 
 int x509_parse_public_key(CBS *cbs, X509_PUBKEY *out,
-                          bssl::Span<const EVP_PKEY_ALG *const> algs) {
+                          Span<const EVP_PKEY_ALG *const> algs) {
   CBS seq;
   if (!CBS_get_asn1(cbs, &seq, CBS_ASN1_SEQUENCE) ||
       !x509_parse_algorithm(&seq, &out->algor) ||
@@ -99,7 +101,7 @@
 }
 
 static int x509_parse_public_key_default(CBS *cbs, X509_PUBKEY *out) {
-  return x509_parse_public_key(cbs, out, bssl::GetDefaultEVPAlgorithms());
+  return x509_parse_public_key(cbs, out, GetDefaultEVPAlgorithms());
 }
 
 int x509_marshal_public_key(CBB *cbb, const X509_PUBKEY *in) {
@@ -111,18 +113,17 @@
 }
 
 X509_PUBKEY *d2i_X509_PUBKEY(X509_PUBKEY **out, const uint8_t **inp, long len) {
-  return bssl::D2IFromCBS(
-      out, inp, len, [](CBS *cbs) -> bssl::UniquePtr<X509_PUBKEY> {
-        bssl::UniquePtr<X509_PUBKEY> ret(X509_PUBKEY_new());
-        if (ret == nullptr || !x509_parse_public_key_default(cbs, ret.get())) {
-          return nullptr;
-        }
-        return ret;
-      });
+  return D2IFromCBS(out, inp, len, [](CBS *cbs) -> UniquePtr<X509_PUBKEY> {
+    UniquePtr<X509_PUBKEY> ret(X509_PUBKEY_new());
+    if (ret == nullptr || !x509_parse_public_key_default(cbs, ret.get())) {
+      return nullptr;
+    }
+    return ret;
+  });
 }
 
 int i2d_X509_PUBKEY(const X509_PUBKEY *key, uint8_t **outp) {
-  return bssl::I2DFromCBB(/*initial_capacity=*/32, outp, [&](CBB *cbb) -> bool {
+  return I2DFromCBB(/*initial_capacity=*/32, outp, [&](CBB *cbb) -> bool {
     return x509_marshal_public_key(cbb, key);
   });
 }
@@ -134,9 +135,8 @@
                              i2d_X509_PUBKEY)
 
 int x509_pubkey_set1(X509_PUBKEY *key, EVP_PKEY *pkey) {
-  bssl::ScopedCBB cbb;
-  if (!CBB_init(cbb.get(), 64) ||
-      !EVP_marshal_public_key(cbb.get(), pkey)) {
+  ScopedCBB cbb;
+  if (!CBB_init(cbb.get(), 64) || !EVP_marshal_public_key(cbb.get(), pkey)) {
     OPENSSL_PUT_ERROR(X509, X509_R_PUBLIC_KEY_ENCODE_ERROR);
     return 0;
   }
@@ -146,11 +146,11 @@
   // TODO(crbug.com/42290364): Use an |EVP_PKEY_ALG| derived from |pkey|.
   // |X509_PUBKEY_get0| does not currently work when setting, say, an
   // |EVP_PKEY_RSA_PSS| key.
-  return x509_parse_public_key(&cbs, key, bssl::GetDefaultEVPAlgorithms());
+  return x509_parse_public_key(&cbs, key, GetDefaultEVPAlgorithms());
 }
 
 int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) {
-  bssl::UniquePtr<X509_PUBKEY> new_key(X509_PUBKEY_new());
+  UniquePtr<X509_PUBKEY> new_key(X509_PUBKEY_new());
   if (new_key == nullptr || !x509_pubkey_set1(new_key.get(), pkey)) {
     return 0;
   }
@@ -191,7 +191,7 @@
   pub->public_key.flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);
   pub->public_key.flags |= ASN1_STRING_FLAG_BITS_LEFT;
 
-  x509_pubkey_changed(pub, bssl::GetDefaultEVPAlgorithms());
+  x509_pubkey_changed(pub, GetDefaultEVPAlgorithms());
   return 1;
 }
 
diff --git a/crypto/x509/x_x509.cc b/crypto/x509/x_x509.cc
index 614bbb0..7590216 100644
--- a/crypto/x509/x_x509.cc
+++ b/crypto/x509/x_x509.cc
@@ -31,6 +31,9 @@
 #include "../internal.h"
 #include "internal.h"
 
+
+using namespace bssl;
+
 static CRYPTO_EX_DATA_CLASS g_ex_data_class = CRYPTO_EX_DATA_CLASS_INIT;
 
 static constexpr CBS_ASN1_TAG kVersionTag =
@@ -41,8 +44,7 @@
     CBS_ASN1_CONSTRUCTED | CBS_ASN1_CONTEXT_SPECIFIC | 3;
 
 X509 *X509_new() {
-  bssl::UniquePtr<X509> ret(
-      reinterpret_cast<X509 *>(OPENSSL_zalloc(sizeof(X509))));
+  UniquePtr<X509> ret(reinterpret_cast<X509 *>(OPENSSL_zalloc(sizeof(X509))));
   if (ret == nullptr) {
     return nullptr;
   }
@@ -99,13 +101,13 @@
 X509 *X509_parse_with_algorithms(CRYPTO_BUFFER *buf,
                                  const EVP_PKEY_ALG *const *algs,
                                  size_t num_algs) {
-  bssl::UniquePtr<X509> ret(X509_new());
+  UniquePtr<X509> ret(X509_new());
   if (ret == nullptr) {
     return nullptr;
   }
 
   // Save the buffer to cache the original encoding.
-  ret->buf = bssl::UpRef(buf).release();
+  ret->buf = UpRef(buf).release();
 
   // Parse the Certificate.
   CBS cbs, cert, tbs;
@@ -161,7 +163,7 @@
                        /*allow_utc_timezone_offset=*/1) ||
       CBS_len(&validity) != 0 ||  //
       !x509_parse_name(&tbs, &ret->subject) ||
-      !x509_parse_public_key(&tbs, &ret->key, bssl::Span(algs, num_algs))) {
+      !x509_parse_public_key(&tbs, &ret->key, Span(algs, num_algs))) {
     OPENSSL_PUT_ERROR(ASN1, ASN1_R_DECODE_ERROR);
     return nullptr;
   }
@@ -211,22 +213,22 @@
 }
 
 X509 *X509_parse_from_buffer(CRYPTO_BUFFER *buf) {
-  auto algs = bssl::GetDefaultEVPAlgorithms();
+  auto algs = GetDefaultEVPAlgorithms();
   return X509_parse_with_algorithms(buf, algs.data(), algs.size());
 }
 
-static bssl::UniquePtr<X509> x509_parse(CBS *cbs) {
+static UniquePtr<X509> x509_parse(CBS *cbs) {
   CBS cert;
   if (!CBS_get_asn1_element(cbs, &cert, CBS_ASN1_SEQUENCE)) {
     OPENSSL_PUT_ERROR(ASN1, ASN1_R_DECODE_ERROR);
     return nullptr;
   }
 
-  bssl::UniquePtr<CRYPTO_BUFFER> buf(CRYPTO_BUFFER_new_from_CBS(&cert, nullptr));
+  UniquePtr<CRYPTO_BUFFER> buf(CRYPTO_BUFFER_new_from_CBS(&cert, nullptr));
   if (buf == nullptr) {
     return nullptr;
   }
-  return bssl::UniquePtr<X509>(X509_parse_from_buffer(buf.get()));
+  return UniquePtr<X509>(X509_parse_from_buffer(buf.get()));
 }
 
 int x509_marshal_tbs_cert(CBB *cbb, const X509 *x509) {
@@ -293,7 +295,7 @@
 }
 
 X509 *d2i_X509(X509 **out, const uint8_t **inp, long len) {
-  return bssl::D2IFromCBS(out, inp, len, x509_parse);
+  return D2IFromCBS(out, inp, len, x509_parse);
 }
 
 int i2d_X509(const X509 *x509, uint8_t **outp) {
@@ -302,7 +304,7 @@
     return -1;
   }
 
-  return bssl::I2DFromCBB(
+  return I2DFromCBB(
       /*initial_capacity=*/256, outp,
       [&](CBB *cbb) -> bool { return x509_marshal(cbb, x509); });
 }
@@ -323,7 +325,7 @@
     return 1;
   }
 
-  bssl::UniquePtr<X509> ret = x509_parse(cbs);
+  UniquePtr<X509> ret = x509_parse(cbs);
   if (ret == nullptr) {
     return 0;
   }
@@ -485,7 +487,7 @@
 }
 
 int i2d_X509_tbs(const X509 *x509, uint8_t **outp) {
-  return bssl::I2DFromCBB(/*initial_capacity=*/128, outp, [&](CBB *cbb) -> bool {
+  return I2DFromCBB(/*initial_capacity=*/128, outp, [&](CBB *cbb) -> bool {
     return x509_marshal_tbs_cert(cbb, x509);
   });
 }
diff --git a/include/openssl/asn1t.h b/include/openssl/asn1t.h
index f682e53..22b1688 100644
--- a/include/openssl/asn1t.h
+++ b/include/openssl/asn1t.h
@@ -453,7 +453,7 @@
   uint32_t flags;
   int ref_offset; /* Offset of reference value */
   ASN1_aux_cb *asn1_cb;
-  int enc_offset; /* Offset of ASN1_ENCODING structure */
+  int enc_offset; /* Offset of bssl::ASN1_ENCODING structure */
 } ASN1_AUX;
 
 /* Flags in ASN1_AUX */