Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / asn1.h
blob50c2e14421f6a5aab194d01bdb5ae87653e2f498
1 /* asn1.h
3 * Some very limited asn.1 support.
4 */
6 /* nettle, low-level cryptographics library
8 * Copyright (C) 2005 Niels Möller
9 *
10 * The nettle library is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or (at your
13 * option) any later version.
15 * The nettle library is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with the nettle library; see the file COPYING.LIB. If not, write to
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 * MA 02111-1301, USA.
26 #ifndef NETTLE_ASN1_H_INCLUDED
27 #define NETTLE_ASN1_H_INCLUDED
29 #include "nettle-types.h"
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
35 /* Name mangling */
36 #define asn1_der_iterator_first nettle_asn1_der_iterator_first
37 #define asn1_der_iterator_next nettle_asn1_der_iterator_next
38 #define asn1_der_decode_constructed nettle_asn1_der_decode_constructed
39 #define asn1_der_decode_constructed_last nettle_asn1_der_decode_constructed_last
40 #define asn1_der_decode_bitstring nettle_asn1_der_decode_bitstring
41 #define asn1_der_decode_bitstring_last nettle_asn1_der_decode_bitstring_last
42 #define asn1_der_get_uint32 nettle_asn1_der_get_uint32
43 #define asn1_der_get_bignum nettle_asn1_der_get_bignum
46 /* enum asn1_type keeps the class number and the constructive in bits
47 13-14, and the constructive flag in bit 12. The remaining 14 bits
48 are the tag (although currently, only tags in the range 0-30 are
49 supported). */
51 enum
53 ASN1_TYPE_CONSTRUCTED = 1 << 12,
55 ASN1_CLASS_UNIVERSAL = 0,
56 ASN1_CLASS_APPLICATION = 1 << 13,
57 ASN1_CLASS_CONTEXT_SPECIFIC = 2 << 13,
58 ASN1_CLASS_PRIVATE = 3 << 13,
60 ASN1_CLASS_MASK = 3 << 13,
61 ASN1_CLASS_SHIFT = 13,
64 enum asn1_type
66 ASN1_BOOLEAN = 1,
67 ASN1_INTEGER = 2,
68 ASN1_BITSTRING = 3,
69 ASN1_OCTETSTRING = 4,
70 ASN1_NULL = 5,
71 ASN1_IDENTIFIER = 6,
72 ASN1_REAL = 9,
73 ASN1_ENUMERATED = 10,
74 ASN1_UTF8STRING = 12,
75 ASN1_SEQUENCE = 16 | ASN1_TYPE_CONSTRUCTED,
76 ASN1_SET = 17 | ASN1_TYPE_CONSTRUCTED,
77 ASN1_PRINTABLESTRING = 19,
78 ASN1_TELETEXSTRING = 20,
79 ASN1_IA5STRING = 22,
80 ASN1_UTC = 23,
81 ASN1_UNIVERSALSTRING = 28,
82 ASN1_BMPSTRING = 30,
85 enum asn1_iterator_result
87 ASN1_ITERATOR_ERROR,
88 ASN1_ITERATOR_PRIMITIVE,
89 ASN1_ITERATOR_CONSTRUCTED,
90 ASN1_ITERATOR_END,
93 /* Parsing DER objects. */
94 struct asn1_der_iterator
96 unsigned buffer_length;
97 const uint8_t *buffer;
99 /* Next object to parse. */
100 unsigned pos;
102 enum asn1_type type;
104 /* Pointer to the current object */
105 unsigned length;
106 const uint8_t *data;
109 /* Initializes the iterator. */
110 enum asn1_iterator_result
111 asn1_der_iterator_first(struct asn1_der_iterator *iterator,
112 unsigned length, const uint8_t *input);
114 enum asn1_iterator_result
115 asn1_der_iterator_next(struct asn1_der_iterator *iterator);
117 /* Starts parsing of a constructed object. */
118 enum asn1_iterator_result
119 asn1_der_decode_constructed(struct asn1_der_iterator *i,
120 struct asn1_der_iterator *contents);
122 /* For the common case that we have a sequence at the end of the
123 object. Checks that the current object is the final one, and then
124 reinitializes the iterator to parse its ontents. */
125 enum asn1_iterator_result
126 asn1_der_decode_constructed_last(struct asn1_der_iterator *i);
128 enum asn1_iterator_result
129 asn1_der_decode_bitstring(struct asn1_der_iterator *i,
130 struct asn1_der_iterator *contents);
132 enum asn1_iterator_result
133 asn1_der_decode_bitstring_last(struct asn1_der_iterator *i);
135 /* All these functions return 1 on success, 0 on failure */
137 asn1_der_get_uint32(struct asn1_der_iterator *i,
138 uint32_t *x);
140 #ifdef __cplusplus
142 #endif
144 #endif /* NETTLE_ASN1_H_INCLUDED */