]> git.saurik.com Git - apple/security.git/blob - keychain/securityd/SOSCloudCircleServer.h
Security-59754.80.3.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
39 bool SOSCCTryUserCredentials_Server(CFStringRef user_label, CFDataRef user_password, CFStringRef dsid, CFErrorRef *error);
40 bool SOSCCSetUserCredentials_Server(CFStringRef user_label, CFDataRef user_password, CFErrorRef *error);
41 bool SOSCCSetUserCredentialsAndDSID_Server(CFStringRef user_label, CFDataRef user_password, CFStringRef dsid, 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 SOSCCRequestToJoinCircleAfterRestore_Server(CFErrorRef* error);
49
50 bool SOSCCRemoveThisDeviceFromCircle_Server(CFErrorRef* error);
51 bool SOSCCRemovePeersFromCircle_Server(CFArrayRef peers, CFErrorRef* error);
52
53 // This will async off the notification, so it does not return a value.
54 void SOSCCNotifyLoggedIntoAccount_Server(void);
55
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
79 CFBooleanRef SOSCCPeersHaveViewsEnabled_Server(CFArrayRef viewNames, CFErrorRef *error);
80
81 SOSViewResultCode SOSCCView_Server(CFStringRef view, SOSViewActionCode action, CFErrorRef *error);
82 bool SOSCCViewSet_Server(CFSetRef enabledViews, CFSetRef disabledViews);
83
84 enum DepartureReason SOSCCGetLastDepartureReason_Server(CFErrorRef* error);
85 bool SOSCCSetLastDepartureReason_Server(enum DepartureReason reason, CFErrorRef *error);
86
87 bool SOSCCProcessEnsurePeerRegistration_Server(CFErrorRef* error);
88
89 CF_RETURNS_RETAINED CFSetRef SOSCCProcessSyncWithPeers_Server(CFSetRef peers, CFSetRef backupPeers, CFErrorRef *error);
90 SyncWithAllPeersReason SOSCCProcessSyncWithAllPeers_Server(CFErrorRef* error);
91
92 SOSPeerInfoRef SOSCCSetNewPublicBackupKey_Server(CFDataRef newPublicBackup, CFErrorRef *error);
93 bool SOSCCRegisterSingleRecoverySecret_Server(CFDataRef backupSlice, bool setupV0Only, CFErrorRef *error);
94
95 bool SOSCCWaitForInitialSync_Server(CFErrorRef*);
96
97 //
98 // MARK: Internal kicks.
99 //
100 CF_RETURNS_RETAINED CFArrayRef SOSCCHandleUpdateMessage(CFDictionaryRef updates);
101
102
103 // Expected to be called when the data source changes.
104 void SOSCCRequestSyncWithPeer(CFStringRef peerID);
105 void SOSCCRequestSyncWithPeers(CFSetRef /*SOSPeerInfoRef/CFStringRef*/ peerIDs);
106 void SOSCCRequestSyncWithPeersList(CFArrayRef /*CFStringRef*/ peerIDs);
107 void SOSCCRequestSyncWithBackupPeerList(CFArrayRef /* CFStringRef */ backupPeerIDs);
108 bool SOSCCIsSyncPendingFor(CFStringRef peerID, CFErrorRef *error);
109
110 void SOSCCAccountTriggerSyncWithBackupPeer_server(CFStringRef peer);
111
112 void SOSCCEnsurePeerRegistration(void);
113 typedef void (^SOSAccountSyncablePeersBlock)(CFArrayRef trustedPeers, CFArrayRef addedPeers, CFArrayRef removedPeers);
114
115 dispatch_queue_t SOSCCGetAccountQueue(void);
116
117 CFTypeRef GetSharedAccountRef(void); // returns SOSAccount* but this header is imported by C files, so we cast through CFTypeRef
118
119 //
120 // MARK: Internal access to local account for tests.
121 //
122 CFTypeRef SOSKeychainAccountGetSharedAccount(void);
123 //
124 // MARK: Internal SPIs for testing
125 //
126
127 void SOSCCSetGestalt_Server(CFStringRef name, CFStringRef version, CFStringRef model, CFStringRef serial);
128 CFStringRef SOSCCCopyOSVersion(void);
129
130 //
131 // MARK: Testing operations, dangerous to call in normal operation.
132 //
133 bool SOSKeychainSaveAccountDataAndPurge(CFErrorRef *error);
134
135 //
136 // MARK: Constants for where we store persistent information in the keychain
137 //
138
139 extern CFStringRef kSOSAccountLabel;
140 extern CFStringRef kSOSPeerDataLabel;
141
142 CFDataRef SOSItemCopy(CFStringRef label, CFErrorRef* error);
143 bool SOSItemUpdateOrAdd(CFStringRef label, CFStringRef accessibility, CFDataRef data, CFErrorRef *error);
144
145 bool SOSCCRegisterRecoveryPublicKey_Server(CFDataRef recovery_key, CFErrorRef *error);
146 CFDataRef SOSCCCopyRecoveryPublicKey_Server(CFErrorRef *error);
147
148 SOSPeerInfoRef SOSCCCopyApplication_Server(CFErrorRef *error);
149 CFDataRef SOSCCCopyCircleJoiningBlob_Server(SOSPeerInfoRef applicant, CFErrorRef *error);
150 bool SOSCCJoinWithCircleJoiningBlob_Server(CFDataRef joiningBlob, PiggyBackProtocolVersion version, CFErrorRef *error);
151 CFDataRef SOSCCCopyInitialSyncData_Server(uint32_t flags, CFErrorRef *error);
152 bool SOSCCCleanupKVSKeys_Server(CFErrorRef *error);
153
154 bool SOSCCAccountHasPublicKey_Server(CFErrorRef *error);
155
156 void sync_the_last_data_to_kvs(CFTypeRef account, bool waitForeverForSynchronization);
157
158 bool SOSCCMessageFromPeerIsPending_Server(SOSPeerInfoRef peer, CFErrorRef *error);
159 bool SOSCCSendToPeerIsPending_Server(SOSPeerInfoRef peer, CFErrorRef *error);
160
161 void SOSCCPerformWithOctagonSigningKey(void (^action)(SecKeyRef octagonPrivKey, CFErrorRef error));
162 void SOSCCPerformWithOctagonSigningPublicKey(void (^action)(SecKeyRef octagonPublicKey, CFErrorRef error));
163 void SOSCCPerformWithOctagonEncryptionKey(void (^action)(SecKeyRef octagonPrivEncryptionKey, CFErrorRef error));
164 void SOSCCPerformWithOctagonEncryptionPublicKey(void (^action)(SecKeyRef octagonPublicEncryptionKey, CFErrorRef error));
165 void SOSCCPerformWithAllOctagonKeys(void (^action)(SecKeyRef octagonEncryptionKey, SecKeyRef octagonSigningKey, CFErrorRef error));
166 void SOSCCPerformWithTrustedPeers(void (^action)(CFSetRef sosPeerInfoRefs, CFErrorRef error));
167 void SOSCCPerformWithPeerID(void (^action)(CFStringRef peerID, CFErrorRef error));
168 void SOSCCPerformUpdateOfAllOctagonKeys(CFDataRef octagonSigningFullKey, CFDataRef octagonEncryptionFullKey,
169 CFDataRef signingPublicKey, CFDataRef encryptionPublicKey,
170 SecKeyRef octagonSigningPublicKeyRef, SecKeyRef octagonEncryptionPublicKeyRef,
171 void (^action)(CFErrorRef error));
172 void SOSCCPerformPreloadOfAllOctagonKeys(CFDataRef octagonSigningFullKey, CFDataRef octagonEncryptionFullKey,
173 SecKeyRef octagonSigningFullKeyRef, SecKeyRef octagonEncryptionFullKeyRef,
174 SecKeyRef octagonSigningPublicKeyRef, SecKeyRef octagonEncryptionPublicKeyRef,
175 void (^action)(CFErrorRef error));
176
177 bool SOSCCSetCKKS4AllStatus(bool status, CFErrorRef* error);
178
179 void SOSCCResetOTRNegotiation_Server(CFStringRef peerid);
180 void SOSCCPeerRateLimiterSendNextMessage_Server(CFStringRef peerid, CFStringRef accessGroup);
181
182 #if __OBJC2__
183 bool SOSCCSaveOctagonKeysToKeychain(NSString* keyLabel, NSData* keyDataToSave, __unused int keySize, SecKeyRef octagonPublicKey, NSError** error);
184 void SOSCCEnsureAccessGroupOfKey(SecKeyRef publicKey, NSString* oldAgrp, NSString* newAgrp);
185 #endif
186
187 __END_DECLS
188
189 #endif