Objective Systems, Inc.  
Home
About ASN.1
Products
Free Software
Open Source
Documents
Services
Resources
Resellers
Customers
Careers
About Us
Contact Us
 

Google


Objective Systems, Inc.

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:

  1. Call the xd_setp low-level decode function to specify the address of the buffer containing the encoded ASN.1 data to be decoded.
  2. 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_indeflen(m)   xd_indeflen_ex(m, INT_MAX)

Functions

int xd_tag (ASN1CTXT *ctxt_p, ASN1TAG *tag_p)
int xd_tag_len (ASN1CTXT *ctxt_p, ASN1TAG *tag_p, int *len_p, ASN1OCTET flags)
int xd_match (ASN1CTXT *ctxt_p, ASN1TAG tag, int *len_p, ASN1OCTET flags)
int xd_boolean (ASN1CTXT *ctxt_p, ASN1BOOL *object_p, ASN1TagType tagging, int length)
int xd_integer (ASN1CTXT *ctxt_p, ASN1INT *object_p, ASN1TagType tagging, int length)
int xd_int8 (ASN1CTXT *ctxt_p, ASN1INT8 *object_p, ASN1TagType tagging, int length)
int xd_int16 (ASN1CTXT *ctxt_p, ASN1SINT *object_p, ASN1TagType tagging, int length)
int xd_unsigned (ASN1CTXT *ctxt_p, ASN1UINT *object_p, ASN1TagType tagging, int length)
int xd_uint8 (ASN1CTXT *ctxt_p, ASN1UINT8 *object_p, ASN1TagType tagging, int length)
int xd_uint16 (ASN1CTXT *ctxt_p, ASN1USINT *object_p, ASN1TagType tagging, int length)
int xd_int64 (ASN1CTXT *ctxt_p, ASN1INT64 *object_p, ASN1TagType tagging, int length)
int xd_uint64 (ASN1CTXT *ctxt_p, ASN1UINT64 *object_p, ASN1TagType tagging, int length)
int xd_bigint (ASN1CTXT *ctxt_p, ASN1ConstCharPtr *object_p, ASN1TagType tagging, int length)
int xd_bitstr_s (ASN1CTXT *ctxt_p, ASN1OCTET *object_p, ASN1UINT *numbits_p, ASN1TagType tagging, int length)
int xd_bitstr (ASN1CTXT *ctxt_p, ASN1ConstOctetPtr *object_p2, ASN1UINT *numbits_p, ASN1TagType tagging, int length)
int xd_octstr_s (ASN1CTXT *ctxt_p, ASN1OCTET *object_p, ASN1UINT *numocts_p, ASN1TagType tagging, int length)
int xd_octstr (ASN1CTXT *ctxt_p, ASN1ConstOctetPtr *object_p2, ASN1UINT *numocts_p, ASN1TagType tagging, int length)
int xd_charstr (ASN1CTXT *ctxt_p, ASN1ConstCharPtr *object_p, ASN1TagType tagging, ASN1TAG tag, int length)
int xd_16BitCharStr (ASN1CTXT *ctxt_p, Asn116BitCharString *object_p, ASN1TagType tagging, ASN1TAG tag, int length)
int xd_32BitCharStr (ASN1CTXT *ctxt_p, Asn132BitCharString *object_p, ASN1TagType tagging, ASN1TAG tag, int length)
int xd_null (ASN1CTXT *ctxt_p, ASN1TagType tagging)
int xd_objid (ASN1CTXT *ctxt_p, ASN1OBJID *object_p, ASN1TagType tagging, int length)
int xd_oid64 (ASN1CTXT *ctxt_p, ASN1OID64 *object_p, ASN1TagType tagging, int length)
int xd_reloid (ASN1CTXT *ctxt_p, ASN1OBJID *object_p, ASN1TagType tagging, int length)
int xd_real (ASN1CTXT *ctxt_p, ASN1REAL *object_p, ASN1TagType tagging, int length)
int xd_enum (ASN1CTXT *ctxt_p, ASN1ENUM *object_p, ASN1TagType tagging, int length)
int xd_OpenType (ASN1CTXT *ctxt_p, ASN1ConstOctetPtr *object_p2, ASN1UINT *numocts_p)
int xd_OpenTypeExt (ASN1CTXT *ctxt_p, ASN1CCB *ccb_p, ASN1TAG tag, Asn1RTDList *pElemList)
int xd_OpenTypeAppend (ASN1CTXT *ctxt_p, Asn1RTDList *pElemList)
int xd_setp (ASN1CTXT *ctxt_p, ASN1ConstOctetPtr msg_p, int msglen, ASN1TAG *tag_p, int *len_p)
int xd_indeflen_ex (ASN1ConstOctetPtr msg_p, int bufSize)
int xd_len (ASN1CTXT *ctxt_p, int *len_p)
int xd_chkend (ASN1CTXT *ctxt_p, ASN1CCB *ccb_p)
int xd_count (ASN1CTXT *ctxt_p, int length, int *count_p)
int xd_NextElement (ASN1CTXT *ctxt_p)
int xd_Tag1AndLen (ASN1CTXT *ctxt_p, ASN1INT *len_p)
int xd_memcpy (ASN1CTXT *ctxt_p, ASN1OCTET *object_p, int length)
int xd_match1 (ASN1CTXT *ctxt_p, ASN1OCTET tag, int *len_p)


