asn1_string_st class final
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. 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|, |V_ASN1_VIDEOTEXSTRING|, |V_ASN1_IA5STRING|, |V_ASN1_GRAPHICSTRING|, |V_ASN1_ISO64STRING|, |V_ASN1_VISIBLESTRING|, |V_ASN1_GENERALSTRING|, |V_ASN1_UNIVERSALSTRING|, or |V_ASN1_BMPSTRING|, the object represents an ASN.1 string type. The data contains the byte representation of the string.
If |type| is |V_ASN1_BIT_STRING|, the object represents a BIT STRING value. See bit string documentation below for the data and flags.
If |type| is one of |V_ASN1_INTEGER|, |V_ASN1_NEG_INTEGER|, |V_ASN1_ENUMERATED|, or |V_ASN1_NEG_ENUMERATED|, the object represents an INTEGER or ENUMERATED value. See integer documentation below for details.
If |type| is |V_ASN1_GENERALIZEDTIME| or |V_ASN1_UTCTIME|, the object represents a GeneralizedTime or UTCTime value, respectively. The data contains the DER encoding of the value. For example, the UNIX epoch would be "19700101000000Z" for a GeneralizedTime and "700101000000Z" for a UTCTime.
If |type| is |V_ASN1_SEQUENCE|, |V_ASN1_SET|, or |V_ASN1_OTHER|, the object represents a SEQUENCE, SET, or arbitrary ASN.1 value, respectively. Unlike the above cases, the data contains the DER encoding of the entire structure, including the header. If the value is explicitly or implicitly tagged, this too will be reflected in the data field. As this case handles unknown types, the contents are not checked when parsing or serializing.
Other values of |type| do not represent a valid ASN.1 value, though default-constructed objects may set |type| to -1. Such objects cannot be serialized.
|ASN1_STRING| additionally has the following typedefs: |ASN1_BIT_STRING|, |ASN1_BMPSTRING|, |ASN1_ENUMERATED|, |ASN1_GENERALIZEDTIME|, |ASN1_GENERALSTRING|, |ASN1_IA5STRING|, |ASN1_INTEGER|, |ASN1_OCTET_STRING|, |ASN1_PRINTABLESTRING|, |ASN1_T61STRING|, |ASN1_TIME|, |ASN1_UNIVERSALSTRING|, |ASN1_UTCTIME|, |ASN1_UTF8STRING|, and |ASN1_VISIBLESTRING|. Other than |ASN1_TIME|, these correspond to universal ASN.1 types. |ASN1_TIME| represents a CHOICE of UTCTime and GeneralizedTime, with a cutoff of 2049, as used in Section 4.1.2.5 of RFC 5280.
For clarity, callers are encouraged to use the appropriate typedef when available. They are the same type as |ASN1_STRING|, so a caller may freely pass them into functions expecting |ASN1_STRING|, such as |ASN1_STRING_length|.
If a function returns an |ASN1_STRING| where the typedef or ASN.1 structure implies constraints on |type|, callers may assume that |type| is correct. However, if a function takes an |ASN1_STRING| as input, callers must ensure |type| matches. These invariants are not captured by the C type system and may not be checked at runtime. For example, callers may assume the output of |X509_get0_serialNumber| has type |V_ASN1_INTEGER| or |V_ASN1_NEG_INTEGER|. Callers must not pass a string of type |V_ASN1_OCTET_STRING| to |X509_set_serialNumber|. Doing so may break invariants on the |X509| object and break the |X509_get0_serialNumber| invariant.
TODO(https://crbug.com/boringssl/445): This is very unfriendly. Getting the type field wrong should not cause memory errors, but it may do strange things. We should add runtime checks to anything that consumes |ASN1_STRING|s from the caller.
- Inheritance
- Implemented types
- Available extensions
Constructors
Properties
-
address
→ Pointer<
T> -
Available on T, provided by the StructAddress extension
The memory address of the underlying data.no setter -
data
↔ Pointer<
UnsignedChar> -
getter/setter pair
- flags ↔ int
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- length ↔ int
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- type ↔ int
-
getter/setter pair
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
$allocate(
Allocator $allocator, {required int length, required int type, required Pointer< UnsignedChar> data, required int flags}) → Pointer<ASN1_OCTET_STRING>