]> git.saurik.com Git - apple/security.git/blob - OSX/utilities/src/der_plist_internal.h
Security-58286.1.32.tar.gz
[apple/security.git] / OSX / utilities / src / 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
36 // CFArray <-> DER
37 size_t der_sizeof_array(CFArrayRef array, CFErrorRef *error);
38
39 uint8_t* der_encode_array(CFArrayRef array, CFErrorRef *error,
40 const uint8_t *der, uint8_t *der_end);
41
42 const uint8_t* der_decode_array(CFAllocatorRef allocator, CFOptionFlags mutability,
43 CFArrayRef* array, CFErrorRef *error,
44 const uint8_t* der, const uint8_t *der_end);
45
46 // CFNull <-> DER
47 size_t der_sizeof_null(CFNullRef nul, CFErrorRef *error);
48
49 uint8_t* der_encode_null(CFNullRef nul, CFErrorRef *error,
50 const uint8_t *der, uint8_t *der_end);
51
52 const uint8_t* der_decode_null(CFAllocatorRef allocator, CFOptionFlags mutability,
53 CFNullRef *nul, CFErrorRef *error,
54 const uint8_t* der, const uint8_t *der_end);
55
56
57 // CFBoolean <-> DER
58 size_t der_sizeof_boolean(CFBooleanRef boolean, CFErrorRef *error);
59
60 uint8_t* der_encode_boolean(CFBooleanRef boolean, CFErrorRef *error,
61 const uint8_t *der, uint8_t *der_end);
62
63 const uint8_t* der_decode_boolean(CFAllocatorRef allocator, CFOptionFlags mutability,
64 CFBooleanRef* boolean, CFErrorRef *error,
65 const uint8_t* der, const uint8_t *der_end);
66
67 // CFData <-> DER
68 size_t der_sizeof_data(CFDataRef data, CFErrorRef *error);
69
70 uint8_t* der_encode_data(CFDataRef data, CFErrorRef *error,
71 const uint8_t *der, uint8_t *der_end);
72
73 const uint8_t* der_decode_data(CFAllocatorRef allocator, CFOptionFlags mutability,
74 CFDataRef* data, CFErrorRef *error,
75 const uint8_t* der, const uint8_t *der_end);
76
77 const uint8_t* der_decode_data_mutable(CFAllocatorRef allocator, CFOptionFlags mutability,
78 CFMutableDataRef* data, CFErrorRef *error,
79 const uint8_t* der, const uint8_t *der_end);
80
81
82 // CFDate <-> DER
83 size_t der_sizeof_date(CFDateRef date, CFErrorRef *error);
84
85 uint8_t* der_encode_date(CFDateRef date, CFErrorRef *error,
86 const uint8_t *der, uint8_t *der_end);
87
88 const uint8_t* der_decode_date(CFAllocatorRef allocator, CFOptionFlags mutability,
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, CFOptionFlags mutability,
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, CFOptionFlags mutability,
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, CFOptionFlags mutability,
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, CFOptionFlags mutability,
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