ASN.1 Interface

DESCRIPTION

Efficient Abstract Syntax Notation One (ASN.1) implementation. This interface provides simple and efficient ASN.1 encoder and decoder.

The encoder directly encodes BER encoded data blocks from variable argument list of ASN.1 types. Multiple trees can be encoded at once and multiple nodes can be encoded into the tree at once. By default encoder does not allocate any memory during encoding but a pre-allocated SilcStack is used as memory.

The decoder directly decodes BER encoded data blocks into the correct types dictated by the variable argument list of ASN.1 types. By default decoder does not allocate any memory during decoding but a pre-allocated SilcStack is used as memory.

The encoding and decoding interface is simple. silc_asn1_encode is used to encode and silc_asn1_decode to decode. The actual ASN.1 is defined as variable argument list to the function. Various macros can be used to encode and decode different ASN.1 types. All types may also be used to encode and decode with various options (such as implicit and explicit tagging and defining specific class option).

The implementation supports all the common ASN.1 types.

References: ITU-T X.680 - X.693 http://www.itu.int/ITU-T/studygroups/com17/languages/

EXAMPLE

 silc_asn1_encode(asn1, buf,
                  SILC_ASN1_SEQUENCE,
                    SILC_ASN1_BOOLEAN(bool_val),
                    SILC_ASN1_OCTET_STRING(string, string_len),
                    SILC_ASN1_SEQUENCE_T(0, 2),
                      SILC_ASN1_BOOLEAN_T(SILC_ASN1_EXPLICIT, 100, foo),
                     SILC_ASN1_END,
                     SILC_ASN1_OCTET_STRING_T(0, 1, string2, string2_len),
                   SILC_ASN1_END, SILC_ASN1_END);

 Creates ASN.1 tree that looks something like:

 buf ::= SEQUENCE {
   bool_val      BOOLEAN,
   string        OCTET-STRING,
            [2]  SEQUENCE {
                   foo   [100] EXPLICIT BOOLEAN }
   string2  [1]  OCTET-STRING }

TABLE OF CONTENTS