class ASNLib

Class containing functions for decoding/encoding ASN.1 basic data types. More...

Full nameTelEngine::ASNLib
Definition#include <libs/yasn/yateasn.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Public Static Methods


Detailed Description

Class ASNLib

enum TypeTag { UNIVERSAL = 0x00, BOOLEAN = 0x01, INTEGER = 0x02, BIT_STRING = 0x03, OCTET_STRING = 0x04, NULL_ID = 0x05, OBJECT_ID = 0x06, REAL = 0x09, UTF8_STR = 0x0c, SEQUENCE = 0x30, SET = 0x31, NUMERIC_STR = 0x12, PRINTABLE_STR = 0x13, IA5_STR = 0x16, UTC_TIME = 0x17, GENERALIZED_TIME = 0x18, VISIBLE_STR = 0x1a, GENERAL_STR = 0x1b, UNIVERSAL_STR = 0x1c, CHARACTER_STR = 0x1d, BMP_STR = 0x1e, CHOICE = 0x1f, DEFINED = 0x2d }

TypeTag

ASN.1 Type tags

enum Error { InvalidLengthOrTag = -1, ConstraintBreakError = -2, ParseError, InvalidContentsError }

Error

Error types

 ASNLib ()

ASNLib

Constructor

 ~ASNLib ()

~ASNLib

Destructor

int  decodeLength (DataBlock& data)

decodeLength

[static]

Decode the length of the block data containing the ASN.1 type data

Parameters:
dataInput block from which to extract the length

Returns: The length of the data block containing data, -1 if it couldn't be decoded

int  decodeBoolean (DataBlock& data, bool* val, bool tagCheck)

decodeBoolean

[static]

Decode a boolean value from the encoded data

Parameters:
dataInput block from which the boolean value should be extracted
valPointer to a boolean to be filled with the decoded value
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for boolean (0x01) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the boolean value could not be decoded

int  decodeInteger (DataBlock& data, u_int64_t& intVal, unsigned int bytes, bool tagCheck)

decodeInteger

[static]

Decode an integer value from the encoded data

Parameters:
dataInput block from which the integer value should be extracted
intValInteger to be filled with the decoded value
bytesWidth of the decoded integer field
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeUINT8 (DataBlock& data, u_int8_t* intVal, bool tagCheck)

decodeUINT8

[static]

Decode an unsigned integer value from the encoded data - helper function for casting from u_int64_t to u_int8_t in case of size constraints

Parameters:
dataInput block from which the integer value should be extracted
intValInteger to be filled with the decoded value
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeUINT16 (DataBlock& data, u_int16_t* intVal, bool tagCheck)

decodeUINT16

[static]

Decode an unsigned integer value from the encoded data - helper function for casting from u_int64_t to u_int16_t in case of size constraints

Parameters:
dataInput block from which the integer value should be extracted
intValInteger to be filled with the decoded value
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeUINT32 (DataBlock& data, u_int32_t* intVal, bool tagCheck)

decodeUINT32

[static]

Decode an unsigned integer value from the encoded data - helper function for casting from u_int64_t to u_int32_t in case of size constraints

Parameters:
dataInput block from which the integer value should be extracted
intValInteger to be filled with the decoded value
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeUINT64 (DataBlock& data, u_int64_t* intVal, bool tagCheck)

decodeUINT64

[static]

Decode an unsigned integer value from the encoded data - helper function for casting in case of size constraints

Parameters:
dataInput block from which the integer value should be extracted
intValInteger to be filled with the decoded value
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeINT8 (DataBlock& data, int8_t* intVal, bool tagCheck)

decodeINT8

[static]

Decode an integer value from the encoded data - helper function for casting from u_int64_t to int8_t in case of size constraints

Parameters:
dataInput block from which the integer value should be extracted
intValInteger to be filled with the decoded value
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeINT16 (DataBlock& data, int16_t* intVal, bool tagCheck)

decodeINT16

[static]

Decode an integer value from the encoded data - helper function for casting from u_int64_t to int16_t in case of size constraints

Parameters:
dataInput block from which the integer value should be extracted
intValInteger to be filled with the decoded value
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeINT32 (DataBlock& data, int32_t* intVal, bool tagCheck)

