28 #if defined(POLARSSL_ASN1_PARSE_C)
32 #if defined(POLARSSL_BIGNUM_C)
44 const unsigned char *end,
47 if( ( end - *p ) < 1 )
50 if( ( **p & 0x80 ) == 0 )
57 if( ( end - *p ) < 2 )
65 if( ( end - *p ) < 3 )
68 *len = ( (*p)[1] << 8 ) | (*p)[2];
73 if( ( end - *p ) < 4 )
76 *len = ( (*p)[1] << 16 ) | ( (*p)[2] << 8 ) | (*p)[3];
81 if( ( end - *p ) < 5 )
84 *len = ( (*p)[1] << 24 ) | ( (*p)[2] << 16 ) | ( (*p)[3] << 8 ) | (*p)[4];
93 if( *len > (
size_t) ( end - *p ) )
100 const unsigned char *end,
101 size_t *len,
int tag )
103 if( ( end - *p ) < 1 )
115 const unsigned char *end,
127 *val = ( **p != 0 ) ? 1 : 0;
134 const unsigned char *end,
143 if( len >
sizeof(
int ) || ( **p & 0x80 ) != 0 )
150 *val = ( *val << 8 ) | **p;
157 #if defined(POLARSSL_BIGNUM_C)
159 const unsigned char *end,
211 const unsigned char *end,
224 if( *p + len != end )
244 if( cur->
next == NULL )
int asn1_get_sequence_of(unsigned char **p, const unsigned char *end, asn1_sequence *cur, int tag)
Parses and splits an ASN.1 "SEQUENCE OF <tag>" Updated the pointer to immediately behind the full seq...
asn1_buf buf
Buffer containing the given ASN.1 item.
#define POLARSSL_ERR_ASN1_LENGTH_MISMATCH
Actual length differs from expected length.
int asn1_get_int(unsigned char **p, const unsigned char *end, int *val)
Retrieve an integer ASN.1 tag and its value.
size_t len
ASN1 length, e.g.
Configuration options (set of defines)
unsigned char unused_bits
Number of unused bits at the end of the string.
#define POLARSSL_ERR_ASN1_INVALID_LENGTH
Error when trying to determine the length or invalid length.
Container for ASN1 bit strings.
Multi-precision integer library.
Container for a sequence of ASN.1 items.
unsigned char * p
Raw ASN1 data for the bit string.
unsigned char * p
ASN1 data, e.g.
int asn1_get_bool(unsigned char **p, const unsigned char *end, int *val)
Retrieve a boolean ASN.1 tag and its value.
#define POLARSSL_ERR_ASN1_OUT_OF_DATA
Out of data when parsing an ASN1 data structure.
#define POLARSSL_ERR_ASN1_MALLOC_FAILED
Memory allocation failed.
int mpi_read_binary(mpi *X, const unsigned char *buf, size_t buflen)
Import X from unsigned binary data, big endian.
Type-length-value structure that allows for ASN1 using DER.
size_t len
ASN1 length, e.g.
int asn1_get_len(unsigned char **p, const unsigned char *end, size_t *len)
Get the length of an ASN.1 element.
int asn1_get_tag(unsigned char **p, const unsigned char *end, size_t *len, int tag)
Get the tag and length of the tag.
int asn1_get_bitstring(unsigned char **p, const unsigned char *end, asn1_bitstring *bs)
Retrieve a bitstring ASN.1 tag and its value.
int asn1_get_mpi(unsigned char **p, const unsigned char *end, mpi *X)
Retrieve a MPI value from an integer ASN.1 tag.
#define POLARSSL_ERR_ASN1_UNEXPECTED_TAG
ASN1 tag was of an unexpected value.
struct _asn1_sequence * next
The next entry in the sequence.