asn1.c File Reference

Go to the source code of this file.

Functions

CONST uint8_tAsnHeaderParse (CONST uint8_t *data, size_t *datalength, uint8_t *type)
 Interpret the ID and length of the next object.
uint8_tAsnHeaderBuild (uint8_t *data, size_t *datalength, uint8_t type, size_t length)
 Build an ASN header for an object with a given ID and length.
CONST uint8_tAsnSequenceParse (CONST uint8_t *data, size_t *datalength, uint8_t type)
 Check the type and get the length of the next object.
uint8_tAsnSequenceBuild (uint8_t *data, size_t *datalength, uint8_t type, size_t length)
 Build an ASN header for a sequence with a given type and length.
CONST uint8_tAsnIntegerParse (CONST uint8_t *data, size_t *datalength, uint8_t *type, long *intp)
 Pull a long out of an ASN integer type.
uint8_tAsnIntegerBuild (uint8_t *data, size_t *datalength, uint8_t type, long *intp)
 Build an ASN object containing an integer.
CONST uint8_tAsnUnsignedParse (CONST uint8_t *data, size_t *datalength, uint8_t *type, uint32_t *intp)
 Pull an unsigned long out of an ASN integer type.
uint8_tAsnUnsignedBuild (uint8_t *data, size_t *datalength, uint8_t type, uint32_t *intp)
 Build an ASN object containing an unsigned integer.
CONST uint8_tAsnOctetStringParse (CONST uint8_t *data, size_t *datalength, uint8_t *type, uint8_t *string, size_t *strlength)
 Pulls a string out of an ASN octet string type.
uint8_tAsnOctetStringBuild (uint8_t *data, size_t *datalength, uint8_t type, CONST uint8_t *string, size_t strlength)
 Build an ASN object containing an octet string.
CONST uint8_tAsnOidParse (CONST uint8_t *data, size_t *datalength, uint8_t *type, OID *objid, size_t *objidlength)
 Pulls an object identifier out of an ASN object ID type.
uint8_tAsnOidBuild (uint8_t *data, size_t *datalength, uint8_t type, CONST OID *objid, size_t objidlength)
 Build an ASN object identifier.
CONST uint8_tAsnNullParse (CONST uint8_t *data, size_t *datalength, uint8_t *type)
 Parse an ASN null type.
uint8_tAsnNullBuild (uint8_t *data, size_t *datalength, uint8_t type)
 Build an ASN null object.
CONST uint8_tAsnBitStringParse (CONST uint8_t *data, size_t *datalength, uint8_t *type, uint8_t *string, size_t *strlength)
 Pull a bitstring out of an ASN bitstring type.
uint8_tAsnBitStringBuild (uint8_t *data, size_t *datalength, uint8_t type, CONST uint8_t *string, size_t strlength)
 Build an ASN bit string.
CONST uint8_tAsnUnsigned64Parse (CONST uint8_t *data, size_t *datalength, uint8_t *type, UNSIGNED64 *cp)
 Pull a 64 bit unsigned long out of an ASN integer type.
uint8_tAsnUnsigned64Build (uint8_t *data, size_t *datalength, uint8_t type, CONST UNSIGNED64 *cp)
 Build an ASN object containing a 64 bit unsigned integer.


Function Documentation

CONST uint8_t* AsnHeaderParse ( CONST uint8_t data,
size_t *  datalength,
uint8_t type 
)

Interpret the ID and length of the next object.

Parameters:
data Pointer to start of the object.
datalength Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the ID and length.
type Pointer to the variable that receives the ASN type of the object.
Returns:
A pointer to the first byte following ID and length (aka the start of the data field). Returns NULL on any error.

Definition at line 135 of file asn1.c.

References ASN_EXTENSION_ID, and CONST.

uint8_t* AsnHeaderBuild ( uint8_t data,
size_t *  datalength,
uint8_t  type,
size_t  length 
)

Build an ASN header for an object with a given ID and length.

This only works on data types < 30, i.e. no extension octets. The maximum length is 0xFFFF;

Parameters:
data Pointer to start of object.
datalength Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the encoded ID and length of this object.
type ASN type of the object.
length Length of object.
Returns:
Returns a pointer to the first byte of the contents of this object. Returns NULL on any error.

Definition at line 188 of file asn1.c.

CONST uint8_t* AsnSequenceParse ( CONST uint8_t data,
size_t *  datalength,
uint8_t  type 
)

Check the type and get the length of the next object.

Similare to AsnHeaderParse, but tests for expected type.

