2 * Copyright (C) 2006 Martin Will
3 * Copyright (C) 2000-2008 Andreas Steffen
5 * Hochschule fuer Technik Rapperswil
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * $Id: asn1.h 3776 2008-04-07 10:37:14Z martin $
21 * @defgroup asn1_parser asn1_parser
25 #ifndef ASN1_PARSER_H_
26 #define ASN1_PARSER_H_
33 * Definition of ASN1 flags
35 #define ASN1_NONE 0x00
38 #define ASN1_LOOP 0x04
41 #define ASN1_BODY 0x20
44 typedef struct asn1Object_t asn1Object_t
;
47 * Syntax definition of an ASN.1 object
56 typedef struct asn1_parser_t asn1_parser_t
;
59 * Public interface of an ASN.1 parser
61 struct asn1_parser_t
{
64 * Parse the next ASN.1 object in the hierarchy and return it
66 * @param objectID current line in the object syntax definition
67 * @param object current object
68 * @return - FALSE if end of object syntax definition was reached
69 * or a parsing error occurred
72 bool (*iterate
)(asn1_parser_t
*this, int *objectID
, chunk_t
*object
);
75 * Get the current parsing level
77 * @return current level
79 u_int (*get_level
)(asn1_parser_t
*this);
82 * Set the top-most level
84 * @param level top-most level
86 void (*set_top_level
)(asn1_parser_t
*this, u_int level0
);
89 * Set implicit and private flags
91 * @param implicit top-most type of object is implicit
92 * @param private object data is private (use debug level 4)
94 void (*set_flags
)(asn1_parser_t
*this, bool implicit
, bool private);
97 * Show final parsing status
99 * @return TRUE if parsing was successful, FALSE otherwise
101 bool (*success
)(asn1_parser_t
*this);
104 * Destroy the ASN.1 parser
106 void (*destroy
)(asn1_parser_t
*this);
110 * Create an ASN.1 parser
112 * @param objects syntax definition of the ASN.1 object to be parsed
113 * @param roof number of syntax definition lines
114 * @param blob ASN.1 coded binary blob
115 * @return ASN.1 context
117 asn1_parser_t
* asn1_parser_create(asn1Object_t
const *objects
, int roof
, chunk_t blob
);
119 #endif /* ASN1_PARSER_H_ @}*/