BER/DER C Encode Functions.
[BER Runtime Library Functions.]
Defines | |
#define | xe_utf8str(pctxt, object_p, tagging) xe_charstr (pctxt, (const char*)object_p, tagging, ASN_ID_UTF8String) |
Functions | |
int | xe_identifier (OSCTXT *pctxt, OSUINT32 ident) |
int | xe_tag (OSCTXT *pctxt, ASN1TAG tag) |
int | xe_tag_len (OSCTXT *pctxt, ASN1TAG tag, int length) |
int | xe_boolean (OSCTXT *pctxt, OSBOOL *object_p, ASN1TagType tagging) |
int | xe_integer (OSCTXT *pctxt, int *object_p, ASN1TagType tagging) |
int | xe_unsigned (OSCTXT *pctxt, OSUINT32 *object_p, ASN1TagType tagging) |
int | xe_int8 (OSCTXT *pctxt, OSINT8 *object_p, ASN1TagType tagging) |
int | xe_int16 (OSCTXT *pctxt, OSINT16 *object_p, ASN1TagType tagging) |
int | xe_int64 (OSCTXT *pctxt, OSINT64 *object_p, ASN1TagType tagging) |
int | xe_uint64 (OSCTXT *pctxt, OSUINT64 *object_p, ASN1TagType tagging) |
int | xe_uint8 (OSCTXT *pctxt, OSUINT8 *object_p, ASN1TagType tagging) |
int | xe_uint16 (OSCTXT *pctxt, OSUINT16 *object_p, ASN1TagType tagging) |
int | xe_bigint (OSCTXT *pctxt, const char *object_p, ASN1TagType tagging) |
int | xe_bitstr (OSCTXT *pctxt, const OSOCTET *object_p, OSUINT32 numbits, ASN1TagType tagging) |
int | xe_octstr (OSCTXT *pctxt, const OSOCTET *object_p, OSUINT32 numocts, ASN1TagType tagging) |
int | xe_charstr (OSCTXT *pctxt, const char *object_p, ASN1TagType tagging, ASN1TAG tag) |
int | xe_16BitCharStr (OSCTXT *pctxt, Asn116BitCharString *object_p, ASN1TagType tagging, ASN1TAG tag) |
int | xe_32BitCharStr (OSCTXT *pctxt, Asn132BitCharString *object_p, ASN1TagType tagging, ASN1TAG tag) |
int | xe_null (OSCTXT *pctxt, ASN1TagType tagging) |
int | xe_objid (OSCTXT *pctxt, ASN1OBJID *object_p, ASN1TagType tagging) |
int | xe_oid64 (OSCTXT *pctxt, ASN1OID64 *object_p, ASN1TagType tagging) |
int | xe_reloid (OSCTXT *pctxt, ASN1OBJID *object_p, ASN1TagType tagging) |
int | xe_enum (OSCTXT *pctxt, OSINT32 *object_p, ASN1TagType tagging) |
int | xe_enumUnsigned (OSCTXT *pctxt, OSUINT32 *object_p, ASN1TagType tagging) |
int | xe_real (OSCTXT *pctxt, OSREAL *object_p, ASN1TagType tagging) |
int | xe_OpenType (OSCTXT *pctxt, const OSOCTET *object_p, OSUINT32 numocts) |
int | xe_OpenTypeExt (OSCTXT *pctxt, OSRTDList *pElemList) |
int | xe_real10 (OSCTXT *pctxt, const char *object_p, ASN1TagType tagging) |
int | xe_derReal10 (OSCTXT *pctxt, const char *object_p, ASN1TagType tagging) |
int | xe_setp (OSCTXT *pctxt, OSOCTET *buf_p, int bufsiz) |
OSOCTET * | xe_getp (OSCTXT *pctxt) |
void | xe_free (OSCTXT *pctxt) |
int | xe_expandBuffer (OSCTXT *pctxt, size_t length) |
int | xe_memcpy (OSCTXT *pctxt, const OSOCTET *object_p, size_t length) |
int | xe_len (OSCTXT *pctxt, int length) |
int | xe_derCanonicalSort (OSCTXT *pctxt, OSRTSList *pList) |
int | xe_TagAndIndefLen (OSCTXT *pctxt, ASN1TAG tag, int length) |
void | xe_getBufLocDescr (OSCTXT *pctxt, OSUINT32 length, Asn1BufLocDescr *pDescr) |
int | derEncBitString (OSCTXT *pctxt, const OSOCTET *pvalue, OSUINT32 numbits, ASN1TagType tagging) |
Detailed Description
BER/DER C encode functions handle the BER encoding 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 complier to accomplish the encoding of complex ASN.1 structures. These functions are also directly callable from within a user's application program if the need to accomplish a low level encoding function exists.
The procedure to call the encode function that encodes a primitive type is the same as the procedure to call a compiler generated encode function described above. The rtxInitContext and xe_setp functions must first be called to initialize a context variable and set a pointer to the buffer into which the variable is to be encoded. A static encode buffer is specified by specifying a pointer to a buffer and buffer size. Setting the buffer address to NULL and buffer size to 0 specifies a dynamic buffer. The primitive encode function is invoked. Finally, xe_getp is called to retrieve a pointer to the encoded message component.
Define Documentation
#define xe_utf8str | ( | pctxt, | |||
object_p, | |||||
tagging | ) | xe_charstr (pctxt, (const char*)object_p, tagging, ASN_ID_UTF8String) |
This function will encode a variable one of ASN.1 UTF-8 character string type.
- Parameters:
-
pctxt Pointer to a context block 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 null-terminated UTF-8 C character string to be encoded. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
Function Documentation
int derEncBitString | ( | OSCTXT * | pctxt, | |
const OSOCTET * | pvalue, | |||
OSUINT32 | numbits, | |||
ASN1TagType | tagging | |||
) |
This function encodes a BIT STRING value in accordance with the Distinguished Encoding Rules (DER). It adjusts the bit count to remove trailing zero bits and then invokes the BER encode function.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store al working variables that must be maintained between function calls. pvalue Bit string to be encoded. numbits Number of bits in the bit string. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_16BitCharStr | ( | OSCTXT * | pctxt, | |
Asn116BitCharString * | object_p, | |||
ASN1TagType | tagging, | |||
ASN1TAG | tag | |||
) |
This function will encode a variable one of the ASN.1 character string types that are based on a 16-bit character set. This includes the ASN.1 BMP character string type.
- Parameters:
-
pctxt Pointer to a context block 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 t a structure representing a 16-bit character string to be encoded. This structure contains a character count element and a pointer to an array of 16-bit character elements represented as 16-bit short integers. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. tag The Universal ASN.1 tag to be encoded in the message. This parameter is passed using the internal representation discussed in Section 4.1.2. It is passed as an unsigned 16-bit integer. The tag value must represent one of the 16-bit character string types documented in the X.680 standard.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_32BitCharStr | ( | OSCTXT * | pctxt, | |
Asn132BitCharString * | object_p, | |||
ASN1TagType | tagging, | |||
ASN1TAG | tag | |||
) |
This function will encode a variable one of the ASN.1 character string types that are based on a 32-bit character set. This includes the ASN.1 Universal character string type.
- Parameters:
-
pctxt Pointer to a context block 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 t a structure representing a 32-bit character string to be encoded. This structure contains a character count element and a pointer to an array of 32-bit character elements represented as 16-bit short integers. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. tag The Universal ASN.1 tag to be encoded in the message. This parameter is passed using the internal representation discussed in Section 4.1.2. It is passed as an unsigned 32-bit integer. The tag value must represent one of the 32-bit character string types documented in the X.680 standard.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_bigint | ( | OSCTXT * | pctxt, | |
const char * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function encodes 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.
Items of this type are stored in character string constant variables. They can be represented as decimal strings (with no prefixes), as hexadecimal strings starting with a "0x" prefix, as octal strings starting with a "0o" prefix or as binary strings starting with a "0b" prefix. Other radixes currently are not supported. Non-decimal values are assumed to be in two's complement form, unless a leading zero is included. It is highly recommended to use the hexadecimal or binary strings for better performance.
- Parameters:
-
pctxt Pointer to context block structure. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. object_p A pointer to a character string containing the value to be encoded.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_bitstr | ( | OSCTXT * | pctxt, | |
const OSOCTET * | object_p, | |||
OSUINT32 | numbits, | |||
ASN1TagType | tagging | |||
) |
This function will encode a variable of the ASN.1 BIT STRING type.
- Parameters:
-
pctxt Pointer to a context block 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 an OCTET string containing the bit data to be encoded. The string contains bytes having the actual bit settings as they are to be encoded in the message. numbits The number of bits within the bit string to be encoded. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_boolean | ( | OSCTXT * | pctxt, | |
OSBOOL * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function will encode a variable of the ASN.1 BOOLEAN type.
- Parameters:
-
pctxt A 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 the BOOLEAN value to be encoded (note that pointer to the BOOLEAN is passed, not the BOOLEAN itself. This may seem awkward, but to keep the calling sequence of all encode functions the same, pointers were used in all cases). A BOOLEAN is defined as a single OCTET whose value is 0 for FALSE and any other value for TRUE. tagging An enumerated type whose value is set to either ASN1EXPL (for explicit tagging) or ASN1IMPL (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to ASN1EXPL.
- Returns:
- The length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_charstr | ( | OSCTXT * | pctxt, | |
const char * | object_p, | |||
ASN1TagType | tagging, | |||
ASN1TAG | tag | |||
) |
This function will encode a variable one of the ASN.1 character string types that are based 8-bit character sets. This includes IA5String, VisibleString, PrintableString, and NumericString
- Parameters:
-
pctxt Pointer to a context block 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 null-terminated C character string to be encoded tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. tag The Universal ASN.1 tag to be encoded in the message. This parameter is passed using the internal representation discussed in Section 4.1.2. It is passed as an unsigned 16-bit integer. The tag value must represent one of the 8-bit character string types documented in the X.680 standard.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_derCanonicalSort | ( | OSCTXT * | pctxt, | |
OSRTSList * | pList | |||
) |
This function is added to the generated code for SEQUENCE OF/SET OF constructs to ensure the elements are in the required canonical order for DER.
If the elements are not in the right order, they are sorted to be in the correct order prior to encoding.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store al working variables that must be maintained between function calls. pList Linked List of message components to be sorted. The elements of this list are offsets to encoded components within the encode buffer.
- Returns:
- Completion status of operation:
- 0 (0) = success,
- negative return value is error.
int xe_derReal10 | ( | OSCTXT * | pctxt, | |
const char * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function will encode a number from character string to ASN.1 real type with using CER/DER decimal encoding. Number may be represented in integer, decimal, and exponent formats.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store al working variables that must be maintained between function calls. object_p Value to be encoded. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_enum | ( | OSCTXT * | pctxt, | |
OSINT32 * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function encodes a variable of the ASN.1 ENUMERATED type.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store al working variables that must be maintained between function calls. object_p A pointer to an integer containing the enumerated value to be encoded (Note that a pointer to the value is passed not the value itself. This may seem awkward, but to keep the calling sequence of all the encode function the same, pointers were used in all cases.) tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_enumUnsigned | ( | OSCTXT * | pctxt, | |
OSUINT32 * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function encodes a variable of the ASN.1 ENUMERATED type.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store al working variables that must be maintained between function calls. object_p A pointer to an integer containing the enumerated value to be encoded (Note that a pointer to the value is passed not the value itself. This may seem awkward, but to keep the calling sequence of all the encode function the same, pointers were used in all cases.) tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_expandBuffer | ( | OSCTXT * | pctxt, | |
size_t | length | |||
) |
This function will expand a dynamic encode buffer.
The dynamic encode buffer is the buffer that is allocated if dynamic encoding of a message is enabled (passing NULL as the buffer pointer argument to xe_setp enables dynamic encoding.)
The size of the new buffer is determined by the length argument. If the length is less than a configurable buffer expansion increment size (the constant ASN_K_ENCBUFSIZ), the buffer is expanded by the increment size; otherwise it is expanded by the actual length value.
- Parameters:
-
pctxt 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. The dynamic encode buffer pointer is contained within the structure. length The number of bytes required. This may not be size the size the buffer is actually expanded by. The buffer will be expanded by a fixed-size increment defined by ASN_K_ENCBUFSIZ for small requests to limit the required number of expansions.
void xe_free | ( | OSCTXT * | pctxt | ) |
This function will free a dynamic encode buffer.
The dynamic encode buffer is the buffer that is allocated if dynamic encoding of a message is enabled (passing NULL as the buffer pointer argument to xe_setp enables dynamic encoding.)
Note that this is different than the xu_freeall function associated with freeing decoder memory. This function only releases the memory associated with a dynamic encoded buffer. The xu_freeall will not release this memory.
- Parameters:
-
pctxt 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. The dynamic encode buffer pointer is contained within the structure.
Referenced by ASN1BEREncodeBuffer::freeBuffer().
void xe_getBufLocDescr | ( | OSCTXT * | pctxt, | |
OSUINT32 | length, | |||
Asn1BufLocDescr * | pDescr | |||
) |
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store al working variables that must be maintained between function calls. length The actual length of existing message components. pDescr A pointer to a buffer location descriptor.
OSOCTET* xe_getp | ( | OSCTXT * | pctxt | ) |
This function is used to obtain a pointer to the start of an encoded message after calls to the encode function(s) are complete. ANS.1 messages are encoded from the end of a given buffer toward the beginning. Therefore, in practically all cases, the start of the message will not be at the beginning of the buffer.
- Parameters:
-
pctxt A 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.
- Returns:
- A pointer to the beginning of the encoded message.
int xe_identifier | ( | OSCTXT * | pctxt, | |
OSUINT32 | ident | |||
) |
This function is used to encode an ASN.1 identifier value.
- Parameters:
-
pctxt A 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. ident Identifier value to be encoded.
- Returns:
- Length of the encoded item.
int xe_int16 | ( | OSCTXT * | pctxt, | |
OSINT16 * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function encodes a 16-bit variable of the ASN.1 INTEGER type.
- Parameters:
-
pctxt Pointer to context block structure. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. object_p A pointer to the 16-bit INTEGER value to be encoded (note that a pointer is passed, not the INTEGER value itself. This may seem awkward, but to keep the calling sequence of all encode functions the same, pointers were used in all cases). The OSINT16 type is set to the C type 'short' in the rtxsrc/rtxCommon.h file. This is assumed to represent a 16-bit integer value.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_int64 | ( | OSCTXT * | pctxt, | |
OSINT64 * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function encodes a 64-bit variable of the ASN.1 INTEGER type.
- Parameters:
-
pctxt Pointer to context block structure. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. object_p A pointer to the 64-bit INTEGER value to be encoded (note that a pointer to the INTEGER is passed, not the INTEGER value itself. This may seem awkward, but to keep the calling sequence of all encode functions the same, pointers were used in all cases). The OSINT64 type is set to the C type '__int64', 'long long' or 'long' in the rtxsrc/rtxCommon.h file (depends on the used platform and the compiler). This is assumed to represent a 64-bit integer value.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_int8 | ( | OSCTXT * | pctxt, | |
OSINT8 * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function encodes an 8-bit variable of the ASN.1 INTEGER type.
- Parameters:
-
pctxt Pointer to context block structure. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. object_p A pointer to the 8-bit INTEGER value to be encoded (note that a pointer is passed, not the INTEGER value itself. This may seem awkward, but to keep the calling sequence of all encode functions the same, pointers were used in all cases). The OSINT8 type is set to the C type 'signed char' in the rtxsrc/rtxCommon.h file. This is assumed to represent an 8-bit integer value.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_integer | ( | OSCTXT * | pctxt, | |
int * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function encodes a variable of the ASN.1 INTEGER type.
- Parameters:
-
pctxt Pointer to context block structure. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. object_p A pointer to the INTEGER value to be encoded (note that a pointer to the INTEGER is passed, not the INTEGER value itself. This may seem awkward, but to keep the calling sequence of all encode functions the same, pointers were used in all cases). The OSINT32 type is set to the C type 'int' in the rtxsrc/rtxCommon.h file. This is assumed to represent a 32-bit integer value.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_len | ( | OSCTXT * | pctxt, | |
int | length | |||
) |
This function is used to encode BER or DER length determinant values.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store al working variables that must be maintained between function calls. length The length variable to encode. For indefinite length, use ASN_K_INDEFLEN.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_memcpy | ( | OSCTXT * | pctxt, | |
const OSOCTET * | object_p, | |||
size_t | length | |||
) |
This function is used to copy bytes into the encode buffer. BER and DER messages are encoded from back-to-front and this function will take this into account when copying bytes. It will also check to ensure that enough space is available in the buffer for the bytes to be copied. If the encode buffer is dynamic, it will be expanded to hold the number of bytes to be copied if not enough space is available. If the buffer is static and enough space is not available, an error (RTERR_BUFOVFLW) will be returned.
- Parameters:
-
pctxt 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. The dynamic encode buffer pointer is contained within the structure. object_p A pointer to a buffer containing the bytes to be copied. length The number of bytes to copy.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_null | ( | OSCTXT * | pctxt, | |
ASN1TagType | tagging | |||
) |
This function will encode an ASN.1 NULL placeholder.
- Parameters:
-
pctxt Pointer to a context block structure. This provides a storage area for the function to store all working variables that must be maintained between function calls. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_objid | ( | OSCTXT * | pctxt, | |
ASN1OBJID * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function encodes a value of the ASN.1 object identifier type.
- Parameters:
-
pctxt Pointer to context block structure. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. object_p Pointer to value to be encoded. The ASN1OBJID structure contains a numids fields to hold the number of subidentifiers and an array to hold the subidentifier values.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_octstr | ( | OSCTXT * | pctxt, | |
const OSOCTET * | object_p, | |||
OSUINT32 | numocts, | |||
ASN1TagType | tagging | |||
) |
This function will encode a variable of the ASN.1 OCTET STRING type.
- Parameters:
-
pctxt Pointer to a context block 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 an OCTET string containing the bit data to be encoded. The string contains bytes having the actual bit settings as they are to be encoded in the message. numocts The number of octets (bytes) within the OCTET STRING to be encoded. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_oid64 | ( | OSCTXT * | pctxt, | |
ASN1OID64 * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function encodes a value of the ASN.1 object identifier type, using 64-bit subidentifiers.
- Parameters:
-
pctxt Pointer to context block structure. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. object_p Pointer to value to be encoded. The ASN1OID64 structure contains a numids fields to hold the number of subidentifiers and an array of unsigned 64-bit integers to hold the subidentifier values.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_OpenType | ( | OSCTXT * | pctxt, | |
const OSOCTET * | object_p, | |||
OSUINT32 | numocts | |||
) |
This function will encode a variable of the old (pre- 1994) ASN.1 ANY type or other elements defined in the later standards to be Open Types (for example, a variable type declaration in a CLASS construct as defined in X.681).
A variable of this type is considered to be previously encoded ASN.1 message component.
- Parameters:
-
pctxt 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 buffer containing an encoded ASN.1 message component. numocts The number of octets to be encoded.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_OpenTypeExt | ( | OSCTXT * | pctxt, | |
OSRTDList * | pElemList | |||
) |
- Parameters:
-
pctxt 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. pElemList A pointer to open type to be encoded.
int xe_real | ( | OSCTXT * | pctxt, | |
OSREAL * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function will encode a variable of the REAL data type.
This function provides support for the plus-infinity and minus-infinity special real values. Use the rtxGetPlusInfinity or rtxGetMinusInfinity functions to get these special values.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store al working variables that must be maintained between function calls. object_p A pointer to a variable of the OSREAL data type. This is defined to be the C double type. Special real values plus and minus infinity are encoded by using the rtxGetPlusInfinity and rtxGetMinusInfinity functions to set the real value to be encoded. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_real10 | ( | OSCTXT * | pctxt, | |
const char * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function will encode a number from character string to ASN.1 real type using decimal encoding. Number may be represented in integer, decimal, and exponent formats.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store al working variables that must be maintained between function calls. object_p Value to be encoded. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_reloid | ( | OSCTXT * | pctxt, | |
ASN1OBJID * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function encodes a value of the ASN.1 RELATIVE-OID type.
- Parameters:
-
pctxt Pointer to context block structure. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. object_p Pointer to value to be encoded. The ASN1OBJID structure contains a numids fields to hold the number of subidentifiers and an array to hold the subidentifier values.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_setp | ( | OSCTXT * | pctxt, | |
OSOCTET * | buf_p, | |||
int | bufsiz | |||
) |
This function is used to set the internal buffer within the runtime library encoding context. It must be called after the context variable is initialized by the rtxInitContext function and before any other compiler generated or runtime library encode function.
- Parameters:
-
pctxt 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. *buf_p A pointer to a memory buffer to use to encode a message. The buffer should be declared as an array of unsigned characters (OSOCTETs). This parameter can be set to NULL to specify dynamic encoding (i.e., the encode functions will dynamically allocate a buffer for the message). bufsiz The length of the memory buffer in bytes.
int xe_tag | ( | OSCTXT * | pctxt, | |
ASN1TAG | tag | |||
) |
This function is used to encode an ASN.1 tag value given its parts (class, form, and ID code).
- Parameters:
-
pctxt A 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. tag The ASN.1 tag to be encoded in the message. This parameter is passed using the ASN1C internal tag representation. It is passed as an unsigned 32-bit integer.
- Returns:
- Length of the encoded tag component.
int xe_tag_len | ( | OSCTXT * | pctxt, | |
ASN1TAG | tag, | |||
int | length | |||
) |
This function is used to encode ASN.1 tag and length fields that preface each block of message data. The ASN1C complier generates calls to this function to handle the encoding of user-defined tags within an ASN.1 specification. The function is also called from within the runtime library functions to handle the addition of the universal tags defined for each of the ASN.1 primitive data types.
- Parameters:
-
pctxt A 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. tag The ASN.1 tag to be encoded in the message. This parameter is passed using the ASN1C internal tag representation. It is passed as an unsigned 32-bit integer. length The length of the contents field previously encoded. This parameter can be used to specify the actual length, or the special constant ASN_K_INDEFLEN can be used to specify that an indefinite length specification should be encoded.
- Returns:
- Length of the encoded message component. This is equal to the given length plus the additional bytes that are added for the tag and length fields. A negative status will be returned if the encoding is not successful.
int xe_TagAndIndefLen | ( | OSCTXT * | pctxt, | |
ASN1TAG | tag, | |||
int | length | |||
) |
This function is used to encode a tag value and an indefinite length.
This can be used to manually create an indefinite length wrapper around long records.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store al working variables that must be maintained between function calls. tag ASN.1 tag value to be encoded. length The actual length of existing message components.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_uint16 | ( | OSCTXT * | pctxt, | |
OSUINT16 * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function encodes an unsigned 16-bit variable of the ASN.1 INTEGER type.
- Parameters:
-
pctxt Pointer to context block structure. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. object_p A pointer to the unsigned 16-bit INTEGER value to be encoded (note that a pointer is passed, not the INTEGER value itself. This may seem awkward, but to keep the calling sequence of all encode functions the same, pointers were used in all cases). The OSUINT16 type is set to the C type 'unsigned short' in the rtxsrc/rtxCommon.h file. This is assumed to represent a 16-bit integer value.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_uint64 | ( | OSCTXT * | pctxt, | |
OSUINT64 * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function encodes an unsigned 64-bit variable of the ASN.1 INTEGER type.
- Parameters:
-
pctxt Pointer to context block structure. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. object_p A pointer to the unsigned 64-bit INTEGER value to be encoded (note that a pointer to the unsigned INTEGER is passed, not the INTEGER value itself. This may seem awkward, but to keep the calling sequence of all encode functions the same, pointers were used in all cases). The OSUINT64 type is set to the C type 'unsigned __int64', 'unsigned long long' or 'unsigned long' in the rtxsrc/rtxCommon.h file (depends on the used platform and the compiler). This is assumed to represent a 64-bit integer value.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_uint8 | ( | OSCTXT * | pctxt, | |
OSUINT8 * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function encodes an unsigned 8-bit variable of the ASN.1 INTEGER type.
- Parameters:
-
pctxt Pointer to context block structure. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. object_p A pointer to the unsigned 8-bit INTEGER value to be encoded (note that a pointer is passed, not the INTEGER value itself. This may seem awkward, but to keep the calling sequence of all encode functions the same, pointers were used in all cases). The OSOCTET type is set to the C type 'unsigned char' in the rtxsrc/rtxCommon.h file. This is assumed to represent an 8-bit integer value.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.
int xe_unsigned | ( | OSCTXT * | pctxt, | |
OSUINT32 * | object_p, | |||
ASN1TagType | tagging | |||
) |
This function encodes an unsigned variable of the ASN.1 INTEGER type.
- Parameters:
-
pctxt Pointer to context block structure. tagging An enumerated type whose value is set to either 'ASN1EXPL' (for explicit tagging) or 'ASN1IMPL' (for implicit). Controls whether the universal tag value for this type is added or not. Users will generally always set this value to 'ASN1EXPL'. object_p A pointer to the unsigned INTEGER value to be encoded (note that a pointer to the unsigned INTEGER is passed, not the INTEGER value itself. This may seem awkward, but to keep the calling sequence of all encode functions the same, pointers were used in all cases). The OSUINT32 type is set to the C type 'unsigned int' in the rtxsrc/rtxCommon.h file. This is assumed to represent a 32-bit integer value.
- Returns:
- Length of the encoded message component. A negative status value will be returned if encoding is not successful.