silc_asn1_alloc

SYNOPSIS

    SilcAsn1 silc_asn1_alloc(SilcStack stack);

DESCRIPTION

Allocates and initializes ASN.1 encoder/decoder and returns SilcAsn1 context or NULL on error. This context can be used with both silc_asn1_encode and silc_asn1_decode functions. If `stack' is non-NULL all memory will be allocated from `stack'.

Usually SilcAsn1 is allocated when encoder or decoder is needed, however it is also possible to allocate long-lasting SilcAsn1 and use that every time ASN.1 routines are needed. Application could for example allocate one SilcAsn1 and use that for all ASN.1 encoding and decoding.

When this context is freed with silc_asn1_free all memory will be freed, and all encoded ASN.1 buffers becomes invalid. Also all data that is returned by silc_asn1_encode and silc_asn1_decode function becomes invalid, unless SILC_ASN1_ALLOC flag is used, in which case the memory is allocated from `stack' and the `stack' is consumed.