Next: , Previous: , Up: Utilities   [Contents][Index]


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 [OPTION] DEFINITIONS ASSIGNMENTS
Generates a DER encoding of ASN.1 DEFINITIONS file
and ASSIGNMENTS file with value assignments.

Mandatory arguments to long options are mandatory for short options too.
  -c, --check           checks the syntax only
  -o, --output=FILE     output file
  -h, --help            display this help and exit
  -v, --version         output version information and exit

Report bugs to: help-libtasn1@gnu.org
GNU Libtasn1 home page: <https://www.gnu.org/software/libtasn1/>
General help using GNU software: <https://www.gnu.org/gethelp/>

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

Next: , Previous: , Up: Utilities   [Contents][Index]