decodeINT32

[static]

Decode an integer value from the encoded data - helper function for casting from u_int64_t to int32_t in case of size constraints

Parameters:
dataInput block from which the integer value should be extracted
intValInteger to be filled with the decoded value
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeINT64 (DataBlock& data, int64_t* intVal, bool tagCheck)

decodeINT64

[static]

Decode an integer value from the encoded data - helper function for casting in case of size constraints

Parameters:
dataInput block from which the integer value should be extracted
intValInteger to be filled with the decoded value
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeBitString (DataBlock& data, String* val, bool tagCheck)

decodeBitString

[static]

Decode a bitstring value from the encoded data

Parameters:
dataInput block from which the bitstring value should be extracted
valString to be filled with the decoded value
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x03) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeOctetString (DataBlock& data, OctetString* strVal, bool tagCheck)

decodeOctetString

[static]

Decode a string value from the encoded data

Parameters:
dataInput block from which the octet string value should be extracted
strValString to be filled with the decoded value
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x04) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeNull (DataBlock& data, bool tagCheck)

decodeNull

[static]

Decode a null value from the encoded data

Parameters:
dataInput block from which the null value should be extracted
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x05) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeOID (DataBlock& data, ASNObjId* obj, bool tagCheck)

decodeOID

[static]

Decode an object id value from the encoded data

Parameters:
dataInput block from which the OID value should be extracted
objASNObjId to be filled with the decoded value
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x06) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeReal (DataBlock& data, float* realVal, bool tagCheck)

decodeReal

[static]

Decode a real value from the encoded data - not implemented

Parameters:
dataInput block from which the real value should be extracted
realValFloat to be filled with the decoded value
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x09) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeString (DataBlock& data, String* str, int* type, bool tagCheck)

decodeString

[static]

Decode other types of ASN.1 strings from the encoded data (NumericString, PrintableString, VisibleString, IA5String)

Parameters:
dataInput block from which the string value should be extracted
strString to be filled with the decoded value
typeInteger to be filled with the value indicating which type of string has been decoded
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeUtf8 (DataBlock& data, String* str, bool tagCheck)

decodeUtf8

[static]

Decode an UTF8 string from the encoded data

Parameters:
dataInput block from which the string value should be extracted
strString to be filled with the decoded value
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag (0x0c) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeGenTime (DataBlock& data, unsigned int* time, unsigned int* fractions, bool* utc, bool tagCheck)

decodeGenTime

[static]

Decode a GeneralizedTime value from the encoded data

Parameters:
dataInput block from which the value should be extracted
timeInteger to be filled with time in seconds since epoch
fractionsInteger to be filled with fractions of a second
utcFlag indicating if the decode time value represent local time or UTC time
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag (0x18) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeUTCTime (DataBlock& data, unsigned int* time, bool tagCheck)

decodeUTCTime

[static]

Decode a UTC time value from the encoded data

Parameters:
dataInput block from which the value should be extracted
timeInteger to be filled with time in seconds since epoch
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 tag (0x17) should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeAny (DataBlock data, DataBlock* val, bool tagCheck)

decodeAny

[static]

Decode a block of arbitrary data

Parameters:
dataInput block from which the value should be extracted
valDataBlock in which the data shoulb be copied
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 should be verified

Returns: Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded

int  decodeSequence (DataBlock& data, bool tagCheck)

decodeSequence

[static]

Decode the header of an ASN.1 sequence ( decodes the tag and the length of the sequence)

Parameters:
dataInput block from which the header should be extracted
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 (0x30) should be verified

Returns: Length of data consumed from the input data it the decoding was succesful, -1 if the integer value could not be decoded

int  decodeSet (DataBlock& data, bool tagCheck)

decodeSet

[static]

Decode the header of an ASN.1 set ( decodes the tag and the length of the sequence)

Parameters:
dataInput block from which the header should be extracted
tagCheckFlag for indicating if in the process of decoding the value the presence of the ASN.1 (0x31) should be verified

Returns: Length of data consumed from the input data it the decoding was succesful, -1 if the integer value could not be decoded

DataBlock  buildLength (DataBlock& data)

buildLength

[static]

