]> git.saurik.com Git - apple/security.git/blob - OSX/sec/SOSCircle/SecureObjectSync/SOSAccount.h
Security-57336.10.29.tar.gz
[apple/security.git] / OSX / sec / SOSCircle / SecureObjectSync / SOSAccount.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 /*!
26 @header SOSAccount.h
27 The functions provided in SOSCircle.h provide an interface to a
28 secure object syncing circle for a single class
29 */
30
31 #ifndef _SOSACCOUNT_H_
32 #define _SOSACCOUNT_H_
33
34 /* Forward declarations of SOS types. */
35 typedef struct __OpaqueSOSAccount *SOSAccountRef;
36
37
38 #include <CoreFoundation/CoreFoundation.h>
39
40 #include <Security/SecureObjectSync/SOSCircle.h>
41 #include <Security/SecureObjectSync/SOSFullPeerInfo.h>
42 #include <Security/SecureObjectSync/SOSCloudCircle.h>
43 #include <Security/SecureObjectSync/SOSCloudCircleInternal.h>
44 #include <Security/SecureObjectSync/SOSTransportKeyParameter.h>
45 #include <Security/SecureObjectSync/SOSTransportCircle.h>
46 #include <Security/SecureObjectSync/SOSTransportMessage.h>
47 #include <Security/SecureObjectSync/SOSRing.h>
48 #include <Security/SecureObjectSync/SOSPeerInfoSecurityProperties.h>
49
50 #include <dispatch/dispatch.h>
51
52 __BEGIN_DECLS
53
54 #define RETIREMENT_FINALIZATION_SECONDS (24*60*60)
55
56
57 typedef void (^SOSAccountCircleMembershipChangeBlock)(SOSCircleRef new_circle,
58 CFSetRef added_peers, CFSetRef removed_peers,
59 CFSetRef added_applicants, CFSetRef removed_applicants);
60 typedef void (^SOSAccountSyncablePeersBlock)(CFArrayRef trustedPeers, CFArrayRef addedPeers, CFArrayRef removedPeers);
61
62 SOSAccountRef SOSAccountCreate(CFAllocatorRef allocator,
63 CFDictionaryRef gestalt,
64 SOSDataSourceFactoryRef factory);
65 SOSAccountRef SOSAccountCreateBasic(CFAllocatorRef allocator,
66 CFDictionaryRef gestalt,
67 SOSDataSourceFactoryRef factory);
68
69
70 CFTypeID SOSAccountGetTypeID(void);
71
72 //
73 // MARK: Persistent Encode decode
74 //
75
76 SOSAccountRef SOSAccountCreateFromDER(CFAllocatorRef allocator, SOSDataSourceFactoryRef factory,
77 CFErrorRef* error,
78 const uint8_t** der_p, const uint8_t *der_end);
79
80 SOSAccountRef SOSAccountCreateFromDER_V3(CFAllocatorRef allocator,
81 SOSDataSourceFactoryRef factory,
82 CFErrorRef* error,
83 const uint8_t** der_p, const uint8_t *der_end);
84
85 SOSAccountRef SOSAccountCreateFromData(CFAllocatorRef allocator, CFDataRef circleData,
86 SOSDataSourceFactoryRef factory,
87 CFErrorRef* error);
88
89 size_t SOSAccountGetDEREncodedSize(SOSAccountRef cir, CFErrorRef *error);
90 uint8_t* SOSAccountEncodeToDER(SOSAccountRef cir, CFErrorRef* error, const uint8_t* der, uint8_t* der_end);
91 size_t SOSAccountGetDEREncodedSize_V3(SOSAccountRef cir, CFErrorRef *error);
92 uint8_t* SOSAccountEncodeToDER_V3(SOSAccountRef cir, CFErrorRef* error, const uint8_t* der, uint8_t* der_end);
93 CFDataRef SOSAccountCopyEncodedData(SOSAccountRef circle, CFAllocatorRef allocator, CFErrorRef *error);
94 //
95 //MARK: IDS Device ID
96 CFStringRef SOSAccountCopyDeviceID(SOSAccountRef account, CFErrorRef *error);
97 bool SOSAccountSetMyDSID(SOSAccountRef account, CFStringRef IDS, CFErrorRef* errror);
98 bool SOSAccountSendIDSTestMessage(SOSAccountRef account, CFStringRef message, CFErrorRef *error);
99 bool SOSAccountStartPingTest(SOSAccountRef account, CFStringRef message, CFErrorRef *error);
100 bool SOSAccountRetrieveDeviceIDFromIDSKeychainSyncingProxy(SOSAccountRef account, CFErrorRef *error);
101
102 //
103 // MARK: Credential management
104 //
105
106 SecKeyRef SOSAccountGetPrivateCredential(SOSAccountRef account, CFErrorRef* error);
107 CFDataRef SOSAccountGetCachedPassword(SOSAccountRef account, CFErrorRef* error);
108
109 void SOSAccountSetParameters(SOSAccountRef account, CFDataRef parameters);
110
111 void SOSAccountPurgePrivateCredential(SOSAccountRef account);
112
113 bool SOSAccountTryUserCredentials(SOSAccountRef account,
114 CFStringRef user_account, CFDataRef user_password,
115 CFErrorRef *error);
116
117 bool SOSAccountAssertUserCredentials(SOSAccountRef account,
118 CFStringRef user_account, CFDataRef user_password,
119 CFErrorRef *error);
120
121 bool SOSAccountRetryUserCredentials(SOSAccountRef account);
122 void SOSAccountSetUnTrustedUserPublicKey(SOSAccountRef account, SecKeyRef publicKey);
123
124 bool SOSAccountGenerationSignatureUpdate(SOSAccountRef account, CFErrorRef *error);
125
126 //
127 // MARK: Circle management
128 //
129
130 bool SOSAccountUpdateCircle(SOSAccountRef account, SOSCircleRef circle, CFErrorRef *error);
131 void SOSTransportEachMessage(SOSAccountRef account, CFDictionaryRef updates, CFErrorRef *error);
132
133
134 SOSCCStatus SOSAccountGetCircleStatus(SOSAccountRef account, CFErrorRef* error);
135 bool SOSAccountIsInCircle(SOSAccountRef account, CFErrorRef *error);
136 bool SOSAccountJoinCircles(SOSAccountRef account, CFErrorRef* error);
137 bool SOSAccountJoinCirclesAfterRestore(SOSAccountRef account, CFErrorRef* error);
138 bool SOSAccountLeaveCircle(SOSAccountRef account,CFErrorRef* error);
139 bool SOSAccountRemovePeersFromCircle(SOSAccountRef account, CFArrayRef peers, CFErrorRef* error);
140 bool SOSAccountBail(SOSAccountRef account, uint64_t limit_in_seconds, CFErrorRef* error);
141 bool SOSAccountAcceptApplicants(SOSAccountRef account, CFArrayRef applicants, CFErrorRef* error);
142 bool SOSAccountRejectApplicants(SOSAccountRef account, CFArrayRef applicants, CFErrorRef* error);
143
144 bool SOSAccountResetToOffering(SOSAccountRef account, CFErrorRef* error);
145 bool SOSAccountResetToEmpty(SOSAccountRef account, CFErrorRef* error);
146 bool SOSValidateUserPublic(SOSAccountRef account, CFErrorRef* error);
147
148 void SOSAccountForEachCirclePeerExceptMe(SOSAccountRef account, void (^action)(SOSPeerInfoRef peer));
149
150 CFArrayRef SOSAccountCopyApplicants(SOSAccountRef account, CFErrorRef *error);
151 CFArrayRef SOSAccountCopyGeneration(SOSAccountRef account, CFErrorRef *error);
152 CFArrayRef SOSAccountCopyValidPeers(SOSAccountRef account, CFErrorRef *error);
153 CFArrayRef SOSAccountCopyPeersToListenTo(SOSAccountRef account, CFErrorRef *error);
154 CFArrayRef SOSAccountCopyNotValidPeers(SOSAccountRef account, CFErrorRef *error);
155 CFArrayRef SOSAccountCopyRetired(SOSAccountRef account, CFErrorRef *error);
156 CFArrayRef SOSAccountCopyViewUnaware(SOSAccountRef account, CFErrorRef *error);
157 CFArrayRef SOSAccountCopyPeers(SOSAccountRef account, CFErrorRef *error);
158 CFArrayRef SOSAccountCopyActivePeers(SOSAccountRef account, CFErrorRef *error);
159 CFArrayRef SOSAccountCopyActiveValidPeers(SOSAccountRef account, CFErrorRef *error);
160 CFArrayRef SOSAccountCopyConcurringPeers(SOSAccountRef account, CFErrorRef *error);
161
162 SOSFullPeerInfoRef SOSAccountCopyAccountIdentityPeerInfo(SOSAccountRef account, CFAllocatorRef allocator, CFErrorRef* error);
163 bool SOSAccountIsAccountIdentity(SOSAccountRef account, SOSPeerInfoRef peer_info, CFErrorRef *error);
164
165 enum DepartureReason SOSAccountGetLastDepartureReason(SOSAccountRef account, CFErrorRef* error);
166
167 //
168 // MARK: Change blocks
169 //
170 void SOSAccountAddChangeBlock(SOSAccountRef a, SOSAccountCircleMembershipChangeBlock changeBlock);
171 void SOSAccountRemoveChangeBlock(SOSAccountRef a, SOSAccountCircleMembershipChangeBlock changeBlock);
172
173 void SOSAccountAddSyncablePeerBlock(SOSAccountRef a,
174 CFStringRef ds_name,
175 SOSAccountSyncablePeersBlock changeBlock);
176
177 //
178 // MARK: Local device gestalt change.
179 //
180 bool SOSAccountUpdateGestalt(SOSAccountRef account, CFDictionaryRef new_gestalt);
181
182 bool SOSAccountUpdateFullPeerInfo(SOSAccountRef account, CFSetRef minimumViews);
183
184 SOSViewResultCode SOSAccountUpdateView(SOSAccountRef account, CFStringRef viewname, SOSViewActionCode actionCode, CFErrorRef *error);
185
186 SOSViewResultCode SOSAccountViewStatus(SOSAccountRef account, CFStringRef viewname, CFErrorRef *error);
187
188 bool SOSAccountUpdateViewSets(SOSAccountRef account, CFSetRef enabledViews, CFSetRef disabledViews);
189
190 SOSSecurityPropertyResultCode SOSAccountUpdateSecurityProperty(SOSAccountRef account, CFStringRef property, SOSSecurityPropertyActionCode actionCode, CFErrorRef *error);
191
192 SOSSecurityPropertyResultCode SOSAccountSecurityPropertyStatus(SOSAccountRef account, CFStringRef property, CFErrorRef *error);
193
194
195 bool SOSAccountHandleParametersChange(SOSAccountRef account, CFDataRef updates, CFErrorRef *error);
196
197 bool SOSAccountSyncWithAllPeers(SOSAccountRef account, CFErrorRef *error);
198
199 bool SOSAccountCleanupAfterPeer(SOSAccountRef account, size_t seconds, SOSCircleRef circle,
200 SOSPeerInfoRef cleanupPeer, CFErrorRef* error);
201
202 bool SOSAccountCleanupRetirementTickets(SOSAccountRef account, size_t seconds, CFErrorRef* error);
203
204 bool SOSAccountScanForRetired(SOSAccountRef account, SOSCircleRef circle, CFErrorRef *error);
205
206 SOSCircleRef SOSAccountCloneCircleWithRetirement(SOSAccountRef account, SOSCircleRef starting_circle, CFErrorRef *error);
207
208 bool SOSAccountPostDebugScope(SOSAccountRef account, CFTypeRef scope, CFErrorRef *error);
209
210 //
211 // MARK: Version incompatibility Functions
212 //
213 CFStringRef SOSAccountCopyIncompatibilityInfo(SOSAccountRef account, CFErrorRef* error);
214
215 //
216 // MARK: Backup functions
217 //
218
219 bool SOSAccountIsBackupRingEmpty(SOSAccountRef account, CFStringRef viewName);
220 bool SOSAccountStartNewBackup(SOSAccountRef account, CFStringRef viewName, CFErrorRef *error);
221
222 bool SOSAccountSetBackupPublicKey(SOSAccountRef account, CFDataRef backupKey, CFErrorRef *error);
223 bool SOSAccountRemoveBackupPublickey(SOSAccountRef account, CFErrorRef *error);
224 bool SOSAccountSetBSKBagForAllSlices(SOSAccountRef account, CFDataRef backupSlice, bool setupV0Only, CFErrorRef *error);
225
226 //
227 // MARK: Private functions
228 //
229
230 dispatch_queue_t SOSAccountGetQueue(SOSAccountRef account);
231
232 typedef bool (^SOSAccountSendBlock)(CFStringRef key, CFDataRef message, CFErrorRef *error);
233
234 //
235 // MARK: Utility functions
236 //
237
238 CFStringRef SOSAccountCreateCompactDescription(SOSAccountRef a);
239 CFStringRef SOSInterestListCopyDescription(CFArrayRef interests);
240
241 //
242 // MARK: View Funcitons
243 //
244
245 // Use these to tell the engine what views are common to myPeer and other circle peers
246 CFArrayRef SOSCreateActiveViewIntersectionArrayForPeerID(SOSAccountRef account, CFStringRef peerID);
247 CFDictionaryRef SOSViewsCreateActiveViewMatrixDictionary(SOSAccountRef account, SOSCircleRef circle, CFErrorRef *error);
248
249 //
250 // MARK: Transactional functions
251 //
252
253 void SOSAccountFinishTransaction(SOSAccountRef account);
254
255 const uint8_t* der_decode_cloud_parameters(CFAllocatorRef allocator,
256 CFIndex algorithmID, SecKeyRef* publicKey,
257 CFDataRef *parameters,
258 CFErrorRef* error,
259 const uint8_t* der, const uint8_t* der_end);
260
261 /* CFSet <-> XPC functions */
262 CFSetRef CreateCFSetRefFromXPCObject(xpc_object_t xpcSetDER, CFErrorRef* error);
263 xpc_object_t CreateXPCObjectWithCFSetRef(CFSetRef setref, CFErrorRef *error);
264
265
266 __END_DECLS
267
268 #endif /* !_SOSACCOUNT_H_ */