Parameters:
data Pointer to start of the object.
datalength Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the ID and length.
type The expected ASN type of the object.
Returns:
A pointer to the first byte following ID and length (aka the start of the data field). Returns NULL on any error.

Definition at line 214 of file asn1.c.

References AsnHeaderParse().

uint8_t* AsnSequenceBuild ( uint8_t data,
size_t *  datalength,
uint8_t  type,
size_t  length 
)

Build an ASN header for a sequence with a given type and length.

This only works on data types < 30, i.e. no extension octets. The maximum length is 0xFFFF;

Parameters:
data Pointer to start of object.
datalength Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the encoded ID and length of this object.
type ASN type of the object.
length Length of object.
Returns:
Returns a pointer to the first byte of the contents of this object. Returns NULL on any error.

Definition at line 243 of file asn1.c.

CONST uint8_t* AsnIntegerParse ( CONST uint8_t data,
size_t *  datalength,
uint8_t type,
long *  intp 
)

Pull a long out of an ASN integer type.

Parameters:
data Pointer to start of the object.
datalength Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the end of this object.
type Pointer to the variable that receives the ASN type of the object.
intp Pointer to the variable that receives the value of the object.
Returns:
Pointer to the first byte past the end of this object (i.e. the start of the next object). Returns NULL on any error.

Definition at line 276 of file asn1.c.

References CONST.

uint8_t* AsnIntegerBuild ( uint8_t data,
size_t *  datalength,
uint8_t  type,
long *  intp 
)

Build an ASN object containing an integer.

Parameters:
data Pointer to start of output buffer
datalength Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the end of this object.
type ASN type of the object.
intp Value of the object.
Returns:
A pointer to the first byte past the end of this object (i.e. the start of the next object). Returns NULL on any error.

Definition at line 322 of file asn1.c.

References AsnHeaderBuild().

CONST uint8_t* AsnUnsignedParse ( CONST uint8_t data,
size_t *  datalength,
uint8_t type,
uint32_t intp 
)

Pull an unsigned long out of an ASN integer type.

Parameters:
data Pointer to start of the object.
datalength Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the end of this object.
type Pointer to the variable that receives the ASN type of the object.
intp Pointer to the variable that receives the value of the object.
Returns:
Pointer to the first byte past the end of this object (i.e. the start of the next object). Returns NULL on any error.

Definition at line 374 of file asn1.c.

References CONST.

uint8_t* AsnUnsignedBuild ( uint8_t data,
size_t *  datalength,
uint8_t  type,
uint32_t intp 
)

Build an ASN object containing an unsigned integer.

Parameters:
data Pointer to start of output buffer
datalength Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the end of this object.
type ASN type of the object.
intp Value of the object.
Returns:
A pointer to the first byte past the end of this object (i.e. the start of the next object). Returns NULL on any error.

Definition at line 424 of file asn1.c.

References AsnHeaderBuild().

CONST uint8_t* AsnOctetStringParse ( CONST uint8_t data,
size_t *  datalength,
uint8_t type,
uint8_t string,
size_t *  strlength 
)

Pulls a string out of an ASN octet string type.

Parameters:
data Pointer to start of the object.
datalength Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the end of this object.
type Pointer to the variable that receives the ASN type of the object.
string Pointer to the variable that receives the value of the object.
strlength Contains the size of the string buffer on entry. On exit, it is returned as the number of bytes stored in the string buffer.
Returns:
Pointer to the first byte past the end of this object (i.e. the start of the next object). Returns NULL on any error.

Definition at line 490 of file asn1.c.

References CONST, and memcpy().

uint8_t* AsnOctetStringBuild ( uint8_t data,
size_t *  datalength,
uint8_t  type,
CONST uint8_t string,
size_t  strlength 
)

Build an ASN object containing an octet string.

Parameters:
data Pointer to start of output buffer
datalength Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the end of this object.
type ASN type of the object.
string Pointer to the value. If NULL, the octet string will be filled with zeros.
strlength Number of bytes in the string value.
Returns:
A pointer to the first byte past the end of this object (i.e. the start of the next object). Returns NULL on any error.

Definition at line 532 of file asn1.c.

References AsnHeaderBuild(), memcpy(), and memset().

CONST uint8_t* AsnOidParse ( CONST uint8_t data,
size_t *  datalength,
uint8_t type,
OID objid,
size_t *  objidlength 
)

Pulls an object identifier out of an ASN object ID type.

