File asn1.h

Generic ASN.1 parsing.

ASN1 Error codes

These error codes are combined with other error codes for higher error granularity. e.g. X.509 and PKCS #7 error codes ASN1 is a standard to specify data structures.

DER constants

These constants comply with the DER encoded ASN.1 type tags. DER encoding uses hexadecimal representation. An example DER sequence is:

  • 0x02 — tag indicating INTEGER

  • 0x01 — length in octets

  • 0x05 — value

struct mbedtls_asn1_buf
#include <asn1.h>

Type-length-value structure that allows for ASN1 using DER.

Public Members

int tag

ASN1 type, e.g. MBEDTLS_ASN1_UTF8_STRING.

size_t len

ASN1 length, in octets.

unsigned char *p

ASN1 data, e.g. in ASCII.

struct mbedtls_asn1_bitstring
#include <asn1.h>

Container for ASN1 bit strings.

Public Members

size_t len

ASN1 length, in octets.

unsigned char unused_bits

Number of unused bits at the end of the string

unsigned char *p

Raw ASN1 data for the bit string

struct mbedtls_asn1_sequence
#include <asn1.h>

Container for a sequence of ASN.1 items

Public Members

mbedtls_asn1_buf buf

Buffer containing the given ASN.1 item.

struct mbedtls_asn1_sequence *next

The next entry in the sequence.

The details of memory management for sequences are not documented and may change in future versions. Set this field to NULL when initializing a structure, and do not modify it except via Mbed TLS library functions.

struct mbedtls_asn1_named_data
#include <asn1.h>

Container for a sequence or list of ‘named’ ASN.1 data items

Public Members

mbedtls_asn1_buf oid

The object identifier.

mbedtls_asn1_buf val

The named value.

struct mbedtls_asn1_named_data *next

The next entry in the sequence.

The details of memory management for named data sequences are not documented and may change in future versions. Set this field to NULL when initializing a structure, and do not modify it except via Mbed TLS library functions.

unsigned char private_next_merged

Merge next item into the current one?

This field exists for the sake of Mbed TLS’s X.509 certificate parsing code and may change in future versions of the library.