Function Documentation

int xd_16BitCharStr ASN1CTXT *  ctxt_p,
Asn116BitCharString *  object_p,
ASN1TagType  tagging,
ASN1TAG  tag,
int  length
 

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 BMPString type. This function allocates memory for the decoded string and returns a pointer to the data.

Parameters:
ctxt_p Pointer to ASN.1 context block structure
object_p Pointer to a pointer to receive the address of the allocated memory into which the decoded character string data will be stored. The string is assumed to contain all non-null 16-bit unicode characters. A null terminator is automatically added to the end of the string by this function.
tagging Specifies whether element is implicitly or explicitly tagged.
tag Tag variable to match
length Length of data to retrieve. Valid for implicit case only.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_32BitCharStr ASN1CTXT *  ctxt_p,
Asn132BitCharString *  object_p,
ASN1TagType  tagging,
ASN1TAG  tag,
int  length
 

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 UniversalString type. This function allocates memory for the decoded string and returns a pointer to the data.

Parameters:
ctxt_p Pointer to ASN.1 context block structure
object_p Pointer to a pointer to receive the address of the allocated memory into which the decoded character string data will be stored. The string is assumed to contain all non-null 32-bit unicode characters. A null terminator is automatically added to the end of the string by this function.
tagging Specifies whether element is implicitly or explicitly tagged.
tag Tag variable to match.
length Length of data to retrieve. Valid for implicit case only.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_bigint ASN1CTXT *  ctxt_p,
ASN1ConstCharPtr *  object_p,
ASN1TagType  tagging,
int  length
 

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 rtBigIntSetStr / rtBigIntToString functions.

Parameters:
ctxt_p Pointer to context block structure.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
object_p Pointer to a character pointer variable to receive the decoded unsigned value. Dynamic memory is allocated for the variable using the rtMemAlloc function. The decoded variable is represented as a decimal string starting with no prefix.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_bitstr ASN1CTXT *  ctxt_p,
ASN1ConstOctetPtr *  object_p2,
ASN1UINT *  numbits_p,
ASN1TagType  tagging,
int  length
 

This function decodes a variable of the ASN.1 BIT STRING. This function will allocate dynamic memory to store the decoded result.

Parameters:
ctxt_p Pointer to context block structure.
tagging Specifies whether element is implicitly or explicitly tagged.
length The length, in OCTETs, of the contents field to be decoded. This parameter only has meaning if the tagging parameter specifies implicit decoding. If explicit, the length is obtained from the decoded length field.
numbits_p Pointer to an integer value to receive the decoded number of bits.
object_p2 Pointer to a pointer variable to receive the decoded bit string. Dynamic memory is allocated to hold the string.Pointer to a variable to receive the decoded bit string.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_bitstr_s ASN1CTXT *  ctxt_p,
ASN1OCTET *  object_p,
ASN1UINT *  numbits_p,
ASN1TagType  tagging,
int  length
 

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.

