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>
30 // Always returns false, to satisfy static analysis
31 bool SecCFDERCreateError(CFIndex errorCode
, CFStringRef descriptionString
, CFErrorRef previousError
, CFErrorRef
*newError
);
35 size_t der_sizeof_array(CFArrayRef array
, CFErrorRef
*error
);
37 uint8_t* der_encode_array(CFArrayRef array
, CFErrorRef
*error
,
38 const uint8_t *der
, uint8_t *der_end
);
40 const uint8_t* der_decode_array(CFAllocatorRef allocator
, CFOptionFlags mutability
,
41 CFArrayRef
* array
, CFErrorRef
*error
,
42 const uint8_t* der
, const uint8_t *der_end
);
45 size_t der_sizeof_null(CFNullRef nul
, CFErrorRef
*error
);
47 uint8_t* der_encode_null(CFNullRef nul
, CFErrorRef
*error
,
48 const uint8_t *der
, uint8_t *der_end
);
50 const uint8_t* der_decode_null(CFAllocatorRef allocator
, CFOptionFlags mutability
,
51 CFNullRef
*nul
, CFErrorRef
*error
,
52 const uint8_t* der
, const uint8_t *der_end
);
56 size_t der_sizeof_boolean(CFBooleanRef boolean
, CFErrorRef
*error
);
58 uint8_t* der_encode_boolean(CFBooleanRef boolean
, CFErrorRef
*error
,
59 const uint8_t *der
, uint8_t *der_end
);
61 const uint8_t* der_decode_boolean(CFAllocatorRef allocator
, CFOptionFlags mutability
,
62 CFBooleanRef
* boolean
, CFErrorRef
*error
,
63 const uint8_t* der
, const uint8_t *der_end
);
66 size_t der_sizeof_data(CFDataRef data
, CFErrorRef
*error
);
68 uint8_t* der_encode_data(CFDataRef data
, CFErrorRef
*error
,
69 const uint8_t *der
, uint8_t *der_end
);
71 const uint8_t* der_decode_data(CFAllocatorRef allocator
, CFOptionFlags mutability
,
72 CFDataRef
* data
, CFErrorRef
*error
,
73 const uint8_t* der
, const uint8_t *der_end
);
75 const uint8_t* der_decode_data_mutable(CFAllocatorRef allocator
, CFOptionFlags mutability
,
76 CFMutableDataRef
* data
, CFErrorRef
*error
,
77 const uint8_t* der
, const uint8_t *der_end
);
81 size_t der_sizeof_date(CFDateRef date
, CFErrorRef
*error
);
83 uint8_t* der_encode_date(CFDateRef date
, CFErrorRef
*error
,
84 const uint8_t *der
, uint8_t *der_end
);
86 const uint8_t* der_decode_date(CFAllocatorRef allocator
, CFOptionFlags mutability
,
87 CFDateRef
* date
, CFErrorRef
*error
,
88 const uint8_t* der
, const uint8_t *der_end
);
91 // CFDictionary <-> DER
92 size_t der_sizeof_dictionary(CFDictionaryRef dictionary
, CFErrorRef
*error
);
94 uint8_t* der_encode_dictionary(CFDictionaryRef dictionary
, CFErrorRef
*error
,
95 const uint8_t *der
, uint8_t *der_end
);
97 const uint8_t* der_decode_dictionary(CFAllocatorRef allocator
, CFOptionFlags mutability
,
98 CFDictionaryRef
* dictionary
, CFErrorRef
*error
,
99 const uint8_t* der
, const uint8_t *der_end
);
102 // Currently only supports signed 64 bit values. No floating point.
103 size_t der_sizeof_number(CFNumberRef number
, CFErrorRef
*error
);
105 uint8_t* der_encode_number(CFNumberRef number
, CFErrorRef
*error
,
106 const uint8_t *der
, uint8_t *der_end
);
108 const uint8_t* der_decode_number(CFAllocatorRef allocator
, CFOptionFlags mutability
,
109 CFNumberRef
* number
, CFErrorRef
*error
,
110 const uint8_t* der
, const uint8_t *der_end
);
113 size_t der_sizeof_string(CFStringRef string
, CFErrorRef
*error
);
115 uint8_t* der_encode_string(CFStringRef string
, CFErrorRef
*error
,
116 const uint8_t *der
, uint8_t *der_end
);
118 const uint8_t* der_decode_string(CFAllocatorRef allocator
, CFOptionFlags mutability
,
119 CFStringRef
* string
, CFErrorRef
*error
,
120 const uint8_t* der
, const uint8_t *der_end
);
123 size_t der_sizeof_set(CFSetRef dict
, CFErrorRef
*error
);
125 uint8_t* der_encode_set(CFSetRef set
, CFErrorRef
*error
,
126 const uint8_t *der
, uint8_t *der_end
);
128 const uint8_t* der_decode_set(CFAllocatorRef allocator
, CFOptionFlags mutability
,
129 CFSetRef
* set
, CFErrorRef
*error
,
130 const uint8_t* der
, const uint8_t *der_end
);
132 #include <corecrypto/ccder.h>
134 CCDER_CONSTRUCTED_CFSET
= CCDER_PRIVATE
| CCDER_SET
,