libtasn1: Invoking asn1Coding
3.2 Invoking asn1Coding
=======================
'asn1Coding' generates a DER encoding from a file with ASN.1 definitions
and another one with assignments.
The file with assignments must have this syntax:
InstanceName Asn1Definition
nameString value
nameString value
...
To specify the field of a 'CHOICE' to be used, specify its name as a
value to the 'CHOICE' element itself. Use '''' to denote the root
element itself. (as in the example below.)
The output file is a binary file with the DER encoding.
Usage: asn1Coding [options] file1 file2
file1 : file with ASN1 definitions.
file2 : file with assignments.
Options:
-h : shows the help message.
-v : shows version information and exit.
-c : checks the syntax only.
-o file : output file.
For example, consider an ASN.1 definitions file as follows:
MYPKIX1 { }
DEFINITIONS IMPLICIT TAGS ::=
BEGIN
OtherStruct := SEQUENCE {
x INTEGER,
y CHOICE {
y1 INTEGER,
y2 OCTET STRING },
}
Dss-Sig-Value ::= SEQUENCE {
r INTEGER,
s INTEGER,
other OtherStruct
z INTEGER OPTIONAL,
}
END
And a assignments file as follows:
dp MYPKIX1.Dss-Sig-Value
r 42
s 47
other.x 66
other.y y1
other.y.y1 15
z (NULL)
Running the command below will generate a 'assign.out' file,
containing the DER encoding of 'PKIX1.Dss-Sig-Value'.
$ asn1Coding pkix.asn assign.asn1
If the root element is of the 'CHOICE' type, the assignment file may
be like (using the types defined in 'pkix.asn'):
elt PKIX1Implicit88.GeneralName
'' dNSName
dNSName example.org