Parameters:
ctxt_p Pointer to context block structure.
tagging Specifies whether element is implicitly or explicitly tagged.
length The length, in OCTETs, of the contents field to be decoded. This parameter only has meaning if the tagging parameter specifies implicit decoding. If explicit, the length is obtained from the decoded length field.
numbits_p Pointer to an integer variable containing the size (in bits) of the sized ASN.1 bit string. An error will occur if the number of bits in the decoded string is larger than this value. Note that this is also used as an output variable - the actual number of decoded bits will be returned in this variable.
object_p Pointer to a variable to receive the decoded bit string. This is assumed to be a static array large enough to hold the number of bits specified in the *numbits_p input parameter.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_boolean ASN1CTXT *  ctxt_p,
ASN1BOOL *  object_p,
ASN1TagType  tagging,
int  length
 

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.

Parameters:
ctxt_p Pointer to context block structure.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
object_p Decoded boolean data value.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • ASN_E_INVLEN invalid length (!= 1)
  • ASN_E_IDNOTFOU unexpected tag value (not UNIV 1)

int xd_charstr ASN1CTXT *  ctxt_p,
ASN1ConstCharPtr *  object_p,
ASN1TagType  tagging,
ASN1TAG  tag,
int  length
 

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.

Parameters:
ctxt_p Pointer to ASN.1 context block structure
object_p Pointer to a pointer to receive the address of the allocated memory into which the decoded character string data will be stored. The string is assumed to be a normal C string containing non-null characters. A null terminator is automatically added to the end of the string by this function.
tagging Specifies whether element is implicitly or explicitly tagged.
tag Tag variable to match
length Length of data to retrieve. Valid for implicit case only.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_chkend ASN1CTXT *  ctxt_p,
ASN1CCB *  ccb_p
 

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.

Parameters:
ctxt_p Pointer to context block structure.
ccb_p Pointer to a context control block (ccb). This is a structure added to compiler generated code to keep track of the current position within nested structures.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_count ASN1CTXT *  ctxt_p,
int  length,
int *  count_p
 

This function determines the count of elements within a constructed type.

Parameters:
ctxt_p Pointer to context block structure.
length Length of the constructed type.
count_p Pointer to an integer variable to receive the element count.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_enum ASN1CTXT *  ctxt_p,
ASN1ENUM *  object_p,
ASN1TagType  tagging,
int  length
 

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.

Parameters:
ctxt_p Pointer to context block structure.
object_p Pointer to value to receive decoded result.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_indeflen_ex ASN1ConstOctetPtr  msg_p,
int  bufSize
 

This function calculates the actual length of an indefinite length message component.

Parameters:
msg_p Pointer to an indefinite length message component.
bufSize Size of the message's buffer

int xd_int16 ASN1CTXT *  ctxt_p,
ASN1SINT *  object_p,
ASN1TagType  tagging,
int  length
 

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.

Parameters:
ctxt_p Pointer to context block structure.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
object_p Pointer to decoded 16-bit integer value.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_int64 ASN1CTXT *  ctxt_p,
ASN1INT64 *  object_p,
ASN1TagType  tagging,
int  length
 

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.

Parameters:
ctxt_p Pointer to context block structure.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
object_p Pointer to decoded 64-bit integer value.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_int8 ASN1CTXT *  ctxt_p,
ASN1INT8 *  object_p,
ASN1TagType  tagging,
int  length
 

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.

Parameters:
ctxt_p Pointer to context block structure.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
object_p Pointer to decoded 8-bit integer value.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_integer ASN1CTXT *  ctxt_p,
ASN1INT *  object_p,
ASN1TagType  tagging,
int  length
 

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.

Parameters:
ctxt_p Pointer to context block structure.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
object_p Pointer to decoded integer value.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_len ASN1CTXT *  ctxt_p,
int *  len_p
 

This function decodes an ASN.1 length value.

Parameters:
ctxt_p Pointer to context block structure.
len_p Pointer to integer variable to receive the the decoded length value. If the length is indefinite, the constant ASN_K_INDEFLEN is returned.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_match ASN1CTXT *  ctxt_p,
ASN1TAG  tag,
int *  len_p,
ASN1OCTET  flags
 

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.

Parameters:
ctxt_p Pointer to context block structure.
tag Tag variable to match.
len_p Length of message component. Returned as follows: >= 0 component is fixed length ASN_K_INDEFLEN component is indefinite length
flags Bit flags used to set the following options:
  • XM_ADVANCE: Advance decode pointer on match.
  • XM_SEEK : Seek until match found or EOM.
  • XM_SKIP : Skip to next tag before search
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_match1 ASN1CTXT *  ctxt_p,
ASN1OCTET  tag,
int *  len_p
 

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.

