Cryptography for Developers

ASN.1 grammar follows a rather traditional Backus-Naur Form (BNF) style grammar, which is fairly loosely interpreted throughout the cryptographic industry. The elements of the grammar of importance to us are the name, type, modifiers, allowable values, and containers. As mentioned earlier, we are only lightly covering the semantics of the ASN.1 grammar. The goal of this section is to enable the reader to understand ASN.1 definitions sufficient to implement encoders or decoders to handle them. The most basic expression (also referred to as a production in ITU-T documentation) would be
Name ::= type
which literally states that some element named Name is an instance of a given ASN.1 type called type. For example,
MyName ::= IA5String
which would mean that we want an element or variable named MyName that is of the ASN.1 type IA5String (like an ASCII string).
Occasionally, we want to specify an ASN.1 type where subsets of the elements have pre-determined values. This is accomplished with the following grammar.
Name ::= type (Explicit Value)
The explicit value has to be an allowable value for the ASN.1 type chosen and is the only value allowed for the element. For example, using our previous example we can specify a default name.
MyName ::= IA5String (Tom)
This means that MyName is the IA5String encoding of the string Tom . To give the language more flexibility the grammar allows other interpretations of the explicit values. One common exception is the composition vertical bar . Expanding on the previous...