The class supports ASN.1 decoding and encoding of length field. The length of ASN.1 data does not include the type identifier and the length field itself.
Encoding rules:
Three different forms exist for encoding of the length. Their usage depends on the actual value of the lenth:
o The short form is used for values less than 128. In this form the first byte is the value of the length.
o The long form is used for values greater or equal than 128. In this form the seven least significant bits of the first byte tell the number of subsequent bytes to provide the data length.
o The indefinite form has a value of 0x80. It can be used for constructed types only. The end of the type's data is indicated by the universal tag 0 and a length of 0, i.e. two bytes of 0.
Definition at line 224 of file asn1.h.
OSB_LIB::Asn1Len::Asn1Len | ( | size_t | len = 0 |
) | [inline, explicit] |
void OSB_LIB::Asn1Len::encode | ( | Asn1Data & | dest | ) | const |
Encode tag to binary data.
dest | Buffer to populate. |
size_t OSB_LIB::Asn1Len::get | ( | const Asn1Byte * | data, | |
size_t | dataSize | |||
) |
Get encoded ASN.1 data length from binary data.
data | Array with binary data. | |
dataSize | Size of binary data. |
bool OSB_LIB::Asn1Len::isInfinite | ( | ) | const [inline] |
Infinite length?
Definition at line 364 of file asn1.h.
References infinite, and len_.
Referenced by operator size_t().
OSB_LIB::Asn1Len::operator size_t | ( | ) | const [inline] |
const Asn1Len & OSB_LIB::Asn1Len::operator= | ( | size_t | len | ) | [inline] |
Asn1Byte OSB_LIB::Asn1Len::operator[] | ( | size_t | i | ) | const |
Return encoded byte at position i.
size_t OSB_LIB::Asn1Len::read | ( | FILE * | in | ) |
Read ASN.1 encoded length from a input file.
If a read error on the input file occurs, the length is set to 0.
in | Input file to read from. |
void OSB_LIB::Asn1Len::setInfinite | ( | ) | [inline] |
size_t OSB_LIB::Asn1Len::size | ( | ) | const |
Number of bytes needed for encoding.
std::string OSB_LIB::Asn1Len::str | ( | ) | const |
Human readable output of an ASN.1 length.
const size_t OSB_LIB::Asn1Len::infinite = static_cast<size_t>(-1) [static] |
Value for infinite length.
Definition at line 227 of file asn1.h.
Referenced by isInfinite(), and setInfinite().
size_t OSB_LIB::Asn1Len::len_ [private] |
Value of length.
Definition at line 290 of file asn1.h.
Referenced by isInfinite(), operator size_t(), operator=(), and setInfinite().