X509_ATTRIBUTE_set1_data function
X509_ATTRIBUTE_set1_data appends a value to |attr|'s value set and returns one on success or zero on error. The value is determined as follows:
If |attrtype| is zero, this function returns one and does nothing. This form may be used when calling |X509_ATTRIBUTE_create_by_*| to create an attribute with an empty value set. Such attributes are invalid, but OpenSSL supports creating them.
Otherwise, if |attrtype| is a |MBSTRING_*| constant, the value is an ASN.1 string. The string is determined by decoding |len| bytes from |data| in the encoding specified by |attrtype|, and then re-encoding it in a form appropriate for |attr|'s type. If |len| is -1, |strlen(data)| is used instead. See |ASN1_STRING_set_by_NID| for details.
Otherwise, if |len| is not -1, the value is an ASN.1 string. |attrtype| is an |ASN1_STRING| type value and the |len| bytes from |data| are copied as the type-specific representation of |ASN1_STRING|. See |ASN1_STRING| for details.
Otherwise, if |len| is -1, the value is constructed by passing |attrtype| and |data| to |ASN1_TYPE_set1|. That is, |attrtype| is an |ASN1_TYPE| type value, and |data| is cast to the corresponding pointer type.
WARNING: Despite the name, this function appends to |attr|'s value set, rather than overwriting it. To overwrite the value set, create a new |X509_ATTRIBUTE| with |X509_ATTRIBUTE_new|.
WARNING: If using the |MBSTRING_*| form, pass a length rather than relying on |strlen|. In particular, |strlen| will not behave correctly if the input is |MBSTRING_BMP| or |MBSTRING_UNIV|.
WARNING: This function currently misinterprets |V_ASN1_OTHER| as an |MBSTRING_*| constant. This matches OpenSSL but means it is impossible to construct a value with a non-universal tag.
Implementation
@meta.RecordUse()
@ffi.Native<
ffi.Int Function(
ffi.Pointer<X509_ATTRIBUTE>,
ffi.Int,
ffi.Pointer<ffi.Void>,
ffi.Int,
)
>(symbol: 'bssl_dart_X509_ATTRIBUTE_set1_data')
external int X509_ATTRIBUTE_set1_data(
ffi.Pointer<X509_ATTRIBUTE> attr,
int attrtype,
ffi.Pointer<ffi.Void> data,
int len,
);