Parameters:
ctxt_p Pointer to context block structure.
tag Tag variable to match in octet format.
len_p Length of message component. Returned as follows: >= 0 component is fixed length ASN_K_INDEFLEN component is indefinite length
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_memcpy ASN1CTXT *  ctxt_p,
ASN1OCTET *  object_p,
int  length
 

This function copies data from the contents field of a message component into the target object.

Parameters:
ctxt_p Pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
*object_p A pointer to a memory structure to receive the copied data.
length The number of bytes to copy from the contents field.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_NextElement ASN1CTXT *  ctxt_p  ) 
 

This function skips to the next element in the decode buffer.

Parameters:
ctxt_p Pointer to context block structure.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_null ASN1CTXT *  ctxt_p,
ASN1TagType  tagging
 

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.

Parameters:
ctxt_p Pointer to ASN.1 context block structure
tagging Specifies whether element is implicitly or explicitly tagged. The function will do nothing if implicit tagging is specified.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_objid ASN1CTXT *  ctxt_p,
ASN1OBJID *  object_p,
ASN1TagType  tagging,
int  length
 

This function decodes a value of the ASN.1 object identifier type.

Parameters:
ctxt_p Pointer to context block structure.
object_p Pointer to value to receive decoded result. The ASN1OBJID structure contains an integer to hold the number of subidentifiers and an array to hold the subidentifier values.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_octstr ASN1CTXT *  ctxt_p,
ASN1ConstOctetPtr *  object_p2,
ASN1UINT *  numocts_p,
ASN1TagType  tagging,
int  length
 

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.

Parameters:
ctxt_p Pointer to ASN.1 context block structure
object_p2 Pointer to a pointer to receive the address of the allocated memory into which the decoded data will be stored.
numocts_p Pointer to an integer variable to receive length of the decoded octet string.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_octstr_s ASN1CTXT *  ctxt_p,
ASN1OCTET *  object_p,
ASN1UINT *  numocts_p,
ASN1TagType  tagging,
int  length
 

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.

Parameters:
ctxt_p Pointer to ASN.1 context block structure
object_p Pointer to static octet array to receive decoded data
numocts_p Pointer to an integer variable to receive the length of the decoded octet string. On input, this parameter is used to specify the size of the octet array.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_oid64 ASN1CTXT *  ctxt_p,
ASN1OID64 *  object_p,
ASN1TagType  tagging,
int  length
 

This function decodes a value of the ASN.1 object identifier type using 64-bit subidentifiers.

Parameters:
ctxt_p Pointer to context block structure.
object_p Pointer to value to receive decoded result. The ASN1OID64 structure contains an integer to hold the number of subidentifiers and an array of 64-bit unsigned integers to hold the subidentifier values.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_OpenType ASN1CTXT *  ctxt_p,
ASN1ConstOctetPtr *  object_p2,
ASN1UINT *  numocts_p
 

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.

Parameters:
ctxt_p Pointer to context block structure.
object_p2 Pointer to value to receive decoded result.
numocts_p Pointer to an integer variable to receive length of the decoded octet string.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_OpenTypeAppend ASN1CTXT *  ctxt_p,
Asn1RTDList *  pElemList
 

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 (...).

Parameters:
ctxt_p Pointer to context block structure.
pElemList Pointer to element list onto which the decoded element should be appended.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_OpenTypeExt ASN1CTXT *  ctxt_p,
ASN1CCB *  ccb_p,
ASN1TAG  tag,
Asn1RTDList *  pElemList
 

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.

Parameters:
ctxt_p Pointer to context block structure.
ccb_p Pointer to a 'context control block' structure. This is basically a loop control mechanism to keep the variable associated with parsing a nested constructed element straight.
tag Next expected tag value (or ASN_K_NOTAG value if last field). The routine will loop through elements until matching tag found or some other error occurs.
pElemList The pointer to linked list structure. The list will contain elements of ASN1OpenType type.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_real ASN1CTXT *  ctxt_p,
ASN1REAL *  object_p,
ASN1TagType  tagging,
int  length
 

This function decodes a value of the ASN.1 REAL type.

Parameters:
ctxt_p Pointer to context block structure.
object_p Pointer to value to receive decoded result. The ASN1REAL data type is a double-precision floating point number type (C double type).
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_reloid ASN1CTXT *  ctxt_p,
ASN1OBJID *  object_p,
ASN1TagType  tagging,
int  length
 

