mbedtls_asn1_get_sequence_of() function
Parses and splits an ASN.1 "SEQUENCE OF ". Updates the pointer to immediately behind the full sequence tag. This function allocates memory for the sequence elements. You can free the allocated memory with mbedtls_asn1_sequence_free().
Arguments
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.
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.
tag
Each element of the sequence must have this tag.
Return value
0 if successful. #MBEDTLS_ERR_ASN1_LENGTH_MISMATCH if the input contains extra data after a valid SEQUENCE OF \p tag. #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. #MBEDTLS_ERR_ASN1_ALLOC_FAILED if a memory allocation failed. An ASN.1 error code if the input does not start with a valid ASN.1 SEQUENCE.
Notes
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. 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.
mbedtls_asn1_get_sequence_of() is called by 1 function and calls 1 function:
![]()
mbedtls_asn1_get_sequence_of()
mbedtls_asn1_get_sequence_of() reads 1 variable:
![]()
mbedtls_asn1_get_sequence_of()