1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public License Version
5
* 1.1 (the "License"); you may not use this file except in compliance with
6
* the License. You may obtain a copy of the License at
7
* http://www.mozilla.org/MPL/
9
* Software distributed under the License is distributed on an "AS IS" basis,
10
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
* for the specific language governing rights and limitations under the
14
* The Original Code is the Netscape security libraries.
16
* The Initial Developer of the Original Code is
17
* Netscape Communications Corporation.
18
* Portions created by the Initial Developer are Copyright (C) 1994-2000
19
* the Initial Developer. All Rights Reserved.
23
* Alternatively, the contents of this file may be used under the terms of
24
* either the GNU General Public License Version 2 or later (the "GPL"), or
25
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
* in which case the provisions of the GPL or the LGPL are applicable instead
27
* of those above. If you wish to allow use of your version of this file only
28
* under the terms of either the GPL or the LGPL, and not to allow others to
29
* use your version of this file under the terms of the MPL, indicate your
30
* decision by deleting the provisions above and replace them with the notice
31
* and other provisions required by the GPL or the LGPL. If you do not delete
32
* the provisions above, a recipient may use your version of this file under
33
* the terms of any one of the MPL, the GPL or the LGPL.
35
* ***** END LICENSE BLOCK ***** */
40
* secdert.h - public data structures for the DER encoding and
41
* decoding utilities library
43
* $Id: secdert.h,v 1.2 2004/04/25 15:03:18 gerv%gerv.net Exp $
46
typedef struct DERTemplateStr DERTemplate;
49
** An array of these structures defines an encoding for an object using DER.
50
** The array usually starts with a dummy entry whose kind is DER_SEQUENCE;
51
** such an array is terminated with an entry where kind == 0. (An array
52
** which consists of a single component does not require a second dummy
53
** entry -- the array is only searched as long as previous component(s)
56
struct DERTemplateStr {
58
** Kind of item being decoded/encoded, including tags and modifiers.
63
** Offset from base of structure to field that holds the value
64
** being decoded/encoded.
69
** When kind suggests it (DER_POINTER, DER_INDEFINITE, DER_INLINE),
70
** this points to a sub-template for nested encoding/decoding.
75
** Argument value, dependent on "kind" and/or template placement
76
** within an array of templates:
77
** - In the first element of a template array, the value is the
78
** size of the structure to allocate when this template is being
79
** referenced by another template via DER_POINTER or DER_INDEFINITE.
80
** - In a component of a DER_SET or DER_SEQUENCE which is *not* a
81
** DER_UNIVERSAL type (that is, it has a class tag for either
82
** DER_APPLICATION, DER_CONTEXT_SPECIFIC, or DER_PRIVATE), the
83
** value is the underlying type of item being decoded/encoded.
88
/************************************************************************/
90
/* default chunksize for arenas used for DER stuff */
91
#define DER_DEFAULT_CHUNKSIZE (2048)
94
** BER/DER values for ASN.1 identifier octets.
96
#define DER_TAG_MASK 0xff
99
* BER/DER universal type tag numbers.
100
* The values are defined by the X.208 standard; do not change them!
101
* NOTE: if you add anything to this list, you must add code to derdec.c
102
* to accept the tag, and probably also to derenc.c to encode it.
104
#define DER_TAGNUM_MASK 0x1f
105
#define DER_BOOLEAN 0x01
106
#define DER_INTEGER 0x02
107
#define DER_BIT_STRING 0x03
108
#define DER_OCTET_STRING 0x04
109
#define DER_NULL 0x05
110
#define DER_OBJECT_ID 0x06
111
#define DER_SEQUENCE 0x10
113
#define DER_PRINTABLE_STRING 0x13
114
#define DER_T61_STRING 0x14
115
#define DER_IA5_STRING 0x16
116
#define DER_UTC_TIME 0x17
117
#define DER_VISIBLE_STRING 0x1a
118
#define DER_HIGH_TAG_NUMBER 0x1f
121
** Modifiers to type tags. These are also specified by a/the
122
** standard, and must not be changed.
125
#define DER_METHOD_MASK 0x20
126
#define DER_PRIMITIVE 0x00
127
#define DER_CONSTRUCTED 0x20
129
#define DER_CLASS_MASK 0xc0
130
#define DER_UNIVERSAL 0x00
131
#define DER_APPLICATION 0x40
132
#define DER_CONTEXT_SPECIFIC 0x80
133
#define DER_PRIVATE 0xc0
136
** Our additions, used for templates.
137
** These are not defined by any standard; the values are used internally only.
138
** Just be careful to keep them out of the low 8 bits.
140
#define DER_OPTIONAL 0x00100
141
#define DER_EXPLICIT 0x00200
142
#define DER_ANY 0x00400
143
#define DER_INLINE 0x00800
144
#define DER_POINTER 0x01000
145
#define DER_INDEFINITE 0x02000
146
#define DER_DERPTR 0x04000
147
#define DER_SKIP 0x08000
148
#define DER_FORCE 0x10000
149
#define DER_OUTER 0x40000 /* for DER_DERPTR */
152
** Macro to convert der decoded bit string into a decoded octet
153
** string. All it needs to do is fiddle with the length code.
155
#define DER_ConvertBitString(item) \
157
(item)->len = ((item)->len + 7) >> 3; \
160
extern DERTemplate SECAnyTemplate[];
161
extern DERTemplate SECBitStringTemplate[];
162
extern DERTemplate SECBooleanTemplate[];
163
extern DERTemplate SECIA5StringTemplate[];
164
extern DERTemplate SECIntegerTemplate[];
165
extern DERTemplate SECNullTemplate[];
166
extern DERTemplate SECObjectIDTemplate[];
167
extern DERTemplate SECOctetStringTemplate[];
168
extern DERTemplate SECPrintableStringTemplate[];
169
extern DERTemplate SECT61StringTemplate[];
170
extern DERTemplate SECUTCTimeTemplate[];
171
extern DERTemplate SECAlgorithmIDTemplate[];
173
#endif /* _SECDERT_H_ */