Don't accept tag number 31 (long form identifier octets) in CBB_add_asn1.

Tag number 31 is a long form tag that requires multiple octets.  It
cannot be handled by adding a single uint8.  Changed CBB_add_asn1()
to return 0 when it is passed in the extension for tag 31.

Change-Id: Ia33936d4f174d1a7176eb11da0b5c7370efb9416
diff --git a/crypto/bytestring/cbb.c b/crypto/bytestring/cbb.c
index 7dc6342..e146727 100644
--- a/crypto/bytestring/cbb.c
+++ b/crypto/bytestring/cbb.c
@@ -280,6 +280,11 @@
 }
 
 int CBB_add_asn1(CBB *cbb, CBB *out_contents, uint8_t tag) {
+  if ((tag & 0x1f) == 0x1f) {
+    /* Long form identifier octets are not supported. */
+    return 0;
+  }
+
   if (!CBB_flush(cbb) ||
       !CBB_add_u8(cbb, tag)) {
     return 0;
diff --git a/include/openssl/bytestring.h b/include/openssl/bytestring.h
index bfbdd03..e10621a 100644
--- a/include/openssl/bytestring.h
+++ b/include/openssl/bytestring.h
@@ -287,7 +287,9 @@
 
 /* CBB_add_asn sets |*out_contents| to a |CBB| into which the contents of an
  * ASN.1 object can be written. The |tag| argument will be used as the tag for
- * the object. It returns one on success or zero on error. */
+ * the object. Passing in |tag| number 31 will return in an error since only
+ * single octet identifiers are supported. It returns one on success or zero
+ * on error. */
 OPENSSL_EXPORT int CBB_add_asn1(CBB *cbb, CBB *out_contents, uint8_t tag);
 
 /* CBB_add_bytes appends |len| bytes from |data| to |cbb|. It returns one on