Using ASN.1 (Abstract Syntax Notation 1): A Data Description Language*

Published in Probe Volume 2(2): Summer 1992

James Ostell
National Center of Biotechnology Information (NCBI)
National Library of Medicine
National Institutes of Health
Bethesda, MD

Abstract Syntax Notation 1 (ASN.1) is used to describe the structure of data to be transferred between the Application Layer and the Presentation Layer of the Open Systems Interconnection (OSI) (next generation networking protocol).

ASN.1 is meant to provide a mechanism whereby the Presentation Layer can use a single standard encoding to reliably exchange any arbitrary data structure with other computer systems, while the Application Layer can map the standard encoding into any type of representation or language that is appropriate for the end user. ASN.1 does not describe the content, meaning, or structure of the data, only the way in which it is specified and encoded.

These properties make it an excellent choice for a standard way of encoding scientific data. Since ASN.1 does not specify content, specifications can be created as new concepts need to be represented. As it is an International Standards Organization (ISO) standard, the new specification can take advantage of various tools built to work with ASN.1 in general. It removes from scientists the role of specifying ad hoc file formats, and focuses them instead on specifying the content and structure of data necessary to convey scientific meaning.

Data Specification

There are two aspects to ASN.1--the specification of the data and the encoded data itself. The specification describes the abstract structure of the data and the allowed values various fields may take. Frequently scientific data is presented with no formal specification. There may be some documentation describing the data file, but very often it is incomplete or not entirely accurate, since it is usually written about the file rather than as a integral step toward building the file.

The ASN.1 specification is formal language, which means it can be automatically and thoroughly checked for errors and inconsistencies in form by machine before any data is collected.

Further, it can be used by a computer to validate that any data presented correctly reflects that specification. This is essential in eliminating the random errors and oversights in generating data files that plague scientific data now.

A utility program, AsnTool, was built at NCBI with the AsnTool libraries to do this sort of checking and validation while developing ASN.1 specifications. (For information on obtaining AsnTool, see the end of the article.)

The requirement for a separate specification also means that interested parties can examine and evaluate the structure of the data independent of any particular database or data file. One can understand the limits and strengths of a specification separately from the quality or amount of the data itself. Data structures that prove to be useful can be re-used in a variety of ways--by large public databases, by small private databases, in various software tools, and in assorted data files.

Finally, a separate specification means software to construct, decode, and validate any AS.1 specified object can be built fully or semi-automatically from the specification. Data encoded according to that specification can then be processed with relatively little manual programming for those aspects of the application dealing directly with ASN.1. This is the purpose of the AsnTool routines.

Commercial Tools

A number of commercial and public domain tools are available for working with ASN.1 and for automatically building data handlers of various sorts. They are focused on the use for which ASN.1 was originally intended, the exchange of data between layers of the OSI. As such they tend to automate the process more that AsnTool does, because the domain of use is more limited. The fact that they determine the internal data structures to use and write all the code to handle them themselves is not a big problem in this case.

When ASN.1 is used for scientific data description, however, other uses will be made of the encoded data than may have originally been envisaged by the designers of these products. For example, a scientist will often want an application which scans through a large complicated data structure and extracts certain fields for use, or even just counts occurrences of certain values. A tool that automatically generates large elaborate data structures and lots of code to parse the stream, generate the structures, and store them in memory is inappropriate for such an application. Further, a scientific application may well wish to manipulate that data in a different language than the tool is written in, such as FORTRAN, PROLOG, or LISP. These applications may well wish to store the whole data structure from the stream, but they will not wish to use the data structure provided by the tool.


ASN.1 can be used to encode data in two ways, an ASCII human readable form called "value notation" or "print form," a binary encoding. ASN.1 has separate standards documents for the syntax (specification rules) and the binary encoding rules (BER, or "Basic Encoding Rules"). This was done on purpose to allow various encoding rules for the same abstract syntax. The BER is, at this writing, the only official ISO encoding for ASN.1, but several other encodings which are faster or take less space, are under consideration by ISO. Currently the only binary encoding AsnTool supports is BER.

The value notation, or ASCII form of the data, is not really an official ISO standard. It was meant to provide a human readable form of ASN.1 data for development or explication, but not as a standard for data exchange. Nonetheless, value notation is quite robust for data exchange. These rules are listed in appendix 1.

While we do not recommend the ASCII form of ASN.1 encoded data for large amounts of data, it is useful for developing and testing data representations or for easily generating ASN.1 values from other data files or local databases without specialized tools. Since the value notation and binary encoded forms of data are completely and reliably interconvertible using AsnTool, there is no problem doing this.

Ordering Information

AsnTool is available for anonymous ftp from as /toolbox/ncbi_tools/ncbi.tar.Z.
If you have questions or comments about AsnTool, you may send an E-mail request to (Internet), or write to the following address: AsnTool, National Center for Biotechnology Information, Building 38A, NIH, 8600 Rockville Pike, Bethesda, MD 20894.


The Open Book A Practical Perspective on OSI by Marshall T. Rose Prentice Hall, Englewood Cliffs, New Jersey 07632 (c) 1990

ISO Development Environment (public software) University of Pennsylvania Department of Computer Science and Information Science

Moore School, Attn: David J. Farber (ISODE Distribution) 200 South 33rd Street Philadelphia, PA 19104-6314

OSIkit Tools for NIST (1989) (public software) U.S. Department of Commerce National Institute of Standards and Technology Gaithersburg, MD

Information Processing - Open Systems Interconnection - Specification of Abstract Syntax Notation One (ASN.1). International Organization for Standardization and International Electrotechnical Committee, 1987. International Standard 8824.

Information Processing - Open Systems Interconnection - Specification of Basic Encoding Rules for Abstract Syntax Notation One (ASN.1). International Organization for Standardization and International Electrotechnical Committee, 1987. International Standard 8825.

Information Processing - Open Systems Interconnection - Abstract Syntax Notation One (ASN.1) - Draft Addendum 1: Extensions to ASN.1. International Organization for Standardization and International Electrotechnical Committee, 1987. Draft Addendum 8824/DAD 1.

Information Processing - Open Systems Interconnection - Abstract Syntax Notation One (ASN.1) - Draft Addendum 1: Extensions to ASN.1 Basic Encoding Rules. International Organization for Standardization and International Electrotechnical Committee, 1987. Draft Addendum 8825/DAD 1.

*Note to Readers: This article briefly describes ASN.1 but it is not meant to be an explanation or tutorial on ASN.1 itself. Please see the Reference section for such works.