BER/DER C Decode Functions.
[BER Runtime Library Functions.]
Detailed Description
BER/DER C decode functions handle the decoding of the primitive ASN.1 data types and ASN.1 length and tag fields within a message. Calls to these functions are assembled in the C source code generated by the ASN1C compiler to decode complex ASN.1 structures. These functions are also directly callable from within a user's application program if the need to decode a primitive data item exists.The procedure to decode a primitive data item is as follows:
- Call the xd_setp low-level decode function to specify the address of the buffer containing the encoded ASN.1 data to be decoded.
- Call the specific decode function to decode the value. The tag value obtained in the first step can be used to determine which decode function to call for decoding the variable.
Defines | |
| #define | xd_utf8str(pctxt, object_p, tagging, length) xd_charstr (pctxt, (const char**)object_p, tagging, ASN_ID_UTF8String, length) |
| #define | xd_indeflen(m) xd_indeflen_ex(m, INT_MAX) |
Functions | |
| int | xd_tag (OSCTXT *pctxt, ASN1TAG *tag_p) |
| int | xd_tag_len (OSCTXT *pctxt, ASN1TAG *tag_p, int *len_p, OSOCTET flags) |
| int | xd_match (OSCTXT *pctxt, ASN1TAG tag, int *len_p, OSOCTET flags) |
| int | xd_boolean (OSCTXT *pctxt, OSBOOL *object_p, ASN1TagType tagging, int length) |
| int | xd_integer (OSCTXT *pctxt, OSINT32 *object_p, ASN1TagType tagging, int length) |
| int | xd_int8 (OSCTXT *pctxt, OSINT8 *object_p, ASN1TagType tagging, int length) |
| int | xd_int16 (OSCTXT *pctxt, OSINT16 *object_p, ASN1TagType tagging, int length) |
| int | xd_unsigned (OSCTXT *pctxt, OSUINT32 *object_p, ASN1TagType tagging, int length) |
| int | xd_uint8 (OSCTXT *pctxt, OSUINT8 *object_p, ASN1TagType tagging, int length) |
| int | xd_uint16 (OSCTXT *pctxt, OSUINT16 *object_p, ASN1TagType tagging, int length) |
| int | xd_int64 (OSCTXT *pctxt, OSINT64 *object_p, ASN1TagType tagging, int length) |
| int | xd_uint64 (OSCTXT *pctxt, OSUINT64 *object_p, ASN1TagType tagging, int length) |
| int | xd_bigint (OSCTXT *pctxt, const char **object_p, ASN1TagType tagging, int length) |
| int | xd_bitstr_s (OSCTXT *pctxt, OSOCTET *object_p, OSUINT32 *numbits_p, ASN1TagType tagging, int length) |
| int | xd_bitstr (OSCTXT *pctxt, const OSOCTET **object_p2, OSUINT32 *numbits_p, ASN1TagType tagging, int length) |
| int | xd_octstr_s (OSCTXT *pctxt, OSOCTET *object_p, OSUINT32 *pnumocts, ASN1TagType tagging, int length) |
| int | xd_octstr (OSCTXT *pctxt, const OSOCTET **object_p2, OSUINT32 *pnumocts, ASN1TagType tagging, int length) |
| int | xd_charstr (OSCTXT *pctxt, const char **object_p, ASN1TagType tagging, ASN1TAG tag, int length) |
| int | xd_16BitCharStr (OSCTXT *pctxt, Asn116BitCharString *object_p, ASN1TagType tagging, ASN1TAG tag, int length) |
| int | xd_32BitCharStr (OSCTXT *pctxt, Asn132BitCharString *object_p, ASN1TagType tagging, ASN1TAG tag, int length) |
| int | xd_null (OSCTXT *pctxt, ASN1TagType tagging) |
| int | xd_objid (OSCTXT *pctxt, ASN1OBJID *object_p, ASN1TagType tagging, int length) |
| int | xd_oid64 (OSCTXT *pctxt, ASN1OID64 *object_p, ASN1TagType tagging, int length) |
| int | xd_reloid (OSCTXT *pctxt, ASN1OBJID *object_p, ASN1TagType tagging, int length) |
| int | xd_real (OSCTXT *pctxt, OSREAL *object_p, ASN1TagType tagging, int length) |
| int | xd_enum (OSCTXT *pctxt, OSINT32 *object_p, ASN1TagType tagging, int length) |
| int | xd_OpenType (OSCTXT *pctxt, const OSOCTET **object_p2, OSUINT32 *pnumocts) |
| int | xd_OpenTypeExt (OSCTXT *pctxt, ASN1CCB *ccb_p, ASN1TAG tag, OSRTDList *pElemList) |
| int | xd_OpenTypeAppend (OSCTXT *pctxt, OSRTDList *pElemList) |
| int | xd_real10 (OSCTXT *pctxt, const char **object_p, ASN1TagType tagging, int length) |
| int | xd_setp (OSCTXT *pctxt, const OSOCTET *msg_p, int msglen, ASN1TAG *tag_p, int *len_p) |
| int | xd_indeflen_ex (const OSOCTET *msg_p, int bufSize) |
| int | xd_len (OSCTXT *pctxt, int *len_p) |
| int | xd_chkend (OSCTXT *pctxt, ASN1CCB *ccb_p) |
| int | xd_count (OSCTXT *pctxt, int length, int *count_p) |
| int | xd_NextElement (OSCTXT *pctxt) |
| int | xd_Tag1AndLen (OSCTXT *pctxt, OSINT32 *len_p) |
| int | xd_memcpy (OSCTXT *pctxt, OSOCTET *object_p, int length) |
| int | xd_match1 (OSCTXT *pctxt, OSOCTET tag, int *len_p) |
Define Documentation
|
|
This function is used to decode a variable of the ASN.1 UTF-8 string type. This function allocates memory for the decoded string and returns a pointer to the data.
|
Function Documentation
|
||||||||||||||||||||||||
|
This function is the base function for decoding a 16-bit character string useful type. In the current version of ASN.1, the only string type based on 16-bit Unicode characters is the UniCharString type. This function allocates memory for the decoded string and returns a pointer to the data.
|
|
||||||||||||||||||||||||
|
This function is the base function for decoding a 32-bit character string useful type. In the current version of ASN.1, the only string type based on 32-bit characters is the 32BitCharString type. This function allocates memory for the decoded string and returns a pointer to the data.
|
|
||||||||||||||||||||
|
This function parses an ASN.1 INTEGER tag/length/value at the current message pointer location and advances the pointer to the next field. This function will decode a variable of the ASN.1 INTEGER type. In this case, the integer is assumed to be of a larger size than can fit in a C or C++ long type (normally 32 or 64 bits). For example, parameters used to calculate security values are typically larger than these sizes. These variables are stored in character string constant variables. They are represented as decimal strings starting with no prefix. If it is necessary to convert a decimal string to another radix, then use rtxBigIntSetStr / rtxBigIntToString functions.
|
|
||||||||||||||||||||||||
|
This function decodes a variable of the ASN.1 BIT STRING. This function will allocate dynamic memory to store the decoded result.
|
|
||||||||||||||||||||||||
|
This function decodes a variable of the ASN.1 BIT STRING type into a static memory structure. This function call is generated by ASN1C to decode a sized bit string production.
|
|
||||||||||||||||||||
|
This function parses an ASN.1 BOOLEAN tag/length/value at the current message pointer location and advances the pointer to the next field. The function first checks to see if explicit tagging is specified. If yes, the universal tag for this message type is checked to make sure it is of the expected value. If the match is not successful, a negative value is returned to indicate the parse was not successful. Otherwise, the pointer is advanced to the length field and the length parsed. The length value is then check to see if it is equal to one which is the only valid length for boolean. If it is equal, the boolean data value is parsed; otherwise, and error is returned.
|
|
||||||||||||||||||||||||
|
This function is the base function for decoding any of the 8-bit character string useful types such as IA5String, VisibleString, etc. This function allocates memory for the decoded string and returns a pointer to the data.
|
|
||||||||||||
|
This function checks for the end of a constructed element. It is typically used by the ASN1C compiler to set up a loop for decoding a constructed type such as a SEQUENCE or SET.
|
|
||||||||||||||||
|
This function determines the count of elements within a constructed type.
|
|
||||||||||||||||||||
|
This function decodes a value of the ASN.1 ENUMERATED type. This function is identical to the integer decode function (xd_integer) except that the enumerated universal tag value is validated.
|
|
||||||||||||
|
This function calculates the actual length of an indefinite length message component.
|
|
||||||||||||||||||||
|
This function parses an ASN.1 INTEGER tag/length/value at the current message pointer location and advances the pointer to the next field. This function is similar to xd_integer but it is used to parse 16-bit integer values.
|
|
||||||||||||||||||||
|
This function parses an ASN.1 INTEGER tag/length/value at the current message pointer location and advances the pointer to the next field. The function is similar to xd_integer but it can be used to parse integer values with sizes up to 64 bits (if platform supports such integer's size). If the match is successful or implicit tagging is specified, the integer data value is parsed.
|
|
||||||||||||||||||||
|
This function parses an ASN.1 INTEGER tag/length/value at the current message pointer location and advances the pointer to the next field. This function is similar to xd_integer but it is used to parse 8-bit integer values.
|
|
||||||||||||||||||||
|
This function parses an ASN.1 INTEGER tag/length/value at the current message pointer location and advances the pointer to the next field. The function first checks to see if explicit tagging is specified. If yes, the universal tag value is parsed and checked to make sure it matches the expected tag for this message type. If not, a negative value is returned to indicate the parse was not successful. Otherwise, the length value is parsed. If the match is successful or implicit tagging is specified, the integer data value is parsed.
|
|
||||||||||||
|
This function decodes an ASN.1 length value.
|
|
||||||||||||||||||||
|
This function compares the tag at the current message pointer position with the given tag for a match. If a match occurs, the length field is decoded and the length is returned to the caller. If the input parameter 'advance' is set to TRUE, the message pointer is advanced to the beginning of the contents field. If a match does not occur, the routine will skip to subsequent fields in search of a match. If a match is eventually found, the processing described above is done; otherwise, a not found status is returned to the caller.
|
|
||||||||||||||||
|
The xd_match1 function does a comparison between the given tag and the tag at the current decode pointer position to determine if they match. It then returns the result of the match operation. In contrast to xd_match function xd_match1 is an optimized version and can be used only to compare primitive tags (with number less than 31). It is always advance the decode pointer to the contents field if matching is successful. Note, that the tag should be specified as an octet, like it is used in BER encoding.
|
|
||||||||||||||||
|
This function copies data from the contents field of a message component into the target object.
|
|
|
This function skips to the next element in the decode buffer.
|
|
||||||||||||
|
This function decoded the ASN.1 NULL placeholder type. The null data type contains no data; however, if explicit tagging is specified, it will contain a universal tag value (5) and zero length. This function will parse those values.
|
|
||||||||||||||||||||
|
This function decodes a value of the ASN.1 object identifier type.
|
|
||||||||||||||||||||||||
|
This function decodes the octet string at the current message pointer location and returns its value. This version of the function allocates memory for the decoded string and returns a pointer to the data.
|
|
||||||||||||||||||||||||
|
This function decodes the octet string at the current message pointer location and returns its value. The value is returned in the buffer pointed to by the given character buffer pointer. This is a static buffer that must be large enough to hold the decoded data.
|
|
||||||||||||||||||||
|
This function decodes a value of the ASN.1 object identifier type using 64-bit subidentifiers.
|
|
||||||||||||||||
|
This function decodes a value of an ASN.1 open type. An open type is used to model the old ASN.1 ANY and ANY DEFINED BY types. It is also used to model variable type references within information objects (for example, TYPE-IDENTIFER.&Type). Dynamic memory is allocated to hold the decoded result.
|
|
||||||||||||
|
This function appends a decoded open type element onto a list of elements. It is used by the ASN1C compiler to decode messages with multiple extension fields following an extension marker (...).
|
|
||||||||||||||||||||
|
This function decodes an ASN.1 open type extension. This is the optional data that follows the ... in multi-version messages. Dynamic memory is allocated to hold the decoded result.
|
|
||||||||||||||||||||
|
This function decodes a value of the binary encoded ASN.1 REAL type.
|
|
||||||||||||||||||||
|
This function decodes a value of the decimal encoded ASN.1 REAL type.
|
|
||||||||||||||||||||
|
This function decodes a value of the ASN.1 RELATIVE-OID type.
|
|
||||||||||||||||||||||||
|
This function sets the decode pointer (cursor) to point at the beginning of the encoded ASN.1 message that is to be decoded. This function must be called prior to calling any of the other decode functions.
|
|
||||||||||||
|
This function decodes an ASN.1 tag into a standard 32-bit unsigned integer type. The bits used to represent the components of a tag are as follows: Bit Fields:
|
|
||||||||||||
|
This function is an optimized version of the xd_tag_len function. If the ASN1C compiler determines the tag at a given location to be parsed is only one byte long (a typical case) then it will use this function. It reads a single tag byte and then immediately parses the length field.
|
|
||||||||||||||||||||
|
This function parses the ASN.1 tag and length fields located at the current message pointer position. xd_tag_len monitors indefinite length messages as follows: Each time a length is parsed, it is checked to see if it is an indefinite length value. If it is, an indefinite length section counter is incremented. Each time an end-of-contents (EOC) identifier is parsed, this counter is decremented. When the counter goes to zero, end of message is signaled.
|
|
||||||||||||||||||||
|
This function parses an unsigned variant of ASN.1 INTEGER tag/length/value at the current message pointer location and advances the pointer to the next field. This function is similar to xd_unsigned but it is used to parse 16-bit unsigned integer values.
|
|
||||||||||||||||||||
|
This function parses an unsigned variant of ASN.1 INTEGER tag/length/value at the current message pointer location and advances the pointer to the next field. The function is similar to xd_unsigned but it can be used to parse integer values with sizes up to 64 bits (if platform supports such integer's size). If the match is successful or implicit tagging is specified, the integer data value is parsed.
|
|
||||||||||||||||||||
|
This function parses an unsigned variant of ASN.1 INTEGER tag/length/value at the current message pointer location and advances the pointer to the next field. This function is similar to xd_unsigned but it is used to parse 8-bit unsigned integer values.
|
|
||||||||||||||||||||
|
This function parses an unsigned variant of ASN.1 INTEGER tag/length/value at the current message pointer location and advances the pointer to the next field. The function first checks to see if explicit tagging is specified. If yes, the universal tag value is parsed and checked to make sure it matches the expected tag for this message type. If not, a negative value is returned to indicate the parse was not successful. Otherwise, the length value is parsed. If the match is successful or implicit tagging is specified, the integer data value is parsed.
|
