]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_keychain/libDER/libDER/libDER_config.h
976af6c0efcebc3a19a72dbee06a70d0de0199c3
[apple/security.git] / OSX / libsecurity_keychain / libDER / libDER / libDER_config.h
1 /*
2 * Copyright (c) 2005-2007,2011-2012,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_config.h - platform dependent #defines and typedefs for libDER
27 *
28 */
29
30 #ifndef _LIB_DER_CONFIG_H_
31 #define _LIB_DER_CONFIG_H_
32
33 #include <stdint.h>
34 #include <string.h>
35
36 /* include defintion of DERSize and DERByte */
37 #include "libDER/oids.h"
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /*
44 * Basic data types: unsigned 8-bit integer, unsigned 32-bit integer
45 */
46 typedef uint16_t DERShort;
47
48
49 /*
50 * Use these #defines of you have memset, memmove, and memcmp; else
51 * write your own equivalents.
52 */
53
54 #define DERMemset(ptr, c, len) memset(ptr, c, len)
55 #define DERMemmove(dst, src, len) memmove(dst, src, len)
56 #define DERMemcmp(b1, b2, len) memcmp(b1, b2, len)
57
58
59 /***
60 *** Compile time options to trim size of the library.
61 ***/
62
63 /* enable general DER encode */
64 #define DER_ENCODE_ENABLE 1
65
66 /* enable general DER decode */
67 #define DER_DECODE_ENABLE 1
68
69 #ifndef DER_MULTIBYTE_TAGS
70 /* enable multibyte tag support. */
71 #define DER_MULTIBYTE_TAGS 1
72 #endif
73
74 #ifndef DER_TAG_SIZE
75 /* Iff DER_MULTIBYTE_TAGS is 1 this is the sizeof(DERTag) in bytes. Note that
76 tags are still encoded and decoded from a minimally encoded DER
77 represantation. This value determines how big each DERItemSpecs is, we
78 choose 2 since that makes DERItemSpecs 8 bytes wide. */
79 #define DER_TAG_SIZE 2
80 #endif
81
82
83 /* ---------------------- Do not edit below this line ---------------------- */
84
85 /*
86 * Logical representation of a tag (the encoded representation is always in
87 * the minimal number of bytes). The top 3 bits encode class and method
88 * The remaining bits encode the tag value. To obtain smaller DERItemSpecs
89 * sizes, choose the smallest type that fits your needs. Most standard ASN.1
90 * usage only needs single byte tags, but ocasionally custom applications
91 * require a larger tag namespace.
92 */
93 #if DER_MULTIBYTE_TAGS
94
95 #if DER_TAG_SIZE == 1
96 typedef uint8_t DERTag;
97 #elif DER_TAG_SIZE == 2
98 typedef uint16_t DERTag;
99 #elif DER_TAG_SIZE == 4
100 typedef uint32_t DERTag;
101 #elif DER_TAG_SIZE == 8
102 typedef uint64_t DERTag;
103 #else
104 #error DER_TAG_SIZE invalid
105 #endif
106
107 #else /* DER_MULTIBYTE_TAGS */
108 typedef DERByte DERTag;
109 #endif /* !DER_MULTIBYTE_TAGS */
110
111 #ifdef __cplusplus
112 }
113 #endif
114
115 #endif /* _LIB_DER_CONFIG_H_ */