Getting Started with ASN.1 SDK

The ASN.1 SDK provides a unified command-line workflow for compiling ASN.1 specifications into source code for C, C++, Java, C#, and Go. This guide walks through installation, licensing, project setup, compilation, and integrating generated code into your build.

1. Installation

The SDK requires Java 21 or later. Download the SDK archive from the Downloads page and unpack it:

unzip asn1-sdk-3.14.15.zip
cd asn1-sdk-3.14.15

The distribution contains the asndt CLI, core library, and compiler plugins:

bin/
  asndt.sh    # Linux/macOS
  asndt.bat   # Windows
lib/
  core/       # SDK core JAR
  plugins/    # Compiler plugin JARs

Add the bin/ directory to your PATH so you can invoke asndt from any directory:

export PATH=/path/to/asn1-sdk-3.14.15/bin:$PATH   # Linux/macOS
:: Windows: add bin\ directory to your system PATH

2. Activate a License

Request an evaluation license from the Free Trial page, or purchase a permanent license. Once you have a license key, activate it interactively:

asndt license

Choose Activate license, select your compiler target, and paste the key. Licenses are stored in your user profile and apply to all projects.

3. Create a Project

Create a new ASN.1 project skeleton:

asndt create MyProject

This creates:

MyProject/
  asn1.avn    # Project configuration
  src/        # Place ASN.1 source files here
  build/      # Generated output

4. The MyHTTP Example

Save the following ASN.1 module as MyProject/src/MyHTTP.asn. This example is adapted from W3C HTTP-NG:

MyHTTP DEFINITIONS
AUTOMATIC TAGS ::=
BEGIN
   GetRequest ::= SEQUENCE {
      header-only   BOOLEAN,
      lock          BOOLEAN,
      accept-types  AcceptTypes,
      url           Url,
      ...,
      timestamp     GeneralizedTime
   }
   AcceptTypes ::= SET {
      standards   BIT STRING { html(0), plain-text(1), gif(2), jpeg(3) } (SIZE(4)) OPTIONAL,
      others      SEQUENCE OF VisibleString (SIZE(4)) OPTIONAL
   }
   Url ::= VisibleString (FROM("a".."z"|"A".."Z"|"0".."9"|"./-_~%#"))
   myRequest GetRequest ::= {
      header-only  TRUE,
      lock         FALSE,
      accept-types {
         standards { html, plain-text }
      },
      url          "www.asnlab.org",
      timestamp    "20121221121221Z"
   }
END

5. Configure and Compile

Edit MyProject/asn1.avn to enable your compiler targets. The compile command is the same for all languages:

asndt compile MyProject

Select a language tab below for the full configuration syntax, available options, and how to integrate the generated code into your project.

6. Understanding the Output

All language targets produce the same BER-encoded bytes for the MyHTTP example. Run the program and you should see:

30 2D 80 01 FF 81 01 00 A2 04 80 02 04 C0 83 0E 77 77 77 2E 61 73 6E 6C 61 62 2E 6F 72 67 84 0F 32 30 31 32 31 32 32 31 31 32 31 32 32 31 5A

Here is a breakdown of each byte:

Bytes Field Explanation
30 2D GetRequest (SEQUENCE) 0x30 = UNIVERSAL CONSTRUCTED 16 (SEQUENCE), length 45
80 01 FF header_only (BOOLEAN) 0x80 = CONTEXT PRIMITIVE 0, length 1, value TRUE (0xFF)
81 01 00 lock (BOOLEAN) 0x81 = CONTEXT PRIMITIVE 1, length 1, value FALSE (0x00)
A2 04 accept_types (SET) 0xA2 = CONTEXT CONSTRUCTED 2, length 4
80 02 04 C0 standards (BIT STRING) 0x80 = CONTEXT PRIMITIVE 0, length 2, 4 unused bits (0x04), bits {html, plain_text} (0xC0 = 1100 0000)
83 0E 77 77... url (VisibleString) 0x83 = CONTEXT PRIMITIVE 3, length 14, ASCII "www.asnlab.org"
84 0F 32 30... timestamp (GeneralizedTime) 0x84 = CONTEXT PRIMITIVE 4, length 15, ASCII "20121221121221Z"

Because we used AUTOMATIC TAGS, each component is tagged with a context-specific tag matching its position in the SEQUENCE (0, 1, 2, 3, 4). The constructed SET (0xA2) wraps the optional accept_types component, and the BIT STRING within it uses a nested context tag 0.

7. Decoding (Roundtrip)

Encoding is only half the story. To verify your data survives a roundtrip, decode the bytes back into a message and compare the fields. All language targets support this pattern:

Next Steps

Explore Compilers

See all supported languages and their features.

Download Runtime

Get the runtime library for your target language.

Start Free Trial

Request an evaluation license and try it yourself.

If you encounter any issues, contact our support team at sales@asnlab.org.