]> git.saurik.com Git - apple/security.git/blob - OSX/sec/ProjectHeaders/Security/SecureObjectSync/SOSPeerInfo.h
Security-57336.1.9.tar.gz
[apple/security.git] / OSX / sec / ProjectHeaders / Security / SecureObjectSync / SOSPeerInfo.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 _SOSPEERINFO_H_
26 #define _SOSPEERINFO_H_
27
28 #include <CoreFoundation/CoreFoundation.h>
29 #include <Security/SecKey.h>
30 #include <CommonCrypto/CommonDigestSPI.h>
31 #include <corecrypto/ccdigest.h>
32
33 #include <Security/SecureObjectSync/SOSTypes.h>
34
35 __BEGIN_DECLS
36
37 typedef struct __OpaqueSOSPeerInfo *SOSPeerInfoRef;
38
39 // Bumped to 3 from 2 so we can identify pre-iCDP peers and add the proper views.
40 #define PEERINFO_CURRENT_VERSION 3
41
42 enum {
43 kSOSPeerVersion = 2,
44 kSOSPeerV2BaseVersion = 2,
45 };
46
47
48 enum {
49 SOSPeerCmpPubKeyHash = 0,
50 SOSPeerCmpName = 1,
51 };
52 typedef uint32_t SOSPeerInfoCmpSelect;
53
54 CFTypeID SOSPeerInfoGetTypeID(void);
55
56 static inline bool isSOSPeerInfo(CFTypeRef obj) {
57 return obj && (CFGetTypeID(obj) == SOSPeerInfoGetTypeID());
58 }
59
60 SOSPeerInfoRef SOSPeerInfoCreate(CFAllocatorRef allocator, CFDictionaryRef gestalt, CFDataRef backup_key, SecKeyRef signingKey, CFErrorRef* error);
61
62 SOSPeerInfoRef SOSPeerInfoCreateWithTransportAndViews(CFAllocatorRef allocator, CFDictionaryRef gestalt, CFDataRef backup_key,
63 CFStringRef IDSID, CFStringRef transportType, CFBooleanRef preferIDS,
64 CFSetRef enabledViews,
65 SecKeyRef signingKey, CFErrorRef* error);
66
67 SOSPeerInfoRef SOSPeerInfoCreateCloudIdentity(CFAllocatorRef allocator, CFDictionaryRef gestalt, SecKeyRef signingKey, CFErrorRef* error);
68
69 SOSPeerInfoRef SOSPeerInfoCreateCopy(CFAllocatorRef allocator, SOSPeerInfoRef toCopy, CFErrorRef* error);
70 SOSPeerInfoRef SOSPeerInfoCreateCurrentCopy(CFAllocatorRef allocator, SOSPeerInfoRef toCopy,
71 CFStringRef IDSID, CFStringRef transportType, CFBooleanRef preferIDS, CFSetRef enabledViews,
72 SecKeyRef signingKey, CFErrorRef* error);
73 bool SOSPeerInfoVersionIsCurrent(SOSPeerInfoRef pi);
74 bool SOSPeerInfoVersionHasV2Data(SOSPeerInfoRef pi);
75 SOSPeerInfoRef SOSPeerInfoCopyWithGestaltUpdate(CFAllocatorRef allocator, SOSPeerInfoRef toCopy, CFDictionaryRef gestalt, SecKeyRef signingKey, CFErrorRef* error);
76 SOSPeerInfoRef SOSPeerInfoCopyWithBackupKeyUpdate(CFAllocatorRef allocator, SOSPeerInfoRef toCopy, CFDataRef backupKey, SecKeyRef signingKey, CFErrorRef* error);
77
78 SOSPeerInfoRef SOSPeerInfoCopyWithViewsChange(CFAllocatorRef allocator, SOSPeerInfoRef toCopy,
79 SOSViewActionCode action, CFStringRef viewname, SOSViewResultCode *retval,
80 SecKeyRef signingKey, CFErrorRef* error);
81 SOSPeerInfoRef SOSPeerInfoCopyAsApplication(SOSPeerInfoRef pi, SecKeyRef userkey, SecKeyRef peerkey, CFErrorRef *error);
82
83 SOSPeerInfoRef SOSPeerInfoCopyWithSecurityPropertyChange(CFAllocatorRef allocator, SOSPeerInfoRef toCopy,
84 SOSSecurityPropertyActionCode action, CFStringRef property, SOSSecurityPropertyResultCode *retval,
85 SecKeyRef signingKey, CFErrorRef* error);
86
87 SOSPeerInfoRef SOSPeerInfoCopyWithPing(CFAllocatorRef allocator, SOSPeerInfoRef toCopy, SecKeyRef signingKey, CFErrorRef* error);
88 SOSPeerInfoRef SOSPeerInfoCopyAsApplication(SOSPeerInfoRef pi, SecKeyRef userkey, SecKeyRef peerkey, CFErrorRef *error);
89
90 bool SOSPeerInfoUpdateDigestWithPublicKeyBytes(SOSPeerInfoRef peer, const struct ccdigest_info *di,
91 ccdigest_ctx_t ctx, CFErrorRef *error);
92 bool SOSPeerInfoUpdateDigestWithDescription(SOSPeerInfoRef peer, const struct ccdigest_info *di,
93 ccdigest_ctx_t ctx, CFErrorRef *error);
94
95
96 bool SOSPeerInfoApplicationVerify(SOSPeerInfoRef pi, SecKeyRef userkey, CFErrorRef *error);
97
98 CF_RETURNS_RETAINED CFDateRef SOSPeerInfoGetApplicationDate(SOSPeerInfoRef pi);
99
100 //
101 // DER Import Export
102 //
103 SOSPeerInfoRef SOSPeerInfoCreateFromDER(CFAllocatorRef allocator, CFErrorRef* error,
104 const uint8_t** der_p, const uint8_t *der_end);
105
106 SOSPeerInfoRef SOSPeerInfoCreateFromData(CFAllocatorRef allocator, CFErrorRef* error,
107 CFDataRef peerinfo_data);
108
109 size_t SOSPeerInfoGetDEREncodedSize(SOSPeerInfoRef peer, CFErrorRef *error);
110 uint8_t* SOSPeerInfoEncodeToDER(SOSPeerInfoRef peer, CFErrorRef* error,
111 const uint8_t* der, uint8_t* der_end);
112
113 CFDataRef SOSPeerInfoCopyEncodedData(SOSPeerInfoRef peer, CFAllocatorRef allocator, CFErrorRef *error);
114
115 //
116 // Transfered Data
117 //
118 bool SOSPeerInfoHasBackupKey(SOSPeerInfoRef peer);
119 CFDataRef SOSPeerInfoCopyBackupKey(SOSPeerInfoRef peer);
120
121 //
122 // DER Import Export
123 //
124 SOSPeerInfoRef SOSPeerInfoCreateFromDER(CFAllocatorRef allocator, CFErrorRef* error,
125 const uint8_t** der_p, const uint8_t *der_end);
126
127 SOSPeerInfoRef SOSPeerInfoCreateFromData(CFAllocatorRef allocator, CFErrorRef* error,
128 CFDataRef peerinfo_data);
129
130 size_t SOSPeerInfoGetDEREncodedSize(SOSPeerInfoRef peer, CFErrorRef *error);
131 uint8_t* SOSPeerInfoEncodeToDER(SOSPeerInfoRef peer, CFErrorRef* error,
132 const uint8_t* der, uint8_t* der_end);
133
134 CFDataRef SOSPeerInfoCopyEncodedData(SOSPeerInfoRef peer, CFAllocatorRef allocator, CFErrorRef *error);
135
136 //
137 // Gestalt info about the peer. It was fetched by the implementation on the other side.
138 // probably has what you're looking for..
139 //
140 CFTypeRef SOSPeerInfoLookupGestaltValue(SOSPeerInfoRef pi, CFStringRef key);
141 CFDictionaryRef SOSPeerInfoCopyPeerGestalt(SOSPeerInfoRef pi);
142 CFDictionaryRef SOSPeerGetGestalt(SOSPeerInfoRef pi);
143 CFStringRef SOSPeerInfoGetPeerName(SOSPeerInfoRef peer);
144
145 //
146 // Syntactic Sugar for some commone ones, might get deprectated at this level.
147 //
148
149 CFStringRef SOSPeerInfoGetPeerDeviceType(SOSPeerInfoRef peer);
150 CFIndex SOSPeerInfoGetPeerProtocolVersion(SOSPeerInfoRef peer);
151
152
153 // Stringified ID for this peer, not human readable.
154 CFStringRef SOSPeerInfoGetPeerID(SOSPeerInfoRef peer);
155 bool SOSPeerInfoPeerIDEqual(SOSPeerInfoRef pi, CFStringRef myPeerID);
156
157 CFIndex SOSPeerInfoGetVersion(SOSPeerInfoRef peer);
158
159 //
160 // Peer Info Gestalt Helpers
161 //
162 CFStringRef SOSPeerGestaltGetName(CFDictionaryRef gestalt);
163
164 // These are Mobile Gestalt questions. Not all Gestalt questions are carried.
165 CFTypeRef SOSPeerGestaltGetAnswer(CFDictionaryRef gestalt, CFStringRef question);
166
167 SecKeyRef SOSPeerInfoCopyPubKey(SOSPeerInfoRef peer);
168
169 CFDataRef SOSPeerInfoGetAutoAcceptInfo(SOSPeerInfoRef peer);
170
171 CFComparisonResult SOSPeerInfoCompareByID(const void *val1, const void *val2, void *context);
172
173 SOSPeerInfoRef SOSPeerInfoCreateRetirementTicket(CFAllocatorRef allocator, SecKeyRef privKey, SOSPeerInfoRef peer, CFErrorRef *error);
174
175 CFStringRef SOSPeerInfoInspectRetirementTicket(SOSPeerInfoRef pi, CFErrorRef *error);
176
177 bool SOSPeerInfoRetireRetirementTicket(size_t max_days, SOSPeerInfoRef pi);
178
179 CF_RETURNS_RETAINED CFDateRef SOSPeerInfoGetRetirementDate(SOSPeerInfoRef pi);
180
181 bool SOSPeerInfoIsRetirementTicket(SOSPeerInfoRef pi);
182
183 bool SOSPeerInfoIsCloudIdentity(SOSPeerInfoRef pi);
184
185 SOSPeerInfoRef SOSPeerInfoUpgradeSignatures(CFAllocatorRef allocator, SecKeyRef privKey, SecKeyRef perKey, SOSPeerInfoRef peer, CFErrorRef *error);
186
187 SOSViewResultCode SOSPeerInfoViewStatus(SOSPeerInfoRef pi, CFStringRef view, CFErrorRef *error);
188
189 CFSetRef SOSPeerInfoGetPermittedViews(SOSPeerInfoRef peer);
190 bool SOSPeerInfoIsEnabledView(SOSPeerInfoRef peer, CFStringRef viewName);
191 CFMutableSetRef SOSPeerInfoCopyEnabledViews(SOSPeerInfoRef peer);
192 void SOSPeerInfoWithEnabledViewSet(SOSPeerInfoRef pi, void (^operation)(CFSetRef enabled));
193
194 SOSSecurityPropertyResultCode SOSPeerInfoSecurityPropertyStatus(SOSPeerInfoRef pi, CFStringRef property, CFErrorRef *error);
195
196 //Transport
197 CFBooleanRef SOSPeerInfoCopyIDSPreference(SOSPeerInfoRef peer);
198 SOSPeerInfoRef SOSPeerInfoSetIDSPreference(CFAllocatorRef allocator, SOSPeerInfoRef toCopy, CFBooleanRef preference, SecKeyRef signingKey, CFErrorRef *error);
199
200 CFStringRef SOSPeerInfoCopyTransportType(SOSPeerInfoRef peer);
201 SOSPeerInfoRef SOSPeerInfoSetTransportType(CFAllocatorRef allocator, SOSPeerInfoRef toCopy, CFStringRef transportType, SecKeyRef signingKey, CFErrorRef *error);
202
203 // IDSs device ID
204 bool SOSPeerInfoHasDeviceID(SOSPeerInfoRef peer);
205 CFStringRef SOSPeerInfoCopyDeviceID(SOSPeerInfoRef peer);
206 SOSPeerInfoRef SOSPeerInfoSetDeviceID(CFAllocatorRef allocator, SOSPeerInfoRef toCopy, CFStringRef IDS, SecKeyRef signingKey, CFErrorRef *error);
207
208 bool SOSPeerInfoShouldUseIDSTransport(SOSPeerInfoRef myPeer, SOSPeerInfoRef theirPeer);
209
210 __END_DECLS
211
212 #endif