]> git.saurik.com Git - apple/security.git/blob - keychain/securityd/SOSCloudCircleServer.h
Security-59306.80.4.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 SOSCCRequestSyncWithBackupPeerList(CFArrayRef /* CFStringRef */ backupPeerIDs);
129 bool SOSCCIsSyncPendingFor(CFStringRef peerID, CFErrorRef *error);
130
131 void SOSCCAccountTriggerSyncWithBackupPeer_server(CFStringRef peer);
132
133 void SOSCCEnsurePeerRegistration(void);
134 typedef void (^SOSAccountSyncablePeersBlock)(CFArrayRef trustedPeers, CFArrayRef addedPeers, CFArrayRef removedPeers);
135
136 dispatch_queue_t SOSCCGetAccountQueue(void);
137
138 CFTypeRef GetSharedAccountRef(void); // returns SOSAccount* but this header is imported by C files, so we cast through CFTypeRef
139
140 //
141 // MARK: Internal access to local account for tests.
142 //
143 CFTypeRef SOSKeychainAccountGetSharedAccount(void);
144 //
145 // MARK: Internal SPIs for testing
146 //
147
148 void SOSCCSetGestalt_Server(CFStringRef name, CFStringRef version, CFStringRef model, CFStringRef serial);
149 CFStringRef SOSCCCopyOSVersion(void);
150 CFDataRef SOSCCCopyAccountState_Server(CFErrorRef* error);
151 CFDataRef SOSCCCopyEngineData_Server(CFErrorRef* error);
152 bool SOSCCDeleteEngineState_Server(CFErrorRef* error);
153 bool SOSCCDeleteAccountState_Server(CFErrorRef* error);
154
155
156 //
157 // MARK: Testing operations, dangerous to call in normal operation.
158 //
159 bool SOSKeychainSaveAccountDataAndPurge(CFErrorRef *error);
160
161 //
162 // MARK: Constants for where we store persistent information in the keychain
163 //
164
165 extern CFStringRef kSOSAccountLabel;
166 extern CFStringRef kSOSPeerDataLabel;
167
168 CFDataRef SOSItemCopy(CFStringRef label, CFErrorRef* error);
169 bool SOSItemUpdateOrAdd(CFStringRef label, CFStringRef accessibility, CFDataRef data, CFErrorRef *error);
170
171 bool SOSCCSetEscrowRecord_Server(CFStringRef escrow_label, uint64_t tries, CFErrorRef *error);
172 CFDictionaryRef SOSCCCopyEscrowRecord_Server(CFErrorRef *error);
173 bool SOSCCRegisterRecoveryPublicKey_Server(CFDataRef recovery_key, CFErrorRef *error);
174 CFDataRef SOSCCCopyRecoveryPublicKey_Server(CFErrorRef *error);
175
176 CFDictionaryRef SOSCCCopyBackupInformation_Server(CFErrorRef *error);
177
178 SOSPeerInfoRef SOSCCCopyApplication_Server(CFErrorRef *error);
179 CFDataRef SOSCCCopyCircleJoiningBlob_Server(SOSPeerInfoRef applicant, CFErrorRef *error);
180 bool SOSCCJoinWithCircleJoiningBlob_Server(CFDataRef joiningBlob, PiggyBackProtocolVersion version, CFErrorRef *error);
181 CFDataRef SOSCCCopyInitialSyncData_Server(uint32_t flags, CFErrorRef *error);
182 bool SOSCCCleanupKVSKeys_Server(CFErrorRef *error);
183
184 bool SOSCCAccountHasPublicKey_Server(CFErrorRef *error);
185 bool SOSCCAccountIsNew_Server(CFErrorRef *error);
186 bool SOSCCTestPopulateKVSWithBadKeys_Server(CFErrorRef *error);
187
188 void sync_the_last_data_to_kvs(CFTypeRef account, bool waitForeverForSynchronization);
189
190 bool SOSCCMessageFromPeerIsPending_Server(SOSPeerInfoRef peer, CFErrorRef *error);
191 bool SOSCCSendToPeerIsPending_Server(SOSPeerInfoRef peer, CFErrorRef *error);
192
193 void SOSCCPerformWithOctagonSigningKey(void (^action)(SecKeyRef octagonPrivKey, CFErrorRef error));
194 void SOSCCPerformWithOctagonSigningPublicKey(void (^action)(SecKeyRef octagonPublicKey, CFErrorRef error));
195 void SOSCCPerformWithOctagonEncryptionKey(void (^action)(SecKeyRef octagonPrivEncryptionKey, CFErrorRef error));
196 void SOSCCPerformWithOctagonEncryptionPublicKey(void (^action)(SecKeyRef octagonPublicEncryptionKey, CFErrorRef error));
197 void SOSCCPerformWithAllOctagonKeys(void (^action)(SecKeyRef octagonEncryptionKey, SecKeyRef octagonSigningKey, CFErrorRef error));
198 void SOSCCPerformWithTrustedPeers(void (^action)(CFSetRef sosPeerInfoRefs, CFErrorRef error));
199 void SOSCCPerformWithPeerID(void (^action)(CFStringRef peerID, CFErrorRef error));
200 void SOSCCPerformUpdateOfAllOctagonKeys(CFDataRef octagonSigningFullKey, CFDataRef octagonEncryptionFullKey,
201 CFDataRef signingPublicKey, CFDataRef encryptionPublicKey,
202 SecKeyRef octagonSigningPublicKeyRef, SecKeyRef octagonEncryptionPublicKeyRef,
203 void (^action)(CFErrorRef error));
204
205 void SOSCCResetOTRNegotiation_Server(CFStringRef peerid);
206 void SOSCCPeerRateLimiterSendNextMessage_Server(CFStringRef peerid, CFStringRef accessGroup);
207
208 __END_DECLS
209
210 #endif