Asn1Compiler includes the new Time types defined by the Amendment 3 to X680 allowing the support of the full range of time types specified by ISO 8601-2004. The Extended-XER encoding rules are supported. This allows decoding and encoding of full XML documents handling all XML features such as attributes or namespaces for example.
The nio support is included in Asn1Compiler for Java.

Read the Release Notes for the latest improvements.

The ASN.1 compiler

The compiler Asn1Compiler generates the Java/C# classes from the ASN.1 schema.

It compiles an ASN.1 schema (defined through one or more ASN.1 files) and generates : 

  • error messages if syntax or semantic errors occur;
  • Java or C# classes associated to the assignments defined in the schema. 

The compiler is compliant with ASN.1 1997/2008 : 

  • Specification of basic notation (ITU-T X.680 / ISO/IEC 8824-1) 
  • Information object specification (ITU-T X.681 / ISO/IEC 8824-2) 
  • Constraint specification (ITU-T X.682 / ISO/IEC 8824-3) 
  • Parameterization of ASN.1 specifications (ITU-T X.683 / ISO/IEC 8824-4) 

Asn1Compiler handles information objects classes, information objects sets and relation constraints so that open types values are encoded and decoded automatically at runtime. The user does not need to write any extra code.

Asn1Compiler is a pure Java application. It can be installed on every machine (Windows, Unix, Linux...) provided a Java Virtual Machine can be installed.

Here are some interesting features of Asn1Compiler

  • configuration through a text file;
  • pure Java or C# code generation;
  • one Java package or C# namespace per module creation;
  • generation of documented classes (javadoc formats or XML .NET documentation);
  • automatic handling of information objects classes and sets as well as relation constraints to enable automatic decoding of open types with no extra code in the application;
  • automatic handling of content constraints applied on BIT STRING and OCTET STRING as well as subtype constraints on open types so that content is automatically decoded with no extra code in the application;
  • huge PDU handling (TAP3 PDU may reach 200MB) with post-decoding/pre-encoding on SET OF/SEQUENCE OF types to reduce storage usage;
  • automatic generation of examples. This feature is really interesting to develop quickly your application.

The runtime

The runtime is a pure Java or C# library. It gathers the encoding and decoding primitives for ASN.1 basic types.

The supported encoding rules are : 

  • Specification of Basic Encoding Rules (BER/DER, ITU-T X.690 / ISO/IEC 8825-1) 
  • Specification of Packed Encoding Rules (PER aligned and unaligned, ITU-T X.691 / ISO/IEC 8825-2) 
  • XML Encoding Rules (Basic XER/Canonical XER/Extended XER, ITU-T X.693 + Amendement-1 / ISO/IEC 8825-4) 

The runtimes offers the following features :

  • easy encoding rules change simply changing the encoder/decoder;
  • understandable error diagnostic;
  • serialization support;
  • clone/equals/hashcode/toString methods support.

An example

Here is an example describing the generation of an API for data structures defined in this file sample.asn1 :


The generation is configured within the file sample.arg :

  • generated API name is "Sample";
  • Encoding rules are ExtendedXER and AlignedBasicPER;
  • the target language is Java (or cSharp);
  • by default, sources files are to be generated in Sample/src/java (or Sample/src/cSharp).
# specify the asn1 files
asn1ToXml.inputFile.1=sample.asn1 # specify the Asn1API name # lists the encoding rules to be used
asn1API.encodingRules=ExtendedXER, AlignedBasicPER # specify the language (Java or C#)

The generation is launched by the command :

Asn1Compiler sample.arg

The result is :

- compilation in progress...
- # input file : sample.asn1
- 1 ASN.1 module compiled : 0 errors, 0 warnings.

- Java source code generation...
- ASN.1 module : SampleModule
- writing generation...
- source code generation complete (7 files created).

The example showing how to use the generated API is provided here.