This function decodes a value of the ASN.1 RELATIVE-OID type.

Parameters:
ctxt_p Pointer to context block structure.
object_p Pointer to value to receive decoded result. The ASN1OBJID structure contains an integer to hold the number of subidentifiers and an array to hold the subidentifier values.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_setp ASN1CTXT *  ctxt_p,
ASN1ConstOctetPtr  msg_p,
int  msglen,
ASN1TAG *  tag_p,
int *  len_p
 

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.

Parameters:
ctxt_p Pointer to context block structure.
msg_p Pointer to message buffer containing data to be decoded.
msglen Pointer to size of the message data buffer. This is an optional parameter. It is used to verify that the length of the data encoded in the message is less than or equal to the given size of the message buffer. If the message size is unknown at the time of decoding, this argument can be set to zero and the size check will be bypassed.
tag_p Pointer to an ASN.1 tag variable to recieve the value of the initial tag parsed from a message. This is an optional parameter. It can be set to NULL is the user does not require the initial tag value.
len_p Pointer to an integer variable to receive the decoded message length. Note that this is the total length of the message from the start of message, NOT the actual length decoded after the initial tag. In other words the length of the initial tag and length are added on to the parsed length. This is an optional parameter. It can be set to NULL if the user does not require the message length value.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_tag ASN1CTXT *  ctxt_p,
ASN1TAG *  tag_p
 

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:

  • 31-30 Class (00 = UNIV, 01 = APPL, 10 = CTXT, 11 = PRIV)
  • 29 Form (0 = primitive, 1 = constructed)
  • 28-0 ID code value

Parameters:
ctxt_p Pointer to context block structure.
tag_p Pointer to variable to receive decoded tag info.
Returns:
Completion status of operation: 0 (ASN_OK) = success, negative return value is error.

int xd_Tag1AndLen ASN1CTXT *  ctxt_p,
ASN1INT *  len_p
 

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.

Parameters:
ctxt_p Pointer to context block structure.
len_p Length of message component. Returned as follows: >= 0 component is fixed length ASN_K_INDEFLEN component is indefinite length
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_tag_len ASN1CTXT *  ctxt_p,
ASN1TAG *  tag_p,
int *  len_p,
ASN1OCTET  flags
 

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.

Parameters:
ctxt_p Pointer to context block structure.
tag_p Pointer to variable to receive decoded tag info.
len_p Length of message component. Returned as follows: >= 0 component is fixed length ASN_K_INDEFLEN component is indefinite length
flags Bit flags used to set the following options: XM_ADVANCE: Advance decode pointer on match.
Returns:
Completion status of operation: 0 (ASN_OK) = success, negative return value is error.

int xd_uint16 ASN1CTXT *  ctxt_p,
ASN1USINT *  object_p,
ASN1TagType  tagging,
int  length
 

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.

Parameters:
ctxt_p Pointer to context block structure.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
object_p Pointer to decoded 16-bit unsigned integer value.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_uint64 ASN1CTXT *  ctxt_p,
ASN1UINT64 *  object_p,
ASN1TagType  tagging,
int  length
 

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.

Parameters:
ctxt_p Pointer to context block structure.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
object_p Pointer to decoded 64-bit unsigned integer value.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_uint8 ASN1CTXT *  ctxt_p,
ASN1UINT8 *  object_p,
ASN1TagType  tagging,
int  length
 

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.

Parameters:
ctxt_p Pointer to context block structure.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
object_p Pointer to decoded 8-bit unsigned integer value.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

int xd_unsigned ASN1CTXT *  ctxt_p,
ASN1UINT *  object_p,
ASN1TagType  tagging,
int  length
 

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.

Parameters:
ctxt_p Pointer to context block structure.
tagging Specifies whether element is implicitly or explicitly tagged.
length Length of data to retrieve. Valid for implicit case only.
object_p Pointer to decoded unsigned integer value.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.


Copyright © 1997-2005 Objective Systems,Inc.
All Rights Reserved.
This document may be distributed in any form, electronic
or otherwise, provided that it is distributed in its entirety
and that the copyright and this notice are included.

This file was last modified on 8 Sep 2005.
ASN1C BER Runtime, ASN1C v5.8x