Function esp_idf_svc::hal::sys::mbedtls_asn1_get_sequence_of
source · pub unsafe extern "C" fn mbedtls_asn1_get_sequence_of(
p: *mut *mut u8,
end: *const u8,
cur: *mut mbedtls_asn1_sequence,
tag: i32,
) -> i32
Expand description
\brief Parses and splits an ASN.1 “SEQUENCE OF
This function allocates memory for the sequence elements. You can free the allocated memory with mbedtls_asn1_sequence_free().
\note On error, this function may return a partial list in \p cur.
You must set cur->next = NULL
before calling this function!
Otherwise it is impossible to distinguish a previously non-null
pointer from a pointer to an object allocated by this function.
\note If the sequence is empty, this function does not modify
\c *cur. If the sequence is valid and non-empty, this
function sets cur->buf.tag
to \p tag. This allows
callers to distinguish between an empty sequence and
a one-element sequence.
\param p On entry, \c *p points to the start of the ASN.1 element.
On successful completion, \c *p is equal to \p end.
On error, the value of \c *p is undefined.
\param end End of data.
\param cur A ::mbedtls_asn1_sequence which this function fills.
When this function returns, \c *cur is the head of a linked
list. Each node in this list is allocated with
mbedtls_calloc() apart from \p cur itself, and should
therefore be freed with mbedtls_free().
The list describes the content of the sequence.
The head of the list (i.e. \c *cur itself) describes the
first element, *cur->next
describes the second element, etc.
For each element, buf.tag == tag
, buf.len
is the length
of the content of the content of the element, and buf.p
points to the first byte of the content (i.e. immediately
past the length of the element).
Note that list elements may be allocated even on error.
\param tag Each element of the sequence must have this tag.
\return 0 if successful. \return #MBEDTLS_ERR_ASN1_LENGTH_MISMATCH if the input contains extra data after a valid SEQUENCE OF \p tag. \return #MBEDTLS_ERR_ASN1_UNEXPECTED_TAG if the input starts with an ASN.1 SEQUENCE in which an element has a tag that is different from \p tag. \return #MBEDTLS_ERR_ASN1_ALLOC_FAILED if a memory allocation failed. \return An ASN.1 error code if the input does not start with a valid ASN.1 SEQUENCE.