Support the allocating case of i2d_ASN1_{BOOLEAN,OBJECT}.

Imported from upstream's 0971432f6f6d8b40d797133621809bd31eb7bf4e and
7d4c97add12cfa5d4589880b09d6139c3203e2f4, but with missing tests added. Along
the way, make Bytes work with any Span<const uint8_t>-convertable type.

Change-Id: If365f981fe8a8274e12000309ffd99b1bb719842
Reviewed-on: https://boringssl-review.googlesource.com/31086
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/test/test_util.cc b/crypto/test/test_util.cc
index 4ad777f..29be702 100644
--- a/crypto/test/test_util.cc
+++ b/crypto/test/test_util.cc
@@ -30,15 +30,15 @@
 }
 
 std::ostream &operator<<(std::ostream &os, const Bytes &in) {
-  if (in.len == 0) {
+  if (in.span_.empty()) {
     return os << "<empty Bytes>";
   }
 
   // Print a byte slice as hex.
   static const char hex[] = "0123456789abcdef";
-  for (size_t i = 0; i < in.len; i++) {
-    os << hex[in.data[i] >> 4];
-    os << hex[in.data[i] & 0xf];
+  for (uint8_t b : in.span_) {
+    os << hex[b >> 4];
+    os << hex[b & 0xf];
   }
   return os;
 }