Parameters:
data Pointer to start of the object.
datalength Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the end of this object.
type Pointer to the variable that receives the ASN type of the object.
objid Pointer to the variable that receives the object identifier.
objidlength Points to a variable that contains the size of the output buffer on entry. On exit, it is returned as the number of sub IDs stored in the output buffer.
Returns:
Pointer to the first byte past the end of this object (i.e. the start of the next object). Returns NULL on any error.

Definition at line 573 of file asn1.c.

References ASN_BIT8, and CONST.

uint8_t* AsnOidBuild ( uint8_t data,
size_t *  datalength,
uint8_t  type,
CONST OID objid,
size_t  objidlength 
)

Build an ASN object identifier.

Parameters:
data Pointer to start of the object.
datalength Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the end of this object.
type ASN type of the object.
objid Pointer to the object identifier.
objidlength Number of sub IDs in the object identifier.
Returns:
Pointer to the first byte past the end of this object (i.e. the start of the next object). Returns NULL on any error.

Definition at line 649 of file asn1.c.

References AsnHeaderBuild(), CONST, free, malloc, and MAX_OID_LEN.

CONST uint8_t* AsnNullParse ( CONST uint8_t data,
size_t *  datalength,
uint8_t type 
)

Parse an ASN null type.

Parameters:
data Pointer to start of the object.
datalength Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the end of this object.
type Pointer to the variable that receives the ASN type of the object.
Returns:
Pointer to the first byte past the end of this object (i.e. the start of the next object). Returns NULL on any error.

Definition at line 774 of file asn1.c.

References CONST.

uint8_t* AsnNullBuild ( uint8_t data,
size_t *  datalength,
uint8_t  type 
)

Build an ASN null object.

Parameters:
data Pointer to start of the object.
datalength Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the end of this object.
type ASN type of the object.
Returns:
Pointer to the first byte past the end of this object (i.e. the start of the next object). Returns NULL on any error.

Definition at line 805 of file asn1.c.

References AsnHeaderBuild().

CONST uint8_t* AsnBitStringParse ( CONST uint8_t data,
size_t *  datalength,
uint8_t type,
uint8_t string,
size_t *  strlength 
)

Pull a bitstring out of an ASN bitstring type.

Parameters:
data Pointer to start of the object.
datalength Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the end of this object.
type Pointer to the variable that receives the ASN type of the object.
string Pointer to the variable that receives the value of the object.
strlength Contains the size of the string buffer on entry. On exit, it is returned as the number of bytes stored in the string buffer.
Returns:
Pointer to the first byte past the end of this object (i.e. the start of the next object). Returns NULL on any error.

Definition at line 830 of file asn1.c.

References CONST, and memcpy().

uint8_t* AsnBitStringBuild ( uint8_t data,
size_t *  datalength,
uint8_t  type,
CONST uint8_t string,
size_t  strlength 
)

Build an ASN bit string.

Parameters:
data Pointer to start of output buffer
datalength Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the end of this object.
type ASN type of the object.
string Pointer to the value. If NULL, the octet string will be filled with zeros.
strlength Number of bytes in the string value.
Returns:
A pointer to the first byte past the end of this object (i.e. the start of the next object). Returns NULL on any error.

Definition at line 872 of file asn1.c.

References AsnHeaderBuild(), and memcpy().

CONST uint8_t* AsnUnsigned64Parse ( CONST uint8_t data,
size_t *  datalength,
uint8_t type,
UNSIGNED64 cp 
)

Pull a 64 bit unsigned long out of an ASN integer type.

Parameters:
data Pointer to start of the object.
datalength Contains the number of valid bytes following the start of the object. On exit, it is returned as the number of valid bytes following the end of this object.
type Pointer to the variable that receives the ASN type of the object.
intp Pointer to the variable that receives the value of the object.
Returns:
Pointer to the first byte past the end of this object (i.e. the start of the next object). Returns NULL on any error.

Definition at line 905 of file asn1.c.

References CONST, UNSIGNED64::high, and UNSIGNED64::low.

uint8_t* AsnUnsigned64Build ( uint8_t data,
size_t *  datalength,
uint8_t  type,
CONST UNSIGNED64 cp 
)

Build an ASN object containing a 64 bit unsigned integer.

Parameters:
data Pointer to start of output buffer
datalength Contains the number of available bytes following the start of the object. On exit, it is returned as the number of available bytes following the end of this object.
type ASN type of the object.
intp Value of the object.
Returns:
A pointer to the first byte past the end of this object (i.e. the start of the next object). Returns NULL on any error.

Definition at line 952 of file asn1.c.

References AsnHeaderBuild().


© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/