]> git.saurik.com Git - apple/security.git/blob - keychain/securityd/SOSCloudCircleServer.h
0bb84b8be754b8f7c7ddb3f2d57e7380b3b0bf49
[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
59 CFArrayRef SOSCCCopyGenerationPeerInfo_Server(CFErrorRef* error);
60 CFArrayRef SOSCCCopyApplicantPeerInfo_Server(CFErrorRef* error);
61 CFArrayRef SOSCCCopyValidPeerPeerInfo_Server(CFErrorRef* error);
62 bool SOSCCValidateUserPublic_Server(CFErrorRef* error);
63
64 CFArrayRef SOSCCCopyNotValidPeerPeerInfo_Server(CFErrorRef* error);
65 CFArrayRef SOSCCCopyRetirementPeerInfo_Server(CFErrorRef* error);
66 CFArrayRef SOSCCCopyViewUnawarePeerInfo_Server(CFErrorRef* error);
67 bool SOSCCRejectApplicants_Server(CFArrayRef applicants, CFErrorRef* error);
68 bool SOSCCAcceptApplicants_Server(CFArrayRef applicants, CFErrorRef* error);
69
70 SOSPeerInfoRef SOSCCCopyMyPeerInfo_Server(CFErrorRef* error);
71 CFArrayRef SOSCCCopyEngineState_Server(CFErrorRef* error);
72
73 CFArrayRef SOSCCCopyPeerPeerInfo_Server(CFErrorRef* error);
74 CFArrayRef SOSCCCopyConcurringPeerPeerInfo_Server(CFErrorRef* error);
75 bool SOSCCAccountSetToNew_Server(CFErrorRef *error);
76 bool SOSCCResetToOffering_Server(CFErrorRef* error);
77 bool SOSCCResetToEmpty_Server(CFErrorRef* error);
78 bool SOSCCResetToEmptyWithAnalytics_Server(CFDataRef parentEvent, CFErrorRef* error);
79
80 CFBooleanRef SOSCCPeersHaveViewsEnabled_Server(CFArrayRef viewNames, CFErrorRef *error);
81
82 SOSViewResultCode SOSCCView_Server(CFStringRef view, SOSViewActionCode action, CFErrorRef *error);
83 bool SOSCCViewSetWithAnalytics_Server(CFSetRef enabledViews, CFSetRef disabledViews, CFDataRef parentEvent);
84 bool SOSCCViewSet_Server(CFSetRef enabledViews, CFSetRef disabledViews);
85
86 enum DepartureReason SOSCCGetLastDepartureReason_Server(CFErrorRef* error);
87 bool SOSCCSetLastDepartureReason_Server(enum DepartureReason reason, CFErrorRef *error);
88
89 bool SOSCCProcessEnsurePeerRegistration_Server(CFErrorRef* error);
90
91 CF_RETURNS_RETAINED CFSetRef SOSCCProcessSyncWithPeers_Server(CFSetRef peers, CFSetRef backupPeers, CFErrorRef *error);
92 SyncWithAllPeersReason SOSCCProcessSyncWithAllPeers_Server(CFErrorRef* error);
93
94 SOSPeerInfoRef SOSCCSetNewPublicBackupKey_Server(CFDataRef newPublicBackup, CFErrorRef *error);
95 bool SOSCCRegisterSingleRecoverySecret_Server(CFDataRef backupSlice, bool setupV0Only, CFErrorRef *error);
96
97 bool SOSCCWaitForInitialSync_Server(CFErrorRef*);
98 bool SOSCCWaitForInitialSyncWithAnalytics_Server(CFDataRef parentEvent, CFErrorRef* error);
99
100 //
101 // MARK: Internal kicks.
102 //
103 CF_RETURNS_RETAINED CFArrayRef SOSCCHandleUpdateMessage(CFDictionaryRef updates);
104
105
106 // Expected to be called when the data source changes.
107 void SOSCCRequestSyncWithPeer(CFStringRef peerID);
108 void SOSCCRequestSyncWithPeers(CFSetRef /*SOSPeerInfoRef/CFStringRef*/ peerIDs);
109 void SOSCCRequestSyncWithPeersList(CFArrayRef /*CFStringRef*/ peerIDs);
110 void SOSCCRequestSyncWithBackupPeerList(CFArrayRef /* CFStringRef */ backupPeerIDs);
111 bool SOSCCIsSyncPendingFor(CFStringRef peerID, CFErrorRef *error);
112
113 void SOSCCAccountTriggerSyncWithBackupPeer_server(CFStringRef peer);
114
115 void SOSCCEnsurePeerRegistration(void);
116 typedef void (^SOSAccountSyncablePeersBlock)(CFArrayRef trustedPeers, CFArrayRef addedPeers, CFArrayRef removedPeers);
117
118 dispatch_queue_t SOSCCGetAccountQueue(void);
119
120 CFTypeRef GetSharedAccountRef(void); // returns SOSAccount* but this header is imported by C files, so we cast through CFTypeRef
121
122 //
123 // MARK: Internal access to local account for tests.
124 //
125 CFTypeRef SOSKeychainAccountGetSharedAccount(void);
126 //
127 // MARK: Internal SPIs for testing
128 //
129
130 void SOSCCSetGestalt_Server(CFStringRef name, CFStringRef version, CFStringRef model, CFStringRef serial);
131 CFStringRef SOSCCCopyOSVersion(void);
132
133 //
134 // MARK: Testing operations, dangerous to call in normal operation.
135 //
136 bool SOSKeychainSaveAccountDataAndPurge(CFErrorRef *error);
137
138 //
139 // MARK: Constants for where we store persistent information in the keychain
140 //
141
142 extern CFStringRef kSOSAccountLabel;
143 extern CFStringRef kSOSPeerDataLabel;
144
145 CFDataRef SOSItemCopy(CFStringRef label, CFErrorRef* error);
146 bool SOSItemUpdateOrAdd(CFStringRef label, CFStringRef accessibility, CFDataRef data, CFErrorRef *error);
147
148 bool SOSCCRegisterRecoveryPublicKey_Server(CFDataRef recovery_key, CFErrorRef *error);
149 CFDataRef SOSCCCopyRecoveryPublicKey_Server(CFErrorRef *error);
150
151 SOSPeerInfoRef SOSCCCopyApplication_Server(CFErrorRef *error);
152 CFDataRef SOSCCCopyCircleJoiningBlob_Server(SOSPeerInfoRef applicant, CFErrorRef *error);
153 bool SOSCCJoinWithCircleJoiningBlob_Server(CFDataRef joiningBlob, PiggyBackProtocolVersion version, CFErrorRef *error);
154 CFDataRef SOSCCCopyInitialSyncData_Server(uint32_t flags, CFErrorRef *error);
155 bool SOSCCCleanupKVSKeys_Server(CFErrorRef *error);
156
157 bool SOSCCAccountHasPublicKey_Server(CFErrorRef *error);
158
159 void sync_the_last_data_to_kvs(CFTypeRef account, bool waitForeverForSynchronization);
160
161 bool SOSCCMessageFromPeerIsPending_Server(SOSPeerInfoRef peer, CFErrorRef *error);
162 bool SOSCCSendToPeerIsPending_Server(SOSPeerInfoRef peer, CFErrorRef *error);
163
164 void SOSCCPerformWithOctagonSigningKey(void (^action)(SecKeyRef octagonPrivKey, CFErrorRef error));
165 void SOSCCPerformWithOctagonSigningPublicKey(void (^action)(SecKeyRef octagonPublicKey, CFErrorRef error));
166 void SOSCCPerformWithOctagonEncryptionKey(void (^action)(SecKeyRef octagonPrivEncryptionKey, CFErrorRef error));
167 void SOSCCPerformWithOctagonEncryptionPublicKey(void (^action)(SecKeyRef octagonPublicEncryptionKey, CFErrorRef error));
168 void SOSCCPerformWithAllOctagonKeys(void (^action)(SecKeyRef octagonEncryptionKey, SecKeyRef octagonSigningKey, CFErrorRef error));
169 void SOSCCPerformWithTrustedPeers(void (^action)(CFSetRef sosPeerInfoRefs, CFErrorRef error));
170 void SOSCCPerformWithPeerID(void (^action)(CFStringRef peerID, CFErrorRef error));
171 void SOSCCPerformUpdateOfAllOctagonKeys(CFDataRef octagonSigningFullKey, CFDataRef octagonEncryptionFullKey,
172 CFDataRef signingPublicKey, CFDataRef encryptionPublicKey,
173 SecKeyRef octagonSigningPublicKeyRef, SecKeyRef octagonEncryptionPublicKeyRef,
174 void (^action)(CFErrorRef error));
175
176 void SOSCCResetOTRNegotiation_Server(CFStringRef peerid);
177 void SOSCCPeerRateLimiterSendNextMessage_Server(CFStringRef peerid, CFStringRef accessGroup);
178
179 __END_DECLS
180
181 #endif