]> git.saurik.com Git - apple/security.git/blob - keychain/securityd/SOSCloudCircleServer.h
Security-59306.41.2.tar.gz
[apple/security.git] / keychain / 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 #include "keychain/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, CFStringRef dsid, 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 bool SOSCCSetUserCredentialsAndDSIDWithAnalytics_Server(CFStringRef user_label, CFDataRef user_password, CFStringRef dsid, CFDataRef parentEvent, CFErrorRef *error);
42
43 bool SOSCCCanAuthenticate_Server(CFErrorRef *error);
44 bool SOSCCPurgeUserCredentials_Server(CFErrorRef *error);
45
46 SOSCCStatus SOSCCThisDeviceIsInCircle_Server(CFErrorRef *error);
47 bool SOSCCRequestToJoinCircle_Server(CFErrorRef* error);
48 bool SOSCCRequestToJoinCircleWithAnalytics_Server(CFDataRef parentEvent, CFErrorRef* error);
49 bool SOSCCRequestToJoinCircleAfterRestore_Server(CFErrorRef* error);
50 bool SOSCCRequestToJoinCircleAfterRestoreWithAnalytics_Server(CFDataRef parentEvent, CFErrorRef* error);
51
52 bool SOSCCRemoveThisDeviceFromCircle_Server(CFErrorRef* error);
53 bool SOSCCRemoveThisDeviceFromCircleWithAnalytics_Server(CFDataRef parentEvent, CFErrorRef* error);
54 bool SOSCCRemovePeersFromCircle_Server(CFArrayRef peers, CFErrorRef* error);
55 bool SOSCCRemovePeersFromCircleWithAnalytics_Server(CFArrayRef peers, CFDataRef parentEvent, CFErrorRef* error);
56 bool SOSCCLoggedOutOfAccount_Server(CFErrorRef *error);
57 bool SOSCCBailFromCircle_Server(uint64_t limit_in_seconds, CFErrorRef* error);
58 bool SOSCCRequestEnsureFreshParameters_Server(CFErrorRef* error);
59
60
61 bool SOSCCApplyToARing_Server(CFStringRef ringName, CFErrorRef *error);
62 bool SOSCCWithdrawlFromARing_Server(CFStringRef ringName, CFErrorRef *error);
63 SOSRingStatus SOSCCRingStatus_Server(CFStringRef ringName, CFErrorRef *error);
64 CF_RETURNS_RETAINED CFStringRef SOSCCGetAllTheRings_Server(CFErrorRef *error);
65 bool SOSCCEnableRing_Server(CFStringRef ringName, CFErrorRef *error);
66
67
68 CFArrayRef SOSCCCopyGenerationPeerInfo_Server(CFErrorRef* error);
69 CFArrayRef SOSCCCopyApplicantPeerInfo_Server(CFErrorRef* error);
70 CFArrayRef SOSCCCopyValidPeerPeerInfo_Server(CFErrorRef* error);
71 bool SOSCCValidateUserPublic_Server(CFErrorRef* error);
72
73 CFArrayRef SOSCCCopyNotValidPeerPeerInfo_Server(CFErrorRef* error);
74 CFArrayRef SOSCCCopyRetirementPeerInfo_Server(CFErrorRef* error);
75 CFArrayRef SOSCCCopyViewUnawarePeerInfo_Server(CFErrorRef* error);
76 bool SOSCCRejectApplicants_Server(CFArrayRef applicants, CFErrorRef* error);
77 bool SOSCCAcceptApplicants_Server(CFArrayRef applicants, CFErrorRef* error);
78
79 SOSPeerInfoRef SOSCCCopyMyPeerInfo_Server(CFErrorRef* error);
80 CFArrayRef SOSCCCopyEngineState_Server(CFErrorRef* error);
81
82 CFArrayRef SOSCCCopyPeerPeerInfo_Server(CFErrorRef* error);
83 CFArrayRef SOSCCCopyConcurringPeerPeerInfo_Server(CFErrorRef* error);
84 bool SOSCCkSecXPCOpIsThisDeviceLastBackup_Server(CFErrorRef *error);
85 bool SOSCCkSecXPCOpIsThisDeviceLastBackup_Server(CFErrorRef *error);
86 bool SOSCCAccountSetToNew_Server(CFErrorRef *error);
87 bool SOSCCResetToOffering_Server(CFErrorRef* error);
88 bool SOSCCResetToEmpty_Server(CFErrorRef* error);
89 bool SOSCCResetToEmptyWithAnalytics_Server(CFDataRef parentEvent, CFErrorRef* error);
90
91 CFBooleanRef SOSCCPeersHaveViewsEnabled_Server(CFArrayRef viewNames, CFErrorRef *error);
92
93 SOSViewResultCode SOSCCView_Server(CFStringRef view, SOSViewActionCode action, CFErrorRef *error);
94 bool SOSCCViewSetWithAnalytics_Server(CFSetRef enabledViews, CFSetRef disabledViews, CFDataRef parentEvent);
95 bool SOSCCViewSet_Server(CFSetRef enabledViews, CFSetRef disabledViews);
96
97 CFStringRef SOSCCCopyIncompatibilityInfo_Server(CFErrorRef* error);
98 enum DepartureReason SOSCCGetLastDepartureReason_Server(CFErrorRef* error);
99 bool SOSCCSetLastDepartureReason_Server(enum DepartureReason reason, CFErrorRef *error);
100
101 bool SOSCCProcessEnsurePeerRegistration_Server(CFErrorRef* error);
102
103 CF_RETURNS_RETAINED CFSetRef SOSCCProcessSyncWithPeers_Server(CFSetRef peers, CFSetRef backupPeers, CFErrorRef *error);
104 SyncWithAllPeersReason SOSCCProcessSyncWithAllPeers_Server(CFErrorRef* error);
105
106 SOSPeerInfoRef SOSCCSetNewPublicBackupKey_Server(CFDataRef newPublicBackup, CFErrorRef *error);
107 bool SOSCCRegisterSingleRecoverySecret_Server(CFDataRef backupSlice, bool setupV0Only, CFErrorRef *error);
108
109 bool SOSCCWaitForInitialSync_Server(CFErrorRef*);
110 bool SOSCCWaitForInitialSyncWithAnalytics_Server(CFDataRef parentEvent, CFErrorRef* error);
111 CFArrayRef SOSCCCopyYetToSyncViewsList_Server(CFErrorRef*);
112
113 bool SOSWrapToBackupSliceKeyBagForView_Server(CFStringRef viewName, CFDataRef input, CFDataRef* output, CFDataRef* bskbEncoded, CFErrorRef* error);
114
115 SOSBackupSliceKeyBagRef SOSBackupSliceKeyBagForView(CFStringRef viewName, CFErrorRef* error);
116 CF_RETURNS_RETAINED CFDataRef SOSWrapToBackupSliceKeyBag(SOSBackupSliceKeyBagRef bskb, CFDataRef input, CFErrorRef* error);
117
118 //
119 // MARK: Internal kicks.
120 //
121 CF_RETURNS_RETAINED CFArrayRef SOSCCHandleUpdateMessage(CFDictionaryRef updates);
122
123
124 // Expected to be called when the data source changes.
125 void SOSCCRequestSyncWithPeer(CFStringRef peerID);
126 void SOSCCRequestSyncWithPeers(CFSetRef /*SOSPeerInfoRef/CFStringRef*/ peerIDs);
127 void SOSCCRequestSyncWithPeersList(CFArrayRef /*CFStringRef*/ peerIDs);
128 void SOSCCRequestSyncWithBackupPeer(CFStringRef backupPeerId);
129 bool SOSCCIsSyncPendingFor(CFStringRef peerID, CFErrorRef *error);
130
131 void SOSCCEnsurePeerRegistration(void);
132 typedef void (^SOSAccountSyncablePeersBlock)(CFArrayRef trustedPeers, CFArrayRef addedPeers, CFArrayRef removedPeers);
133
134 dispatch_queue_t SOSCCGetAccountQueue(void);
135
136 CFTypeRef GetSharedAccountRef(void); // returns SOSAccount* but this header is imported by C files, so we cast through CFTypeRef
137
138 //
139 // MARK: Internal access to local account for tests.
140 //
141 CFTypeRef SOSKeychainAccountGetSharedAccount(void);
142 //
143 // MARK: Internal SPIs for testing
144 //
145
146 void SOSCCSetGestalt_Server(CFStringRef name, CFStringRef version, CFStringRef model, CFStringRef serial);
147 CFStringRef SOSCCCopyOSVersion(void);
148 CFDataRef SOSCCCopyAccountState_Server(CFErrorRef* error);
149 CFDataRef SOSCCCopyEngineData_Server(CFErrorRef* error);
150 bool SOSCCDeleteEngineState_Server(CFErrorRef* error);
151 bool SOSCCDeleteAccountState_Server(CFErrorRef* error);
152
153
154 //
155 // MARK: Testing operations, dangerous to call in normal operation.
156 //
157 bool SOSKeychainSaveAccountDataAndPurge(CFErrorRef *error);
158
159 //
160 // MARK: Constants for where we store persistent information in the keychain
161 //
162
163 extern CFStringRef kSOSAccountLabel;
164 extern CFStringRef kSOSPeerDataLabel;
165
166 CFDataRef SOSItemCopy(CFStringRef label, CFErrorRef* error);
167 bool SOSItemUpdateOrAdd(CFStringRef label, CFStringRef accessibility, CFDataRef data, CFErrorRef *error);
168
169 bool SOSCCSetEscrowRecord_Server(CFStringRef escrow_label, uint64_t tries, CFErrorRef *error);
170 CFDictionaryRef SOSCCCopyEscrowRecord_Server(CFErrorRef *error);
171 bool SOSCCRegisterRecoveryPublicKey_Server(CFDataRef recovery_key, CFErrorRef *error);
172 CFDataRef SOSCCCopyRecoveryPublicKey_Server(CFErrorRef *error);
173
174 CFDictionaryRef SOSCCCopyBackupInformation_Server(CFErrorRef *error);
175
176 SOSPeerInfoRef SOSCCCopyApplication_Server(CFErrorRef *error);
177 CFDataRef SOSCCCopyCircleJoiningBlob_Server(SOSPeerInfoRef applicant, CFErrorRef *error);
178 bool SOSCCJoinWithCircleJoiningBlob_Server(CFDataRef joiningBlob, PiggyBackProtocolVersion version, CFErrorRef *error);
179 CFDataRef SOSCCCopyInitialSyncData_Server(uint32_t flags, CFErrorRef *error);
180 bool SOSCCCleanupKVSKeys_Server(CFErrorRef *error);
181
182 bool SOSCCAccountHasPublicKey_Server(CFErrorRef *error);
183 bool SOSCCAccountIsNew_Server(CFErrorRef *error);
184 bool SOSCCTestPopulateKVSWithBadKeys_Server(CFErrorRef *error);
185
186 void sync_the_last_data_to_kvs(CFTypeRef account, bool waitForeverForSynchronization);
187
188 bool SOSCCMessageFromPeerIsPending_Server(SOSPeerInfoRef peer, CFErrorRef *error);
189 bool SOSCCSendToPeerIsPending_Server(SOSPeerInfoRef peer, CFErrorRef *error);
190
191 void SOSCCPerformWithOctagonSigningKey(void (^action)(SecKeyRef octagonPrivKey, CFErrorRef error));
192 void SOSCCPerformWithOctagonSigningPublicKey(void (^action)(SecKeyRef octagonPublicKey, CFErrorRef error));
193 void SOSCCPerformWithOctagonEncryptionKey(void (^action)(SecKeyRef octagonPrivEncryptionKey, CFErrorRef error));
194 void SOSCCPerformWithOctagonEncryptionPublicKey(void (^action)(SecKeyRef octagonPublicEncryptionKey, CFErrorRef error));
195 void SOSCCPerformWithAllOctagonKeys(void (^action)(SecKeyRef octagonEncryptionKey, SecKeyRef octagonSigningKey, CFErrorRef error));
196 void SOSCCPerformWithTrustedPeers(void (^action)(CFSetRef sosPeerInfoRefs, CFErrorRef error));
197 void SOSCCPerformWithPeerID(void (^action)(CFStringRef peerID, CFErrorRef error));
198 void SOSCCPerformUpdateOfAllOctagonKeys(CFDataRef octagonSigningFullKey, CFDataRef octagonEncryptionFullKey,
199 CFDataRef signingPublicKey, CFDataRef encryptionPublicKey,
200 SecKeyRef octagonSigningPublicKeyRef, SecKeyRef octagonEncryptionPublicKeyRef,
201 void (^action)(CFErrorRef error));
202
203 void SOSCCResetOTRNegotiation_Server(CFStringRef peerid);
204 void SOSCCPeerRateLimiterSendNextMessage_Server(CFStringRef peerid, CFStringRef accessGroup);
205
206 __END_DECLS
207
208 #endif