]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_keychain/libDER/libDER/libDER.h
e5e4b127b387861553978c0196addf7f5354b373
[apple/security.git] / OSX / libsecurity_keychain / libDER / libDER / libDER.h
1 /*
2 * Copyright (c) 2005-2016 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 #include <libDER/libDER_config.h>
34
35 __BEGIN_DECLS
36
37 /*
38 * Error returns generated by this library.
39 */
40 typedef enum {
41 DR_Success = 0,
42 DR_EndOfSequence, /* end of sequence or set */
43 DR_UnexpectedTag, /* unexpected tag found while decoding */
44 DR_DecodeError, /* misc. decoding error (badly formatted DER) */
45 DR_Unimplemented, /* function not implemented in this configuration */
46 DR_IncompleteSeq, /* incomplete sequence */
47 DR_ParamErr, /* incoming parameter error */
48 DR_BufOverflow /* buffer overflow */
49 /* etc. */
50 } DERReturn;
51
52 /*
53 * The structure of a sequence during decode or encode is expressed as
54 * an array of DERItemSpecs. While decoding or encoding a sequence,
55 * each item in the sequence corresponds to one DERItemSpec.
56 */
57 typedef struct {
58 DERSize offset; /* offset of destination DERItem */
59 DERTag tag; /* DER tag */
60 DERShort options; /* DER_DEC_xxx or DER_ENC_xxx */
61 } DERItemSpec;
62
63 /*
64 * Macro to obtain offset of a DERDecodedInfo within a struct.
65 * FIXME this is going to need reworking to avoid compiler warnings
66 * on 64-bit compiles. It'll work OK as long as an offset can't be larger
67 * than a DERSize, but the cast from a pointer to a DERSize may
68 * provoke compiler warnings.
69 */
70 #define DER_OFFSET(type, field) ((DERSize)(&((type *)0)->field))
71
72 __END_DECLS
73
74 #endif /* _LIB_DER_H_ */
75