crypto/asn1: Constify ASN1_STRING_data

Update-Note: ASN1_STRING_data can no longer be used to mutate the
ASN1_STRING's data. To enable some optimizations, we are removing
all direct, mutable access to ASN1_STRING's buffer. Users should
use ASN1_STRING_set1_data to replace the content.

Fixed: 574019297
Signed-off-by: Xiangfei Ding <xfding@google.com>
Change-Id: I76ea8819755dbc3db247dc1ee9086b7b6a6a6964
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/105888
Presubmit-BoringSSL-Verified: boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Benjamin <davidben@google.com>
diff --git a/crypto/asn1/asn1_lib.cc b/crypto/asn1/asn1_lib.cc
index 416fc71..e45fec1 100644
--- a/crypto/asn1/asn1_lib.cc
+++ b/crypto/asn1/asn1_lib.cc
@@ -388,7 +388,7 @@
 
 int ASN1_STRING_type(const ASN1_STRING *str) { return str->type; }
 
-unsigned char *ASN1_STRING_data(ASN1_STRING *str) { return str->data; }
+const uint8_t *ASN1_STRING_data(const ASN1_STRING *str) { return str->data; }
 
 const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *str) {
   return str->data;
diff --git a/include/openssl/asn1.h b/include/openssl/asn1.h
index 1adae57..441c551 100644
--- a/include/openssl/asn1.h
+++ b/include/openssl/asn1.h
@@ -1811,7 +1811,7 @@
 // type. See the documentation for `ASN1_STRING` for details.
 //
 // Prefer `ASN1_STRING_get0_data`. See crbug.com/574019297.
-OPENSSL_EXPORT unsigned char *ASN1_STRING_data(ASN1_STRING *str);
+OPENSSL_EXPORT const uint8_t *ASN1_STRING_data(const ASN1_STRING *str);
 
 // ASN1_STRING_length returns the length of `str`, in bytes. Prefer
 // `ASN1_STRING_get_length`.