ASN.1 uses tags to identify the type of encoded data. The class supports encoding, decoding and I/O of ASN.1 tags.
Encoding of tags:
+ Bits 8 and 7 of the frist byte contain the type class,
o universal: 00
o application: 01
o context: 10
o private: 11
+ Bit 6 of the first byte indicates if the type is primitive (0) or constructed (1).
+ Tag numbers less than 31 are coded in bits 5 to 1 of the tag's first byte.
+ For tag numbers greater or equal than 31 bits 5 to 1 of the tag's first byte are set to 11111. The actual number is stored in the subsequent bytes. These bytes contain the tag number in the 7 less significant bits and have bit 8 is set to 1 if more bytes with the tag number follow and bit 8 set to 0 for the final tag number byte. Examples:
o The value for the private tag 11, constructed type is 11101011 (binary) or 0xeb (hexadecimal).
o The application tag 195, primitive type is hexadecimal 0x5f8143.
Definition at line 90 of file asn1.h.
OSB_LIB::Asn1Tag::Asn1Tag | ( | size_t | val = tagNotSet |
) | [explicit] |
Constructor with encoded tag value.
val | Value of the encoded tag, incl. class and primitive/constructed. |
OSB_LIB::Asn1Tag::Asn1Tag | ( | TypeClass | typeClass, | |
size_t | tagNum, | |||
bool | constructed | |||
) |
Constructor with type class, tag value and flag if the type is constructed.
typeClass | The type class. | |
tagNum | The tag number. | |
constructed | Flag if type is constructed. |
void OSB_LIB::Asn1Tag::encode | ( | Asn1Data & | dest | ) | const |
Encode tag to binary data.
dest | Buffer to populate. |
size_t OSB_LIB::Asn1Tag::get | ( | const Asn1Byte * | data, | |
size_t | dataSize | |||
) |
Get encoded ASN.1 tag from binary data.
data | Array with binary data. | |
dataSize | Size of binary data. |
bool OSB_LIB::Asn1Tag::isConstructed | ( | ) | const [inline] |
bool OSB_LIB::Asn1Tag::isSet | ( | ) | const [inline] |
void OSB_LIB::Asn1Tag::mkSize | ( | ) | [inline, private] |
Compute size_.
bool OSB_LIB::Asn1Tag::operator!= | ( | const Asn1Tag & | rhs | ) | const [inline] |
bool OSB_LIB::Asn1Tag::operator< | ( | const Asn1Tag & | rhs | ) | const [inline] |
bool OSB_LIB::Asn1Tag::operator== | ( | const Asn1Tag & | rhs | ) | const [inline] |
Asn1Byte OSB_LIB::Asn1Tag::operator[] | ( | size_t | i | ) | const |
Return encoded byte at position i.
size_t OSB_LIB::Asn1Tag::read | ( | FILE * | in | ) |
Read encoded ASN.1 tag from an input file.
If a read error on the input file occurs, the tag value is not set.
in | Input file to read from. |
size_t OSB_LIB::Asn1Tag::size | ( | ) | const [inline] |
std::string OSB_LIB::Asn1Tag::str | ( | ) | const |
Human readable output of an ASN.1 tag in hex format.
The returned string is empty if the tag is not set.
size_t OSB_LIB::Asn1Tag::tagNumber | ( | ) | const |
Tag number (excl. type class and composed flag).
Asn1Tag::TypeClass OSB_LIB::Asn1Tag::typeClass | ( | ) | const [inline] |
size_t OSB_LIB::Asn1Tag::value | ( | ) | const [inline] |
Tag value (incl. type class and composed flag).
Definition at line 299 of file asn1.h.
References value_.
Referenced by OSB_LIB::Asn1Info::tagValue().
size_t OSB_LIB::Asn1Tag::size_ [private] |
const size_t OSB_LIB::Asn1Tag::tagNotSet = size_t(-1) [static] |
size_t OSB_LIB::Asn1Tag::value_ [private] |
Tag value incl. type class and composed flag.
Definition at line 195 of file asn1.h.
Referenced by isSet(), operator!=(), operator<(), operator==(), and value().