Encode the length of the given data

Parameters:
dataThe data for which the length should be encoded

Returns: The data block which now contains the length encoding

DataBlock  encodeBoolean (bool val, bool tagCheck)

encodeBoolean

[static]

Encode the given boolean value

Parameters:
valThe boolean value to encode
tagCheckFlag to specify if the boolean type tag should be inserted in the encoding

Returns: The data block encoding of the value

DataBlock  encodeInteger (u_int64_t intVal, bool tagCheck)

encodeInteger

[static]

Encode the given integer value

Parameters:
intValThe integer value to encode
tagCheckFlag to specify if the integer type tag should be inserted in the encoding

Returns: The data block encoding of the value

DataBlock  encodeOctetString (OctetString strVal, bool tagCheck)

encodeOctetString

[static]

Encode the given octet string value

Parameters:
strValThe octet string value to encode
tagCheckFlag to specify if the octet string type tag should be inserted in the encoding

Returns: The data block encoding of the value

DataBlock  encodeNull (bool tagCheck)

encodeNull

[static]

Encode a null value

Parameters:
tagCheckFlag to specify if the null tag should be inserted in the encoding

Returns: The data block encoding of the value

DataBlock  encodeBitString (String val, bool tagCheck)

encodeBitString

[static]

Encode the given bitstring value

Parameters:
valThe bitstring value to encode
tagCheckFlag to specify if the type tag should be inserted in the encoding

Returns: The data block encoding of the value

DataBlock  encodeOID (ASNObjId obj, bool tagCheck)

encodeOID

[static]

Encode the given OID value

Parameters:
objThe OID value to encode
tagCheckFlag to specify if the type tag should be inserted in the encoding

Returns: The data block encoding of the value

DataBlock  encodeReal (float val, bool tagCheck)

encodeReal

[static]

Encode the given real value - not implemented

Parameters:
valThe real value to encode
tagCheckFlag to specify if the type tag should be inserted in the encoding

Returns: The data block encoding of the value

DataBlock  encodeString (String str, int type, bool tagCheck)

encodeString

[static]

Encode the given string value to NumericString, PrintableString, IA5String, VisibleString

Parameters:
strThe string value to encode
typeThe type of the encoding
tagCheckFlag to specify if the type tag should be inserted in the encoding

Returns: The data block encoding of the value

DataBlock  encodeUtf8 (String str, bool tagCheck)

encodeUtf8

[static]

Encode the UTF8 string value

Parameters:
strThe string value to encode
tagCheckFlag to specify if the type tag should be inserted in the encoding

Returns: The data block encoding of the value

DataBlock  encodeGenTime (unsigned int time, unsigned int fractions, bool tagCheck)

encodeGenTime

[static]

Encode the given time value into a GeneralizedTime format

Parameters:
timeTime in seconds since epoch to encode
fractionsFractions of a seconds to encode
tagCheckFlag to specify if the type tag should be inserted in the encoding

Returns: The data block encoding of the value

DataBlock  encodeUTCTime (unsigned int time, bool tagCheck)

encodeUTCTime

[static]

Encode the given time value into an UTCTime format

Parameters:
timeTime in seconds since epoch to encode
tagCheckFlag to specify if the type tag should be inserted in the encoding

Returns: The data block encoding of the value

DataBlock  encodeAny (DataBlock data, bool tagCheck)

encodeAny

[static]

Encode an arbitrary block a data

Parameters:
datadata
tagCheckFlag to specify if the type tag should be inserted in the encoding

Returns: The data block encoding of the value

int  encodeSequence (DataBlock& data, bool tagCheck)

encodeSequence

[static]

Encode the header for a sequence

Parameters:
dataSequence data for which the header is encoded
tagCheckFlag to specify if the ype tag should be inserted in the encoding

Returns: The length of the data block length encoding

int  encodeSet (DataBlock& data, bool tagCheck)

encodeSet

[static]

Encode the header for a set

Parameters:
dataSequence data for which the header is encoded
tagCheckFlag to specify if the type tag should be inserted in the encoding

Returns: The length of the data block length encoding


Generated by: paulc on bussard on Tue Apr 12 17:15:21 2011, using kdoc 2.0a54.