1 \input texinfo @c -*-texinfo-*-
2 @comment %**start of header
3 @setfilename libtasn1.info
5 @settitle GNU Libtasn1 @value{VERSION}
7 @c Unify some of the indices.
11 @comment %**end of header
13 This manual is for GNU Libtasn1
14 (version @value{VERSION}, @value{UPDATED}),
15 which is a library for Abstract Syntax Notation One (ASN.1) and
16 Distinguish Encoding Rules (DER) manipulation.
18 Copyright @copyright{} 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
21 Permission is granted to copy, distribute and/or modify this document
22 under the terms of the GNU Free Documentation License, Version 1.3 or
23 any later version published by the Free Software Foundation; with no
24 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
25 copy of the license is included in the section entitled ``GNU Free
26 Documentation License''.
30 @dircategory Software libraries
32 * libtasn1: (libtasn1). Library for Abstract Syntax Notation One (ASN.1).
37 @subtitle Abstract Syntax Notation One (ASN.1) library for the GNU system
38 @subtitle for version @value{VERSION}, @value{UPDATED}
40 @author Simon Josefsson (@email{bug-gnutls@@gnu.org})
42 @vskip 0pt plus 1filll
57 * ASN.1 structure handling::
59 * Function reference::
60 * Copying Information::
64 * Concept Index:: Index of concepts and programs.
65 * Function and Data Index:: Index of functions, variables and data types.
71 This document describes the Libtasn1 library developed for ASN.1
72 (Abstract Syntax Notation One) structures management and DER
73 (Distinguished Encoding Rules) encoding functions.
75 The main features of this library are:
79 @item On line ASN1 structure management that doesn't require any
80 C code file generation.
82 @item Off line ASN1 structure management with C code file generation
85 @item DER (Distinguish Encoding Rules) encoding.
87 @item No limits for INTEGER and ENUMERATED values.
89 @item It's Free Software.
90 Anybody can use, modify, and redistribute the library under the terms
91 of the GNU Lesser General Public License version 2.1 or later. The
92 command line tools, self-tests and build infrastructure are licensed
93 under the GNU General Public License version 3.0 or later.
95 @item It's thread-safe.
97 No global variables are used and multiple library handles and session
98 handles may be used in parallel.
102 It should work on all Unix like operating systems, including Windows.
103 The library itself should be portable to any C89 system, not even
107 @node ASN.1 structure handling
108 @chapter ASN.1 structure handling
114 * Future developments::
118 @section ASN.1 syntax
122 The parser is case sensitive. The comments begin with "-- " and end at
123 the end of lines. An example is in "pkix.asn" file. ASN.1
124 definitions must have this syntax:
127 definitions_name {<object definition>}
129 DEFINITIONS <EXPLICIT or IMPLICIT> TAGS ::=
133 <type and constants definitions>
138 The token "::=" must be separate from others elements, so this is a
152 Here is the list of types that the parser can manage:
154 @cindex Supported ASN.1 types, list of
161 @item OBJECT IDENTIFIER
166 @item GeneralizedTime
178 This version doesn't manage REAL type. It doesn't allow the "EXPORT"
179 and "IMPORT" sections too.
181 The SIZE constraints are allowed, but no check is done on them.
186 Consider this definition:
191 DEFINITIONS EXPLICIT TAGS ::=
196 id OBJECT IDENTIFIER,
208 To identify the type 'Group' you have to use the null terminated
209 string "Example.Group". These strings are used in functions that are
214 Field 'id' in 'Group' type : "Example.Group.id".
216 Field 'value1' in field 'value' in type 'Group':
217 "Example.Group.value.value1".
219 Elements of structured types that don't have a name, receive the name
220 "?1","?2", and so on.
222 The name "?LAST" indicates the last element of a @code{SET_OF} or
226 @section Library Notes
228 @cindex Header file libtasn1.h
230 The header file of this library is @file{libtasn1.h}.
232 @cindex Main type ASN1_TYPE
234 The main type used in it is @code{ASN1_TYPE}, and it's used to store
235 the ASN.1 definitions and structures (instances).
237 The constant @code{ASN1_TYPE_EMPTY} can be used for the variable
238 initialization. For example:
241 ASN1_TYPE definitions=ASN1_TYPE_EMPTY;
244 Some functions require a parameter named errorDescription of char*
245 type. The array must be already allocated and must have at least
246 @code{ASN1_MAX_ERROR_DESCRIPTION_SIZE} bytes (E.g, as in @code{char
247 Description[ASN1_MAX_ERROR_DESCRIPTION_SIZE];}).
249 @code{ASN1_MAX_NAME_SIZE} indicates the maximum number of characters of a
250 name inside a file with ASN1 definitions.
252 @node Future developments
253 @section Future developments
254 @cindex Future developments
258 @item Add functions for a C code file generation containing equivalent
259 data structures (not a single array like now).
269 * Invoking asn1Parser::
270 * Invoking asn1Coding::
271 * Invoking asn1Decoding::
274 @node Invoking asn1Parser
275 @section Invoking asn1Parser
276 @cindex asn1Parser program
278 @file{asn1Parser} reads one file with ASN1 definitions and generates a
279 file with an array to use with libtasn1 functions.
282 Usage: asn1Parser [options] file
285 -h : shows the help message.
286 -v : shows version information and exit.
287 -c : checks the syntax only.
288 -o file : output file.
289 -n name : array name.
292 @node Invoking asn1Coding
293 @section Invoking asn1Coding
294 @cindex asn1Coding program
296 @file{asn1Coding} generates a DER encoding from a file with ASN1
297 definitions and another one with assignments.
299 The file with assignments must have this syntax:
302 InstanceName Asn1Definition
310 The output file is a binary file with the DER encoding.
313 Usage: asn1Coding [options] file1 file2
314 file1 : file with ASN1 definitions.
315 file2 : file with assignments.
317 -h : shows the help message.
318 -v : shows version information and exit.
319 -c : checks the syntax only.
320 -o file : output file.
323 @node Invoking asn1Decoding
324 @section Invoking asn1Decoding
325 @cindex asn1Decoding program
327 @file{asn1Decoding} generates an ASN1 structure from a file with ASN1
328 definitions and a binary file with a DER encoding.
331 Usage: asn1Decoding [options] file1 file2 type
332 file1 : file with ASN1 definitions.
333 file2 : binary file with a DER encoding.
334 type : ASN1 definition name.
336 -h : shows the help message.
337 -v : shows version information and exit.
338 -c : checks the syntax only.
339 -o file : output file.
342 @node Function reference
343 @chapter Function reference
346 * ASN.1 schema functions::
347 * ASN.1 field functions::
349 * Error handling functions::
350 * Auxilliary functions::
353 @node ASN.1 schema functions
354 @section ASN.1 schema functions
356 @include texi/ASN1.c.texi
358 @node ASN.1 field functions
359 @section ASN.1 field functions
361 @include texi/structure.c.texi
362 @include texi/element.c.texi
365 @section DER functions
367 @include texi/coding.c.texi
368 @include texi/decoding.c.texi
370 @node Error handling functions
371 @section Error handling functions
373 @include texi/errors.c.texi
375 @node Auxilliary functions
376 @section Auxilliary functions
378 @include texi/parser_aux.c.texi
379 @include texi/version.c.texi
381 @node Copying Information
382 @appendix Copying Information
385 * GNU Free Documentation License:: License for copying this manual.
388 @node GNU Free Documentation License
389 @appendixsec GNU Free Documentation License
391 @cindex FDL, GNU Free Documentation License
393 @include fdl-1.3.texi
396 @unnumbered Concept Index
400 @node Function and Data Index
401 @unnumbered Function and Data Index