Skip to content

Commit

Permalink
Clarify that ASN1_STRING reprs are not always the DER one
Browse files Browse the repository at this point in the history
Change-Id: I2f3ced7723925542d2dbf0cff1a458b43c7bf48e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/70587
Commit-Queue: Adam Langley <[email protected]>
Auto-Submit: David Benjamin <[email protected]>
Reviewed-by: Adam Langley <[email protected]>
  • Loading branch information
davidben authored and Boringssl LUCI CQ committed Aug 27, 2024
1 parent 0a2d3a4 commit 3551079
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion include/openssl/asn1.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,8 @@ DECLARE_ASN1_ITEM(ASN1_FBOOLEAN)

// An asn1_string_st (aka |ASN1_STRING|) represents a value of a string-like
// ASN.1 type. It contains a |type| field, and a byte string |data| field with a
// type-specific representation.
// type-specific representation. This type-specific representation does not
// always correspond to the DER encoding of the type.
//
// If |type| is one of |V_ASN1_OCTET_STRING|, |V_ASN1_UTF8STRING|,
// |V_ASN1_NUMERICSTRING|, |V_ASN1_PRINTABLESTRING|, |V_ASN1_T61STRING|,
Expand Down Expand Up @@ -568,17 +569,29 @@ OPENSSL_EXPORT int ASN1_STRING_type(const ASN1_STRING *str);
// ASN1_STRING_get0_data returns a pointer to |str|'s contents. Callers should
// use |ASN1_STRING_length| to determine the length of the string. The string
// may have embedded NUL bytes and may not be NUL-terminated.
//
// The contents of an |ASN1_STRING| encode the value in some type-specific
// representation that does not always correspond to the DER encoding of the
// type. See the documentation for |ASN1_STRING| for details.
OPENSSL_EXPORT const unsigned char *ASN1_STRING_get0_data(
const ASN1_STRING *str);

// ASN1_STRING_data returns a mutable pointer to |str|'s contents. Callers
// should use |ASN1_STRING_length| to determine the length of the string. The
// string may have embedded NUL bytes and may not be NUL-terminated.
//
// The contents of an |ASN1_STRING| encode the value in some type-specific
// representation that does not always correspond to the DER encoding of the
// type. See the documentation for |ASN1_STRING| for details.
//
// Prefer |ASN1_STRING_get0_data|.
OPENSSL_EXPORT unsigned char *ASN1_STRING_data(ASN1_STRING *str);

// ASN1_STRING_length returns the length of |str|, in bytes.
//
// The contents of an |ASN1_STRING| encode the value in some type-specific
// representation that does not always correspond to the DER encoding of the
// type. See the documentation for |ASN1_STRING| for details.
OPENSSL_EXPORT int ASN1_STRING_length(const ASN1_STRING *str);

// ASN1_STRING_cmp compares |a| and |b|'s type and contents. It returns an
Expand Down

0 comments on commit 3551079

Please sign in to comment.