2 \usepackage{fancyheadings
}
4 \newcommand{\HRule}{\rule{\linewidth}{0.4mm
}}
8 {\Large{ASN
.1 structures parser
}}
15 This is part of the GnuTLS project\\
22 Copyright
\copyright\
2001,
2002,
2003 Fabio Fiorina\\
23 \setlength{\parskip}{4mm
}
25 Permission is granted to copy, distribute and/or modify this
26 document under the terms of the GNU Free Documentation License,
27 Version
1.1 or any later version published by the Free Software
28 Foundation; with no Invariant Sections, no Front-Cover Texts and
29 no Back-Cover Texts. A copy of the license is included in the
30 chapter entitled "GNU Free Documentation License".
33 \setlength{\parindent}{2mm
}
35 \setlength{\parskip}{1mm
}
39 \chapter{ASN
.1 structures handling
}
41 \section{Introduction
}
42 This
document describes the version
0.2.0 of library 'libtasn1' developed
43 for ASN1 (Abstract Syntax Notation One) structures management.
44 The main features of this library are:
46 \item on line ASN1 structure management that doesn't require any
47 C code file generation.
48 \item off line ASN1 structure management with C code file generation
50 \item DER (Distinguish Encoding Rules) encoding
51 \item no limits for INTEGER and ENUMERATED values
55 \section{ASN
.1 syntax
}
56 The parser is case sensitive. The comments begin with "-- " and end at the end of lines.
57 An example is in "pkix.asn" file.
58 ASN
.1 definitions must have this syntax:
61 definitions_name
{<object definition>
}
63 DEFINITIONS <EXPLICIT or IMPLICIT> TAGS ::=
67 <type and constants definitions>
73 The token "::=" must be separate from others elements, so this is a wrong declaration:
75 the correct one is : Version ::= INTEGER
76 Here is the list of types that the parser can manage:
82 \item OBJECT IDENTIFIER
98 This version doesn't manage REAL type. It doesn't allow the
99 "EXPORT" and "IMPORT" sections too.
101 The SIZE constraints are allowed, but no check is done on them.
106 With this definitions:
111 DEFINITIONS EXPLICIT TAGS ::=
116 id OBJECT IDENTIFIER,
128 to identify the type 'Group' you have to use the null terminated string "Example.Group".
130 Field 'id' in 'Group' type : "Example.Group.id"
131 Field 'value1' in field 'value' in type 'Group': "Example.Group.value.value1"
132 These strings are used in functions that are described below.
133 Elements of structured types that don't have a name, receive the name "?
1","?
2", and so on.
134 The name "?LAST" indicates the last element of a SET
\_OF or SEQUENCE
\_OF.
136 \section{Library Notes
}
137 The header file of this library is libtasn1.h .
138 The main type used in it is ASN1
\_TYPE, and it's used to
139 store the ASN1 definitions and structures (instances).
140 The constant ASN1
\_TYPE\_EMPTY can be used for the variable initialization.
142 Example: ASN1
\_TYPE definitions=ASN1
\_TYPE\_EMPTY;
144 Some functions require a parameter named errorDescription of char* type.
145 The array must be already allocated and must have at least
146 MAX
\_ERROR\_DESCRIPTION\_SIZE bytes
147 (E.g: char Description
[MAX
\_ERROR\_DESCRIPTION\_SIZE];).
149 MAX
\_NAME\_SIZE indicates the maximum number of characters of a name inside
150 a file with ASN1 definitions.
152 \section{Future developments
}
154 \item add functions for a C code file generation containing equivalent
155 data structures (not a single array like now).
163 asn1Parser reads one file with ASN1 definitions and generates a file
164 with an array to use with libasn1 functions.
166 Usage: asn1Parser
[options
] file
170 \item -h : shows the help message.
171 \item -v : shows version information and exit.
172 \item -c : checks the syntax only.
173 \item -o file : output file.
174 \item -n name : array name.
179 asn1Coding generates a DER encoding from a file with ASN1 definitions
180 and another one with assignments.
181 The file with assignments must have this syntax:
183 InstanceName Asn1Definition
191 The output file is a binary file with the DER encoding.
193 Usage: asn1Coding
[options
] file1 file2
195 \item file1 : file with ASN1 definitions.
196 \item file2 : file with assignments.
202 \item -h : shows the help message.
203 \item -v : shows version information and exit.
204 \item -c : checks the syntax only.
205 \item -o file : output file.
208 \section{asn1Decoding
}
209 asn1Decoding generates an ASN1 structure from a file with ASN1 definitions
210 and a binary file with a DER encoding.
212 Usage: asn1Decoding
[options
] file1 file2 type
214 \item file1 : file with ASN1 definitions.
215 \item file2 : binary file with a DER encoding.
216 \item type : ASN1 definition name.
223 \item -h : shows the help message.
224 \item -v : shows version information and exit.
225 \item -c : checks the syntax only.
226 \item -o file : output file.
229 \chapter{Function reference
}