2 * Copyright (c) 2012-2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
25 #ifndef _DER_PLIST_INTERNAL_H_
26 #define _DER_PLIST_INTERNAL_H_
28 #include <CoreFoundation/CoreFoundation.h>
29 #include <utilities/SecCFError.h>
31 // Always returns false, to satisfy static analysis
32 #define SecCFDERCreateError(errorCode, descriptionString, previousError, newError) \
33 SecCFCreateErrorWithFormat(errorCode, sSecDERErrorDomain, previousError, newError, NULL, descriptionString)
37 size_t der_sizeof_array(CFArrayRef array
, CFErrorRef
*error
);
39 uint8_t* der_encode_array(CFArrayRef array
, CFErrorRef
*error
,
40 const uint8_t *der
, uint8_t *der_end
);
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
);
47 size_t der_sizeof_null(CFNullRef nul
, CFErrorRef
*error
);
49 uint8_t* der_encode_null(CFNullRef nul
, CFErrorRef
*error
,
50 const uint8_t *der
, uint8_t *der_end
);
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
);
58 size_t der_sizeof_boolean(CFBooleanRef boolean
, CFErrorRef
*error
);
60 uint8_t* der_encode_boolean(CFBooleanRef boolean
, CFErrorRef
*error
,
61 const uint8_t *der
, uint8_t *der_end
);
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
);
68 size_t der_sizeof_data(CFDataRef data
, CFErrorRef
*error
);
70 uint8_t* der_encode_data(CFDataRef data
, CFErrorRef
*error
,
71 const uint8_t *der
, uint8_t *der_end
);
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
);
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
);
83 size_t der_sizeof_date(CFDateRef date
, CFErrorRef
*error
);
85 uint8_t* der_encode_date(CFDateRef date
, CFErrorRef
*error
,
86 const uint8_t *der
, uint8_t *der_end
);
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
);
93 // CFDictionary <-> DER
94 size_t der_sizeof_dictionary(CFDictionaryRef dictionary
, CFErrorRef
*error
);
96 uint8_t* der_encode_dictionary(CFDictionaryRef dictionary
, CFErrorRef
*error
,
97 const uint8_t *der
, uint8_t *der_end
);
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
);
104 // Currently only supports signed 64 bit values. No floating point.
105 size_t der_sizeof_number(CFNumberRef number
, CFErrorRef
*error
);
107 uint8_t* der_encode_number(CFNumberRef number
, CFErrorRef
*error
,
108 const uint8_t *der
, uint8_t *der_end
);
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
);
115 size_t der_sizeof_string(CFStringRef string
, CFErrorRef
*error
);
117 uint8_t* der_encode_string(CFStringRef string
, CFErrorRef
*error
,
118 const uint8_t *der
, uint8_t *der_end
);
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
);
125 size_t der_sizeof_set(CFSetRef dict
, CFErrorRef
*error
);
127 uint8_t* der_encode_set(CFSetRef set
, CFErrorRef
*error
,
128 const uint8_t *der
, uint8_t *der_end
);
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
);
134 #include <corecrypto/ccder.h>
136 CCDER_CONSTRUCTED_CFSET
= CCDER_PRIVATE
| CCDER_SET
,