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
43 #define ASN1_EXIT 0x80
45 typedef struct asn1Object_t asn1Object_t
;
48 * Syntax definition of an ASN.1 object
57 typedef struct asn1_parser_t asn1_parser_t
;
60 * Public interface of an ASN.1 parser
62 struct asn1_parser_t
{
65 * Parse the next ASN.1 object in the hierarchy and return it
67 * @param objectID current line in the object syntax definition
68 * @param object current object
69 * @return - FALSE if end of object syntax definition was reached
70 * or a parsing error occurred
73 bool (*iterate
)(asn1_parser_t
*this, int *objectID
, chunk_t
*object
);
76 * Get the current parsing level
78 * @return current level
80 u_int (*get_level
)(asn1_parser_t
*this);
83 * Set the top-most level
85 * @param level top-most level
87 void (*set_top_level
)(asn1_parser_t
*this, u_int level0
);
90 * Set implicit and private flags
92 * @param implicit top-most type of object is implicit
93 * @param private object data is private (use debug level 4)
95 void (*set_flags
)(asn1_parser_t
*this, bool implicit
, bool private);
98 * Show final parsing status
100 * @return TRUE if parsing was successful, FALSE otherwise
102 bool (*success
)(asn1_parser_t
*this);
105 * Destroy the ASN.1 parser
107 void (*destroy
)(asn1_parser_t
*this);
111 * Create an ASN.1 parser
113 * @param objects syntax definition of the ASN.1 object to be parsed
114 * @param blob ASN.1 coded binary blob
115 * @return ASN.1 context
117 asn1_parser_t
* asn1_parser_create(asn1Object_t
const *objects
, chunk_t blob
);
119 #endif /* ASN1_PARSER_H_ @}*/