]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_keychain/libDER/libDER/libDER.h
b17e4ba3740ab0711f8dff0369861d949a1b92d9
[apple/security.git] / OSX / libsecurity_keychain / libDER / libDER / libDER.h
1 /*
2 * Copyright (c) 2005-2007,2011,2014 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24
25 /*
26 * libDER.h - main header for libDER, a ROM-capable DER decoding library.
27 *
28 */
29
30 #ifndef _LIB_DER_H_
31 #define _LIB_DER_H_
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #include <libDER/libDER_config.h>
38 /*
39 * Error returns generated by this library.
40 */
41 typedef enum {
42 DR_Success,
43 DR_EndOfSequence, /* end of sequence or set */
44 DR_UnexpectedTag, /* unexpected tag found while decoding */
45 DR_DecodeError, /* misc. decoding error (badly formatted DER) */
46 DR_Unimplemented, /* function not implemented in this configuration */
47 DR_IncompleteSeq, /* incomplete sequence */
48 DR_ParamErr, /* incoming parameter error */
49 DR_BufOverflow /* buffer overflow */
50 /* etc. */
51 } DERReturn;
52
53 /*
54 * The structure of a sequence during decode or encode is expressed as
55 * an array of DERItemSpecs. While decoding or encoding a sequence,
56 * each item in the sequence corresponds to one DERItemSpec.
57 */
58 typedef struct {
59 DERSize offset; /* offset of destination DERItem */
60 DERTag tag; /* DER tag */
61 DERShort options; /* DER_DEC_xxx or DER_ENC_xxx */
62 } DERItemSpec;
63
64 /*
65 * Macro to obtain offset of a DERDecodedInfo within a struct.
66 * FIXME this is going to need reworking to avoid compiler warnings
67 * on 64-bit compiles. It'll work OK as long as an offset can't be larger
68 * than a DERSize, but the cast from a pointer to a DERSize may
69 * provoke compiler warnings.
70 */
71 #define DER_OFFSET(type, field) ((DERSize)(&((type *)0)->field))
72
73 #ifdef __cplusplus
74 }
75 #endif
76
77 #endif /* _LIB_DER_H_ */
78