]> git.saurik.com Git - apple/security.git/blob - OSX/sec/securityd/SOSCloudCircleServer.h
Security-58286.1.32.tar.gz
[apple/security.git] / OSX / sec / securityd / SOSCloudCircleServer.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 _SECURITY_SOSCLOUDCIRCLESERVER_H_
26 #define _SECURITY_SOSCLOUDCIRCLESERVER_H_
27
28 #import <Security/SecureObjectSync/SOSCloudCircle.h>
29 #import <Security/SecureObjectSync/SOSRing.h>
30 #import <Security/SecKey.h>
31 #import <xpc/xpc.h>
32
33 __BEGIN_DECLS
34
35 //
36 // MARK: Server versions of our SPI
37 //
38 bool SOSCCTryUserCredentials_Server(CFStringRef user_label, CFDataRef user_password, CFErrorRef *error);
39 bool SOSCCSetUserCredentials_Server(CFStringRef user_label, CFDataRef user_password, CFErrorRef *error);
40 bool SOSCCSetUserCredentialsAndDSID_Server(CFStringRef user_label, CFDataRef user_password, CFStringRef dsid, CFErrorRef *error);
41
42 bool SOSCCCanAuthenticate_Server(CFErrorRef *error);
43 bool SOSCCPurgeUserCredentials_Server(CFErrorRef *error);
44
45 SOSCCStatus SOSCCThisDeviceIsInCircle_Server(CFErrorRef *error);
46 bool SOSCCRequestToJoinCircle_Server(CFErrorRef* error);
47 bool SOSCCRequestToJoinCircleAfterRestore_Server(CFErrorRef* error);
48 CFStringRef SOSCCCopyDeviceID_Server(CFErrorRef *error);
49 bool SOSCCSetDeviceID_Server(CFStringRef IDS, CFErrorRef *error);
50 HandleIDSMessageReason SOSCCHandleIDSMessage_Server(CFDictionaryRef messageDict, CFErrorRef* error);
51 bool SOSCCRequestSyncWithPeerOverKVS_Server(CFStringRef peerID, CFDataRef message, CFErrorRef *error);
52 bool SOSCCClearPeerMessageKeyInKVS_Server(CFStringRef peerID, CFErrorRef *error);
53
54 bool SOSCCIDSServiceRegistrationTest_Server(CFStringRef message, CFErrorRef *error);
55 bool SOSCCIDSPingTest_Server(CFStringRef message, CFErrorRef *error);
56 bool SOSCCIDSDeviceIDIsAvailableTest_Server(CFErrorRef *error);
57
58 bool SOSCCRemoveThisDeviceFromCircle_Server(CFErrorRef* error);
59 bool SOSCCRemovePeersFromCircle_Server(CFArrayRef peers, CFErrorRef* error);
60 bool SOSCCLoggedOutOfAccount_Server(CFErrorRef *error);
61 bool SOSCCBailFromCircle_Server(uint64_t limit_in_seconds, CFErrorRef* error);
62 bool SOSCCRequestEnsureFreshParameters_Server(CFErrorRef* error);
63
64
65 bool SOSCCApplyToARing_Server(CFStringRef ringName, CFErrorRef *error);
66 bool SOSCCWithdrawlFromARing_Server(CFStringRef ringName, CFErrorRef *error);
67 SOSRingStatus SOSCCRingStatus_Server(CFStringRef ringName, CFErrorRef *error);
68 CFStringRef SOSCCGetAllTheRings_Server(CFErrorRef *error);
69 bool SOSCCEnableRing_Server(CFStringRef ringName, CFErrorRef *error);
70
71
72 CFArrayRef SOSCCCopyGenerationPeerInfo_Server(CFErrorRef* error);
73 CFArrayRef SOSCCCopyApplicantPeerInfo_Server(CFErrorRef* error);
74 CFArrayRef SOSCCCopyValidPeerPeerInfo_Server(CFErrorRef* error);
75 bool SOSCCValidateUserPublic_Server(CFErrorRef* error);
76
77 CFArrayRef SOSCCCopyNotValidPeerPeerInfo_Server(CFErrorRef* error);
78 CFArrayRef SOSCCCopyRetirementPeerInfo_Server(CFErrorRef* error);
79 CFArrayRef SOSCCCopyViewUnawarePeerInfo_Server(CFErrorRef* error);
80 bool SOSCCRejectApplicants_Server(CFArrayRef applicants, CFErrorRef* error);
81 bool SOSCCAcceptApplicants_Server(CFArrayRef applicants, CFErrorRef* error);
82
83 SOSPeerInfoRef SOSCCCopyMyPeerInfo_Server(CFErrorRef* error);
84 CFArrayRef SOSCCCopyEngineState_Server(CFErrorRef* error);
85
86 CFArrayRef SOSCCCopyPeerPeerInfo_Server(CFErrorRef* error);
87 CFArrayRef SOSCCCopyConcurringPeerPeerInfo_Server(CFErrorRef* error);
88 bool SOSCCCheckPeerAvailability_Server(CFErrorRef *error);
89 bool SOSCCkSecXPCOpIsThisDeviceLastBackup_Server(CFErrorRef *error);
90 bool SOSCCkSecXPCOpIsThisDeviceLastBackup_Server(CFErrorRef *error);
91 bool SOSCCAccountSetToNew_Server(CFErrorRef *error);
92 bool SOSCCResetToOffering_Server(CFErrorRef* error);
93 bool SOSCCResetToEmpty_Server(CFErrorRef* error);
94
95 CFBooleanRef SOSCCPeersHaveViewsEnabled_Server(CFArrayRef viewNames, CFErrorRef *error);
96
97 SOSViewResultCode SOSCCView_Server(CFStringRef view, SOSViewActionCode action, CFErrorRef *error);
98 bool SOSCCViewSet_Server(CFSetRef enabledView, CFSetRef disabledViews);
99
100 SOSSecurityPropertyResultCode SOSCCSecurityProperty_Server(CFStringRef property, SOSSecurityPropertyActionCode action, CFErrorRef *error);
101
102 CFStringRef SOSCCCopyIncompatibilityInfo_Server(CFErrorRef* error);
103 enum DepartureReason SOSCCGetLastDepartureReason_Server(CFErrorRef* error);
104 bool SOSCCSetLastDepartureReason_Server(enum DepartureReason reason, CFErrorRef *error);
105
106 bool SOSCCProcessEnsurePeerRegistration_Server(CFErrorRef* error);
107
108 CF_RETURNS_RETAINED CFSetRef SOSCCProcessSyncWithPeers_Server(CFSetRef peers, CFSetRef backupPeers, CFErrorRef *error);
109 SyncWithAllPeersReason SOSCCProcessSyncWithAllPeers_Server(CFErrorRef* error);
110 bool SOSCCRequestSyncWithPeerOverKVSUsingIDOnly_Server(CFStringRef deviceID, CFErrorRef *error);
111
112 SOSPeerInfoRef SOSCCSetNewPublicBackupKey_Server(CFDataRef newPublicBackup, CFErrorRef *error);
113 bool SOSCCRegisterSingleRecoverySecret_Server(CFDataRef backupSlice, bool setupV0Only, CFErrorRef *error);
114
115 bool SOSCCWaitForInitialSync_Server(CFErrorRef*);
116 CFArrayRef SOSCCCopyYetToSyncViewsList_Server(CFErrorRef*);
117
118 bool SOSWrapToBackupSliceKeyBagForView_Server(CFStringRef viewName, CFDataRef input, CFDataRef* output, CFDataRef* bskbEncoded, CFErrorRef* error);
119
120 SOSBackupSliceKeyBagRef SOSBackupSliceKeyBagForView(CFStringRef viewName, CFErrorRef* error);
121 CF_RETURNS_RETAINED CFDataRef SOSWrapToBackupSliceKeyBag(SOSBackupSliceKeyBagRef bskb, CFDataRef input, CFErrorRef* error);
122
123 //
124 // MARK: Internal kicks.
125 //
126 CF_RETURNS_RETAINED CFArrayRef SOSCCHandleUpdateMessage(CFDictionaryRef updates);
127
128
129 // Expected to be called when the data source changes.
130 void SOSCCRequestSyncWithPeer(CFStringRef peerID);
131 void SOSCCRequestSyncWithPeers(CFSetRef /*SOSPeerInfoRef/CFStringRef*/ peerIDs);
132 void SOSCCRequestSyncWithPeersList(CFArrayRef /*CFStringRef*/ peerIDs);
133 void SOSCCRequestSyncWithBackupPeer(CFStringRef backupPeerId);
134
135 bool SOSCCIsSyncPendingFor(CFStringRef peerID, CFErrorRef *error);
136
137 void SOSCCEnsurePeerRegistration(void);
138 typedef void (^SOSAccountSyncablePeersBlock)(CFArrayRef trustedPeers, CFArrayRef addedPeers, CFArrayRef removedPeers);
139
140 dispatch_queue_t SOSCCGetAccountQueue(void);
141
142 CFTypeRef GetSharedAccountRef(void); // returns SOSAccount* but this header is imported by C files, so we cast through CFTypeRef
143
144 //
145 // MARK: Internal access to local account for tests.
146 //
147 CFTypeRef SOSKeychainAccountGetSharedAccount(void);
148 //
149 // MARK: Internal SPIs for testing
150 //
151 CFStringRef CopyOSVersion(void);
152 CFDataRef SOSCCCopyAccountState_Server(CFErrorRef* error);
153 CFDataRef SOSCCCopyEngineData_Server(CFErrorRef* error);
154 bool SOSCCDeleteEngineState_Server(CFErrorRef* error);
155 bool SOSCCDeleteAccountState_Server(CFErrorRef* error);
156
157
158 //
159 // MARK: Testing operations, dangerous to call in normal operation.
160 //
161 bool SOSKeychainSaveAccountDataAndPurge(CFErrorRef *error);
162
163 //
164 // MARK: Constants for where we store persistent information in the keychain
165 //
166
167 extern CFStringRef kSOSAccountLabel;
168 extern CFStringRef kSOSPeerDataLabel;
169
170 CFDataRef SOSItemCopy(CFStringRef label, CFErrorRef* error);
171 bool SOSItemUpdateOrAdd(CFStringRef label, CFStringRef accessibility, CFDataRef data, CFErrorRef *error);
172
173 bool SOSCCSetEscrowRecord_Server(CFStringRef escrow_label, uint64_t tries, CFErrorRef *error);
174 CFDictionaryRef SOSCCCopyEscrowRecord_Server(CFErrorRef *error);
175 bool SOSCCRegisterRecoveryPublicKey_Server(CFDataRef recovery_key, CFErrorRef *error);
176 CFDataRef SOSCCCopyRecoveryPublicKey_Server(CFErrorRef *error);
177
178 CFDictionaryRef SOSCCCopyBackupInformation_Server(CFErrorRef *error);
179
180 SOSPeerInfoRef SOSCCCopyApplication_Server(CFErrorRef *error);
181 CFDataRef SOSCCCopyCircleJoiningBlob_Server(SOSPeerInfoRef applicant, CFErrorRef *error);
182 bool SOSCCJoinWithCircleJoiningBlob_Server(CFDataRef joiningBlob, PiggyBackProtocolVersion version, CFErrorRef *error);
183 CFDataRef SOSCCCopyInitialSyncData_Server(CFErrorRef *error);
184 bool SOSCCCleanupKVSKeys_Server(CFErrorRef *error);
185
186 bool SOSCCAccountHasPublicKey_Server(CFErrorRef *error);
187 bool SOSCCAccountIsNew_Server(CFErrorRef *error);
188 bool SOSCCTestPopulateKVSWithBadKeys_Server(CFErrorRef *error);
189
190 void sync_the_last_data_to_kvs(CFTypeRef account, bool waitForeverForSynchronization);
191
192 bool SOSCCMessageFromPeerIsPending_Server(SOSPeerInfoRef peer, CFErrorRef *error);
193 bool SOSCCSendToPeerIsPending_Server(SOSPeerInfoRef peer, CFErrorRef *error);
194 XPC_RETURNS_RETAINED xpc_endpoint_t SOSCCCreateSOSEndpoint_server(CFErrorRef *error);
195
196 void SOSCCPerformWithOctagonSigningKey(void (^action)(SecKeyRef octagonPrivKey, CFErrorRef error));
197 void SOSCCResetOTRNegotiation_Server(CFStringRef peerid);
198 void SOSCCPeerRateLimiterSendNextMessage_Server(CFStringRef peerid, CFStringRef accessGroup);
199
200 __END_DECLS
201
202 #endif