]> git.saurik.com Git - apple/security.git/blob - OSX/utilities/der_plist_internal.h
Security-59754.41.1.tar.gz
[apple/security.git] / OSX / utilities / der_plist_internal.h
1 /*
2 * Copyright (c) 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 #ifndef _DER_PLIST_INTERNAL_H_
26 #define _DER_PLIST_INTERNAL_H_
27
28 #include <CoreFoundation/CoreFoundation.h>
29 #include <utilities/SecCFError.h>
30
31 // Always returns false, to satisfy static analysis
32 #define SecCFDERCreateError(errorCode, descriptionString, previousError, newError) \
33 SecCFCreateErrorWithFormat(errorCode, sSecDERErrorDomain, previousError, newError, NULL, descriptionString)
34
35 uint8_t * SecCCDEREncodeHandleResult(uint8_t *der, CFErrorRef *newError);
36
37
38 // CFArray <-> DER
39 size_t der_sizeof_array(CFArrayRef array, CFErrorRef *error);
40
41 uint8_t* der_encode_array(CFArrayRef array, CFErrorRef *error,
42 const uint8_t *der, uint8_t *der_end);
43
44 const uint8_t* der_decode_array(CFAllocatorRef allocator,
45 CFArrayRef* array, CFErrorRef *error,
46 const uint8_t* der, const uint8_t *der_end);
47
48 // CFNull <-> DER
49 size_t der_sizeof_null(CFNullRef nul, CFErrorRef *error);
50
51 uint8_t* der_encode_null(CFNullRef nul, CFErrorRef *error,
52 const uint8_t *der, uint8_t *der_end);
53
54 const uint8_t* der_decode_null(CFAllocatorRef allocator,
55 CFNullRef *nul, CFErrorRef *error,
56 const uint8_t* der, const uint8_t *der_end);
57
58
59 // CFBoolean <-> DER
60 size_t der_sizeof_boolean(CFBooleanRef boolean, CFErrorRef *error);
61
62 uint8_t* der_encode_boolean(CFBooleanRef boolean, CFErrorRef *error,
63 const uint8_t *der, uint8_t *der_end);
64
65 const uint8_t* der_decode_boolean(CFAllocatorRef allocator,
66 CFBooleanRef* boolean, CFErrorRef *error,
67 const uint8_t* der, const uint8_t *der_end);
68
69 // CFData <-> DER
70 size_t der_sizeof_data(CFDataRef data, CFErrorRef *error);
71
72 uint8_t* der_encode_data(CFDataRef data, CFErrorRef *error,
73 const uint8_t *der, uint8_t *der_end);
74
75 const uint8_t* der_decode_data(CFAllocatorRef allocator,
76 CFDataRef* data, CFErrorRef *error,
77 const uint8_t* der, const uint8_t *der_end);
78
79 // CFDate <-> DER
80 size_t der_sizeof_date(CFDateRef date, CFErrorRef *error);
81
82 uint8_t* der_encode_date(CFDateRef date, CFErrorRef *error,
83 const uint8_t *der, uint8_t *der_end);
84
85 uint8_t* der_encode_date_repair(CFDateRef date, CFErrorRef *error,
86 bool repair, const uint8_t *der, uint8_t *der_end);
87
88 const uint8_t* der_decode_date(CFAllocatorRef allocator,
89 CFDateRef* date, CFErrorRef *error,
90 const uint8_t* der, const uint8_t *der_end);
91
92
93 // CFDictionary <-> DER
94 size_t der_sizeof_dictionary(CFDictionaryRef dictionary, CFErrorRef *error);
95
96 uint8_t* der_encode_dictionary(CFDictionaryRef dictionary, CFErrorRef *error,
97 const uint8_t *der, uint8_t *der_end);
98
99 const uint8_t* der_decode_dictionary(CFAllocatorRef allocator,
100 CFDictionaryRef* dictionary, CFErrorRef *error,
101 const uint8_t* der, const uint8_t *der_end);
102
103 // CFNumber <-> DER
104 // Currently only supports signed 64 bit values. No floating point.
105 size_t der_sizeof_number(CFNumberRef number, CFErrorRef *error);
106
107 uint8_t* der_encode_number(CFNumberRef number, CFErrorRef *error,
108 const uint8_t *der, uint8_t *der_end);
109
110 const uint8_t* der_decode_number(CFAllocatorRef allocator,
111 CFNumberRef* number, CFErrorRef *error,
112 const uint8_t* der, const uint8_t *der_end);
113
114 // CFString <-> DER
115 size_t der_sizeof_string(CFStringRef string, CFErrorRef *error);
116
117 uint8_t* der_encode_string(CFStringRef string, CFErrorRef *error,
118 const uint8_t *der, uint8_t *der_end);
119
120 const uint8_t* der_decode_string(CFAllocatorRef allocator,
121 CFStringRef* string, CFErrorRef *error,
122 const uint8_t* der, const uint8_t *der_end);
123
124 // CFSet <-> DER
125 size_t der_sizeof_set(CFSetRef dict, CFErrorRef *error);
126
127 uint8_t* der_encode_set(CFSetRef set, CFErrorRef *error,
128 const uint8_t *der, uint8_t *der_end);
129
130 const uint8_t* der_decode_set(CFAllocatorRef allocator,
131 CFSetRef* set, CFErrorRef *error,
132 const uint8_t* der, const uint8_t *der_end);
133
134 #include <corecrypto/ccder.h>
135 enum {
136 CCDER_CONSTRUCTED_CFSET = CCDER_PRIVATE | CCDER_SET,
137 };
138
139 #endif