BER/DER encode functions are generated when the -ber (basic encoding rules) or -der (distinguished encoding rules), switch is specified on the command line. Encoding for BER and DER is quite similar with the more restrictive DER form also acceptable as a BER encoding. For that reason, encoding is done in DER form only. For the remainder of this section, the acronym BER will be used to mean either BER or DER form.
For each ASN.1 production defined in the ASN.1 source file, a BER encode function is generated. This function will convert a populated Go variable of the given type into a BER encoded ASN.1 message.