|
Yate
|
Class containing functions for decoding/encoding ASN.1 basic data types. More...
#include <yateasn.h>
Public Types | |
| 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 } |
| enum | Error { InvalidLengthOrTag = -1 , ConstraintBreakError = -2 , ParseError = -3 , InvalidContentsError = -4 , IndefiniteForm = -5 } |
Public Member Functions | |
| ASNLib () | |
| ~ASNLib () | |
Static Public Member Functions | |
| static int | decodeLength (DataBlock &data) |
| static int | decodeBoolean (DataBlock &data, bool *val, bool tagCheck) |
| static int | decodeInteger (DataBlock &data, u_int64_t &intVal, unsigned int bytes, bool tagCheck) |
| static int | decodeUINT8 (DataBlock &data, u_int8_t *intVal, bool tagCheck) |
| static int | decodeUINT16 (DataBlock &data, u_int16_t *intVal, bool tagCheck) |
| static int | decodeUINT32 (DataBlock &data, u_int32_t *intVal, bool tagCheck) |
| static int | decodeUINT64 (DataBlock &data, u_int64_t *intVal, bool tagCheck) |
| static int | decodeINT8 (DataBlock &data, int8_t *intVal, bool tagCheck) |
| static int | decodeINT16 (DataBlock &data, int16_t *intVal, bool tagCheck) |
| static int | decodeINT32 (DataBlock &data, int32_t *intVal, bool tagCheck) |
| static int | decodeINT64 (DataBlock &data, int64_t *intVal, bool tagCheck) |
| static int | decodeBitString (DataBlock &data, String *val, bool tagCheck) |
| static int | decodeOctetString (DataBlock &data, OctetString *strVal, bool tagCheck) |
| static int | decodeNull (DataBlock &data, bool tagCheck) |
| static int | decodeOID (DataBlock &data, ASNObjId *obj, bool tagCheck) |
| static int | decodeReal (DataBlock &data, float *realVal, bool tagCheck) |
| static int | decodeString (DataBlock &data, String *str, int *type, bool tagCheck) |
| static int | decodeUtf8 (DataBlock &data, String *str, bool tagCheck) |
| static int | decodeGenTime (DataBlock &data, unsigned int *time, unsigned int *fractions, bool *utc, bool tagCheck) |
| static int | decodeUTCTime (DataBlock &data, unsigned int *time, bool tagCheck) |
| static int | decodeAny (DataBlock data, DataBlock *val, bool tagCheck) |
| static int | decodeSequence (DataBlock &data, bool tagCheck) |
| static int | decodeSet (DataBlock &data, bool tagCheck) |
| static DataBlock | buildLength (DataBlock &data) |
| static DataBlock | encodeBoolean (bool val, bool tagCheck) |
| static DataBlock | encodeInteger (u_int64_t intVal, bool tagCheck) |
| static DataBlock | encodeOctetString (OctetString strVal, bool tagCheck) |
| static DataBlock | encodeNull (bool tagCheck) |
| static DataBlock | encodeBitString (String val, bool tagCheck) |
| static DataBlock | encodeOID (ASNObjId obj, bool tagCheck) |
| static DataBlock | encodeReal (float val, bool tagCheck) |
| static DataBlock | encodeString (String str, int type, bool tagCheck) |
| static DataBlock | encodeUtf8 (String str, bool tagCheck) |
| static DataBlock | encodeGenTime (unsigned int time, unsigned int fractions, bool tagCheck) |
| static DataBlock | encodeUTCTime (unsigned int time, bool tagCheck) |
| static DataBlock | encodeAny (DataBlock data, bool tagCheck) |
| static int | encodeSequence (DataBlock &data, bool tagCheck) |
| static int | encodeSet (DataBlock &data, bool tagCheck) |
| static int | matchEOC (DataBlock &data) |
| static int | parseUntilEoC (DataBlock &data, int length=0) |
Class containing functions for decoding/encoding ASN.1 basic data types.
Class ASNLib
| enum TypeTag |
ASN.1 Type tags
| ASNLib | ( | ) |
Constructor
| ~ASNLib | ( | ) |
Destructor
Encode the length of the given data
| data | The data for which the length should be encoded |
Decode a block of arbitrary data
| data | Input block from which the value should be extracted |
| val | DataBlock in which the data shoulb be copied |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 should be verified |
Decode a bitstring value from the encoded data
| data | Input block from which the bitstring value should be extracted |
| val | String to be filled with the decoded value |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x03) should be verified |
|
static |
Decode a boolean value from the encoded data
| data | Input block from which the boolean value should be extracted |
| val | Pointer to a boolean to be filled with the decoded value |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for boolean (0x01) should be verified |
|
static |
Decode a GeneralizedTime value from the encoded data
| data | Input block from which the value should be extracted |
| time | Integer to be filled with time in seconds since epoch |
| fractions | Integer to be filled with fractions of a second |
| utc | Flag indicating if the decode time value represent local time or UTC time |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag (0x18) should be verified |
|
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
| data | Input block from which the integer value should be extracted |
| intVal | Integer to be filled with the decoded value |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified |
|
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
| data | Input block from which the integer value should be extracted |
| intVal | Integer to be filled with the decoded value |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified |
|
static |
Decode an integer value from the encoded data - helper function for casting in case of size constraints
| data | Input block from which the integer value should be extracted |
| intVal | Integer to be filled with the decoded value |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified |
|
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
| data | Input block from which the integer value should be extracted |
| intVal | Integer to be filled with the decoded value |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified |
|
static |
Decode an integer value from the encoded data
| data | Input block from which the integer value should be extracted |
| intVal | Integer to be filled with the decoded value |
| bytes | Width of the decoded integer field |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified |
|
static |
Decode the length of the block data containing the ASN.1 type data
| data | Input block from which to extract the length |
|
static |
Decode a null value from the encoded data
| data | Input block from which the null value should be extracted |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x05) should be verified |
|
static |
Decode a string value from the encoded data
| data | Input block from which the octet string value should be extracted |
| strVal | String to be filled with the decoded value |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x04) should be verified |
Decode an object id value from the encoded data
| data | Input block from which the OID value should be extracted |
| obj | ASNObjId to be filled with the decoded value |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x06) should be verified |
|
static |
Decode a real value from the encoded data - not implemented
| data | Input block from which the real value should be extracted |
| realVal | Float to be filled with the decoded value |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x09) should be verified |
|
static |
Decode the header of an ASN.1 sequence ( decodes the tag and the length of the sequence)
| data | Input block from which the header should be extracted |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 (0x30) should be verified |
|
static |
Decode the header of an ASN.1 set ( decodes the tag and the length of the sequence)
| data | Input block from which the header should be extracted |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 (0x31) should be verified |
Decode other types of ASN.1 strings from the encoded data (NumericString, PrintableString, VisibleString, IA5String)
| data | Input block from which the string value should be extracted |
| str | String to be filled with the decoded value |
| type | Integer to be filled with the value indicating which type of string has been decoded |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag should be verified |
|
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
| data | Input block from which the integer value should be extracted |
| intVal | Integer to be filled with the decoded value |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified |
|
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
| data | Input block from which the integer value should be extracted |
| intVal | Integer to be filled with the decoded value |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified |
|
static |
Decode an unsigned integer value from the encoded data - helper function for casting in case of size constraints
| data | Input block from which the integer value should be extracted |
| intVal | Integer to be filled with the decoded value |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified |
|
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
| data | Input block from which the integer value should be extracted |
| intVal | Integer to be filled with the decoded value |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified |
|
static |
Decode a UTC time value from the encoded data
| data | Input block from which the value should be extracted |
| time | Integer to be filled with time in seconds since epoch |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag (0x17) should be verified |
Decode an UTF8 string from the encoded data
| data | Input block from which the string value should be extracted |
| str | String to be filled with the decoded value |
| tagCheck | Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag (0x0c) should be verified |
Encode an arbitrary block a data
| data | data |
| tagCheck | Flag to specify if the type tag should be inserted in the encoding |
Encode the given bitstring value
| val | The bitstring value to encode |
| tagCheck | Flag to specify if the type tag should be inserted in the encoding |
|
static |
Encode the given boolean value
| val | The boolean value to encode |
| tagCheck | Flag to specify if the boolean type tag should be inserted in the encoding |
|
static |
Encode the given time value into a GeneralizedTime format
| time | Time in seconds since epoch to encode |
| fractions | Fractions of a seconds to encode |
| tagCheck | Flag to specify if the type tag should be inserted in the encoding |
|
static |
Encode the given integer value
| intVal | The integer value to encode |
| tagCheck | Flag to specify if the integer type tag should be inserted in the encoding |
|
static |
Encode a null value
| tagCheck | Flag to specify if the null tag should be inserted in the encoding |
|
static |
Encode the given octet string value
| strVal | The octet string value to encode |
| tagCheck | Flag to specify if the octet string type tag should be inserted in the encoding |
Encode the given OID value
| obj | The OID value to encode |
| tagCheck | Flag to specify if the type tag should be inserted in the encoding |
|
static |
Encode the given real value - not implemented
| val | The real value to encode |
| tagCheck | Flag to specify if the type tag should be inserted in the encoding |
|
static |
Encode the header for a sequence
| data | Sequence data for which the header is encoded |
| tagCheck | Flag to specify if the ype tag should be inserted in the encoding |
|
static |
Encode the header for a set
| data | Sequence data for which the header is encoded |
| tagCheck | Flag to specify if the type tag should be inserted in the encoding |
Encode the given string value to NumericString, PrintableString, IA5String, VisibleString
| str | The string value to encode |
| type | The type of the encoding |
| tagCheck | Flag to specify if the type tag should be inserted in the encoding |
|
static |
Encode the given time value into an UTCTime format
| time | Time in seconds since epoch to encode |
| tagCheck | Flag to specify if the type tag should be inserted in the encoding |
Encode the UTF8 string value
| str | The string value to encode |
| tagCheck | Flag to specify if the type tag should be inserted in the encoding |
|
static |
Verify the data for End Of Contents presence
| data | Input block to verify |
|
static |
Extract length until a End Of Contents is found.
| data | Input block for which to determine the length to End Of Contents |
| length | Length to which to add determined length |