1 \input texinfo @c -*-texinfo-*-
3 @comment %**start of header
4 @setfilename libtasn1.info
6 @settitle Libtasn1 @value{VERSION}
8 @c Unify some of the indices.
12 @comment %**end of header
14 This manual is for Libtasn1
15 (version @value{VERSION}, @value{UPDATED}),
16 which is a library for Abstract Syntax Notation One (ASN.1) and
17 Distinguish Encoding Rules (DER) manipulation.
19 Copyright @copyright{} 2004 Simon Josefsson
21 Copyright @copyright{} 2001, 2002, 2003 Fabio Fiorina
24 Permission is granted to copy, distribute and/or modify this document
25 under the terms of the GNU Free Documentation License, Version 1.1 or
26 any later version published by the Free Software Foundation; with no
27 Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
28 and with the Back-Cover Texts as in (a) below. A copy of the
29 license is included in the section entitled ``GNU Free Documentation
32 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
33 this GNU Manual, like GNU software. Copies published by the Free
34 Software Foundation raise funds for GNU development.''
38 @dircategory GNU Libraries
40 * libtasn1: (libtasn1). Library for Abstract Syntax Notation One (ASN.1).
45 @subtitle Abstract Syntax Notation One (ASN.1) library for the GNU system
46 @subtitle part of the GnuTLS project
47 @subtitle for version @value{VERSION}, @value{UPDATED}
48 @author Fabio Fiorina (@email{bug-gnutls@@gnu.org})
50 @vskip 0pt plus 1filll
64 * ASN.1 structure handling::
66 * Function reference::
67 * Copying This Manual::
71 * Concept Index:: Index of concepts and programs.
72 * Function and Data Index:: Index of functions, variables and data types.
76 @node ASN.1 structure handling
77 @chapter ASN.1 structure handling
79 This document describes the Libtasn1 library developed for ASN.1
80 (Abstract Syntax Notation One) structures management.
82 The main features of this library are:
86 @item On line ASN1 structure management that doesn't require any
87 C code file generation.
89 @item Off line ASN1 structure management with C code file generation
92 @item DER (Distinguish Encoding Rules) encoding.
94 @item No limits for INTEGER and ENUMERATED values.
96 @item It's Free Software.
97 Anybody can use, modify, and redistribute the library under the terms
98 of the GNU Lesser General Public License.
100 @item It's thread-safe.
102 No global variables are used and multiple library handles and session
103 handles may be used in parallel.
107 It should work on all Unix like operating systems, including Windows.
108 The library itself should be portable to any C89 system, not even
116 * Future developments::
120 @section ASN.1 syntax
124 The parser is case sensitive. The comments begin with "-- " and end at
125 the end of lines. An example is in "pkix.asn" file. ASN.1
126 definitions must have this syntax:
129 definitions_name {<object definition>}
131 DEFINITIONS <EXPLICIT or IMPLICIT> TAGS ::=
135 <type and constants definitions>
140 The token "::=" must be separate from others elements, so this is a
154 Here is the list of types that the parser can manage:
156 @cindex Supported ASN.1 types, list of
163 @item OBJECT IDENTIFIER
168 @item GeneralizedTime
180 This version doesn't manage REAL type. It doesn't allow the "EXPORT"
181 and "IMPORT" sections too.
183 The SIZE constraints are allowed, but no check is done on them.
188 Consider this definition:
193 DEFINITIONS EXPLICIT TAGS ::=
198 id OBJECT IDENTIFIER,
210 To identify the type 'Group' you have to use the null terminated
211 string "Example.Group". These strings are used in functions that are
216 Field 'id' in 'Group' type : "Example.Group.id".
218 Field 'value1' in field 'value' in type 'Group':
219 "Example.Group.value.value1".
221 Elements of structured types that don't have a name, receive the name
222 "?1","?2", and so on.
224 The name "?LAST" indicates the last element of a @code{SET_OF} or
228 @section Library Notes
230 @cindex Header file libtasn1.h
232 The header file of this library is @file{libtasn1.h}.
234 @cindex Main type ASN1_TYPE
236 The main type used in it is @code{ASN1_TYPE}, and it's used to store
237 the @acronym{ASN.1} definitions and structures (instances).
239 The constant @acronym{ASN1_TYPE_EMPTY} can be used for the variable
240 initialization. For example:
243 ASN1_TYPE definitions=ASN1_TYPE_EMPTY;
246 Some functions require a parameter named errorDescription of char*
247 type. The array must be already allocated and must have at least
248 @code{MAX_ERROR_DESCRIPTION_SIZE} bytes (E.g, as in @code{char
249 Description[MAX_ERROR_DESCRIPTION_SIZE];}).
251 @code{MAX_NAME_SIZE} indicates the maximum number of characters of a
252 name inside a file with ASN1 definitions.
254 @node Future developments
255 @section Future developments
256 @cindex Future developments
260 @item Add functions for a C code file generation containing equivalent
261 data structures (not a single array like now).
271 * Invoking asn1Parser::
272 * Invoking asn1Coding::
273 * Invoking asn1Decoding::
276 @node Invoking asn1Parser
277 @section Invoking asn1Parser
278 @cindex asn1Parser program
280 @file{asn1Parser} reads one file with ASN1 definitions and generates a
281 file with an array to use with libasn1 functions.
284 Usage: asn1Parser [options] file
287 -h : shows the help message.
288 -v : shows version information and exit.
289 -c : checks the syntax only.
290 -o file : output file.
291 -n name : array name.
294 @node Invoking asn1Coding
295 @section Invoking asn1Coding
296 @cindex asn1Coding program
298 @file{asn1Coding} generates a DER encoding from a file with ASN1
299 definitions and another one with assignments.
301 The file with assignments must have this syntax:
304 InstanceName Asn1Definition
312 The output file is a binary file with the DER encoding.
315 Usage: asn1Coding [options] file1 file2
316 file1 : file with ASN1 definitions.
317 file2 : file with assignments.
319 -h : shows the help message.
320 -v : shows version information and exit.
321 -c : checks the syntax only.
322 -o file : output file.
325 @node Invoking asn1Decoding
326 @section Invoking asn1Decoding
327 @cindex asn1Decoding program
329 @file{asn1Decoding} generates an ASN1 structure from a file with ASN1
330 definitions and a binary file with a DER encoding.
333 Usage: asn1Decoding [options] file1 file2 type
334 file1 : file with ASN1 definitions.
335 file2 : binary file with a DER encoding.
336 type : ASN1 definition name.
338 -h : shows the help message.
339 -v : shows version information and exit.
340 -c : checks the syntax only.
341 -o file : output file.
344 @node Function reference
345 @chapter Function reference
348 * ASN.1 schema functions::
349 * ASN.1 field functions::
351 * Error handling functions::
352 * Auxilliary functions::
355 @node ASN.1 schema functions
356 @section ASN.1 schema functions
358 @include texi/ASN1.c.texi
360 @node ASN.1 field functions
361 @section ASN.1 field functions
363 @include texi/structure.c.texi
364 @include texi/element.c.texi
367 @section DER functions
369 @include texi/coding.c.texi
370 @include texi/decoding.c.texi
372 @node Error handling functions
373 @section Error handling functions
375 @include texi/errors.c.texi
377 @node Auxilliary functions
378 @section Auxilliary functions
380 @include texi/parser_aux.c.texi
382 @node Copying This Manual
383 @appendix Copying This Manual
386 * GNU Free Documentation License:: License for copying this manual.
393 @unnumbered Concept Index
397 @node Function and Data Index
398 @unnumbered Function and Data Index