]> git.saurik.com Git - apple/security.git/blob - Security/sec/SOSCircle/SecureObjectSync/SOSAccount.h
Security-57031.1.35.tar.gz
[apple/security.git] / Security / 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 <SecureObjectSync/SOSCircle.h>
41 #include <SecureObjectSync/SOSFullPeerInfo.h>
42 #include <SecureObjectSync/SOSCloudCircle.h>
43 #include <SecureObjectSync/SOSCloudCircleInternal.h>
44 #include <SecureObjectSync/SOSTransportKeyParameter.h>
45 #include <SecureObjectSync/SOSTransportCircle.h>
46 #include <SecureObjectSync/SOSTransportMessage.h>
47
48 #include <dispatch/dispatch.h>
49
50 __BEGIN_DECLS
51
52 #define RETIREMENT_FINALIZATION_SECONDS (24*60*60)
53
54
55 typedef void (^SOSAccountCircleMembershipChangeBlock)(SOSCircleRef new_circle,
56 CFSetRef added_peers, CFSetRef removed_peers,
57 CFSetRef added_applicants, CFSetRef removed_applicants);
58 typedef void (^SOSAccountSyncablePeersBlock)(CFArrayRef trustedPeers, CFArrayRef addedPeers, CFArrayRef removedPeers);
59
60 SOSAccountRef SOSAccountGetShared(void);
61 SOSAccountRef SOSAccountCreate(CFAllocatorRef allocator,
62 CFDictionaryRef gestalt,
63 SOSDataSourceFactoryRef factory);
64 SOSAccountRef SOSAccountCreateBasic(CFAllocatorRef allocator,
65 CFDictionaryRef gestalt,
66 SOSDataSourceFactoryRef factory);
67
68 //
69 // MARK: Persistent Encode decode
70 //
71
72 SOSAccountRef SOSAccountCreateFromDER(CFAllocatorRef allocator, SOSDataSourceFactoryRef factory,
73 CFErrorRef* error,
74 const uint8_t** der_p, const uint8_t *der_end);
75
76 SOSAccountRef SOSAccountCreateFromDER_V3(CFAllocatorRef allocator,
77 SOSDataSourceFactoryRef factory,
78 CFErrorRef* error,
79 const uint8_t** der_p, const uint8_t *der_end);
80
81 SOSAccountRef SOSAccountCreateFromData(CFAllocatorRef allocator, CFDataRef circleData,
82 SOSDataSourceFactoryRef factory,
83 CFErrorRef* error);
84
85 size_t SOSAccountGetDEREncodedSize(SOSAccountRef cir, CFErrorRef *error);
86 uint8_t* SOSAccountEncodeToDER(SOSAccountRef cir, CFErrorRef* error, const uint8_t* der, uint8_t* der_end);
87 size_t SOSAccountGetDEREncodedSize_V3(SOSAccountRef cir, CFErrorRef *error);
88 uint8_t* SOSAccountEncodeToDER_V3(SOSAccountRef cir, CFErrorRef* error, const uint8_t* der, uint8_t* der_end);
89 CFDataRef SOSAccountCopyEncodedData(SOSAccountRef circle, CFAllocatorRef allocator, CFErrorRef *error);
90 //
91 //MARK: IDS Device ID
92 CFStringRef SOSAccountGetDeviceID(SOSAccountRef account, CFErrorRef *error);
93 bool SOSAccountSetMyDSID(SOSAccountRef account, CFStringRef IDS, CFErrorRef* errror);
94
95 //
96 //
97 // MARK: Local Peer finding
98 //
99 SOSPeerInfoRef SOSAccountGetMyPeerInCircle(SOSAccountRef account, SOSCircleRef circle, CFErrorRef* error);
100 SOSPeerInfoRef SOSAccountGetMyPeerInCircleNamed(SOSAccountRef account, CFStringRef circle, CFErrorRef* error);
101
102 SOSFullPeerInfoRef SOSAccountGetMyFullPeerInCircle(SOSAccountRef account, SOSCircleRef circle, CFErrorRef* error);
103 SOSFullPeerInfoRef SOSAccountGetMyFullPeerInCircleNamed(SOSAccountRef account, CFStringRef name, CFErrorRef *error);
104
105 //
106 // MARK: Credential management
107 //
108
109 SecKeyRef SOSAccountGetPrivateCredential(SOSAccountRef account, CFErrorRef* error);
110 void SOSAccountPurgePrivateCredential(SOSAccountRef account);
111
112 bool SOSAccountTryUserCredentials(SOSAccountRef account,
113 CFStringRef user_account, CFDataRef user_password,
114 CFErrorRef *error);
115
116 bool SOSAccountAssertUserCredentials(SOSAccountRef account,
117 CFStringRef user_account, CFDataRef user_password,
118 CFErrorRef *error);
119
120
121 //
122 // MARK: Circle management
123 //
124 int SOSAccountCountCircles(SOSAccountRef a);
125
126 void SOSAccountForEachCircle(SOSAccountRef account, void (^process)(SOSCircleRef circle));
127
128 SOSCircleRef SOSAccountFindCircle(SOSAccountRef a, CFStringRef name, CFErrorRef *error);
129 SOSCircleRef SOSAccountEnsureCircle(SOSAccountRef a, CFStringRef name, CFErrorRef *error);
130
131 bool SOSAccountUpdateCircle(SOSAccountRef account, SOSCircleRef circle, CFErrorRef *error);
132 void SOSTransportEachMessage(SOSAccountRef account, CFDictionaryRef updates, CFErrorRef *error);
133
134
135 SOSCCStatus SOSAccountIsInCircles(SOSAccountRef account, CFErrorRef* error);
136 bool SOSAccountJoinCircles(SOSAccountRef account, CFErrorRef* error);
137 bool SOSAccountJoinCirclesAfterRestore(SOSAccountRef account, CFErrorRef* error);
138 bool SOSAccountLeaveCircles(SOSAccountRef account,CFErrorRef* error);
139 bool SOSAccountBail(SOSAccountRef account, uint64_t limit_in_seconds, CFErrorRef* error);
140 bool SOSAccountAcceptApplicants(SOSAccountRef account, CFArrayRef applicants, CFErrorRef* error);
141 bool SOSAccountRejectApplicants(SOSAccountRef account, CFArrayRef applicants, CFErrorRef* error);
142
143 bool SOSAccountResetToOffering(SOSAccountRef account, CFErrorRef* error);
144 bool SOSAccountResetToEmpty(SOSAccountRef account, CFErrorRef* error);
145 bool SOSValidateUserPublic(SOSAccountRef account, CFErrorRef* error);
146
147 CFArrayRef SOSAccountCopyApplicants(SOSAccountRef account, CFErrorRef *error);
148 CFArrayRef SOSAccountCopyGeneration(SOSAccountRef account, CFErrorRef *error);
149 CFArrayRef SOSAccountCopyValidPeers(SOSAccountRef account, CFErrorRef *error);
150 CFArrayRef SOSAccountCopyNotValidPeers(SOSAccountRef account, CFErrorRef *error);
151 CFArrayRef SOSAccountCopyRetired(SOSAccountRef account, CFErrorRef *error);
152 CFArrayRef SOSAccountCopyPeers(SOSAccountRef account, CFErrorRef *error);
153 CFArrayRef SOSAccountCopyActivePeers(SOSAccountRef account, CFErrorRef *error);
154 CFArrayRef SOSAccountCopyActiveValidPeers(SOSAccountRef account, CFErrorRef *error);
155 CFArrayRef SOSAccountCopyConcurringPeers(SOSAccountRef account, CFErrorRef *error);
156
157 CFArrayRef SOSAccountCopyAccountIdentityPeerInfos(SOSAccountRef account, CFAllocatorRef allocator, CFErrorRef* error);
158 bool SOSAccountIsAccountIdentity(SOSAccountRef account, SOSPeerInfoRef peer_info, CFErrorRef *error);
159
160 enum DepartureReason SOSAccountGetLastDepartureReason(SOSAccountRef account, CFErrorRef* error);
161
162 //
163 // MARK: Change blocks
164 //
165 void SOSAccountAddChangeBlock(SOSAccountRef a, SOSAccountCircleMembershipChangeBlock changeBlock);
166 void SOSAccountRemoveChangeBlock(SOSAccountRef a, SOSAccountCircleMembershipChangeBlock changeBlock);
167
168 void SOSAccountAddSyncablePeerBlock(SOSAccountRef a,
169 CFStringRef ds_name,
170 SOSAccountSyncablePeersBlock changeBlock);
171
172 //
173 // MARK: Local device gestalt change.
174 //
175 bool SOSAccountUpdateGestalt(SOSAccountRef account, CFDictionaryRef new_gestalt);
176
177 bool SOSAccountHandleParametersChange(SOSAccountRef account, CFDataRef updates, CFErrorRef *error);
178
179 bool SOSAccountSyncWithPeer(SOSAccountRef account, SOSCircleRef circle, SOSPeerInfoRef thisPeer, bool* didSendData, CFErrorRef* error);
180 bool SOSAccountSyncWithAllPeers(SOSAccountRef account, CFErrorRef *error);
181
182 bool SOSAccountCleanupAfterPeer(SOSAccountRef account, size_t seconds, SOSCircleRef circle,
183 SOSPeerInfoRef cleanupPeer, CFErrorRef* error);
184
185 bool SOSAccountCleanupRetirementTickets(SOSAccountRef account, size_t seconds, CFErrorRef* error);
186
187 bool SOSAccountScanForRetired(SOSAccountRef account, SOSCircleRef circle, CFErrorRef *error);
188
189 SOSCircleRef SOSAccountCloneCircleWithRetirement(SOSAccountRef account, SOSCircleRef starting_circle, CFErrorRef *error);
190
191 //
192 // MARK: Version incompatibility Functions
193 //
194 CFStringRef SOSAccountCopyIncompatibilityInfo(SOSAccountRef account, CFErrorRef* error);
195
196 //
197 // MARK: Private functions
198 //
199
200
201 dispatch_queue_t SOSAccountGetQueue(SOSAccountRef account);
202
203 typedef bool (^SOSAccountSendBlock)(CFStringRef key, CFDataRef message, CFErrorRef *error);
204
205 //
206 // MARK: Utility functions
207 //
208
209 CFStringRef SOSInterestListCopyDescription(CFArrayRef interests);
210
211
212 __END_DECLS
213
214 #endif /* !_SOSACCOUNT_H_ */