Chapter 15. Generated MDER Encode Methods

Table of Contents

Generated Method Format and Calling Parameters
Populating Generated Variables for Encoding
Procedure for Calling MDER Encode Methods
Reuse of Encoding Objects

Unlike what is done for other encoding rules, for MDER we provide stream-based encoding only. In order to encode to a memory buffer, you simply use a System.IO.MemoryStream.

For each ASN.1 production defined in an ASN.1 source file, an encode method may be generated. This function will convert a populated variable of the given type into an encoded ASN.1 message.

An encode method is only generated if it is required to alter the behavior of the base class. The C# model is built on inheritance from a set of common run-time base classes. MDER supports only a few primitive types, and most of these are subsets of ASN.1 built-in types. Therefore, in most cases, there is not an applicable MDER encode method in the common run-time base class and so an encode method will be generated.

The generated classes for all constructed types (SEQUENCE, SEQUENCE OF, and CHOICE) will include generated encode methods.