2 * Copyright (c) 2017 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
24 #import <Foundation/Foundation.h>
26 #ifndef SECURITY_OT_OTCONTROLPROTOCOL_H
27 #define SECURITY_OT_OTCONTROLPROTOCOL_H 1
29 #import <Security/OTClique.h>
30 #import <Security/OTConstants.h>
33 NS_ASSUME_NONNULL_BEGIN
35 @
class OTJoiningConfiguration
;
37 @protocol OTControlProtocol
38 - (void)restore
:(NSString
*)contextID dsid
:(NSString
*)dsid secret
:(NSData
*)secret escrowRecordID
:(NSString
*)escrowRecordID reply
:(void (^)(NSData
* _Nullable signingKeyData
, NSData
* _Nullable encryptionKeyData
, NSError
* _Nullable error
))reply
;
39 - (void)octagonEncryptionPublicKey
:(void (^)(NSData
* _Nullable encryptionKey
, NSError
* _Nullable
))reply
;
40 - (void)octagonSigningPublicKey
:(void (^)(NSData
* _Nullable signingKey
, NSError
* _Nullable
))reply
;
41 - (void)listOfEligibleBottledPeerRecords
:(void (^)(NSArray
* _Nullable listOfRecords
, NSError
* _Nullable
))reply
;
43 // If you're not sure about container, pass nil. If you're not sure about context, pass OTDefaultContext.
44 - (void)signIn
:(NSString
*)altDSID
45 container
:(NSString
* _Nullable
)container
46 context
:(NSString
*)contextID
47 reply
:(void (^)(NSError
* _Nullable error
))reply
;
49 - (void)signOut
:(NSString
* _Nullable
)container
50 context
:(NSString
*)contextID
51 reply
:(void (^)(NSError
* _Nullable error
))reply
;
53 - (void)notifyIDMSTrustLevelChangeForContainer
:(NSString
* _Nullable
)container
54 context
:(NSString
*)contextID
55 reply
:(void (^)(NSError
* _Nullable error
))reply
;
57 - (void)reset
:(void (^)(BOOL result
, NSError
* _Nullable error
))reply
;
59 - (void)handleIdentityChangeForSigningKey
:(SFECKeyPair
*)peerSigningKey
60 ForEncryptionKey
:(SFECKeyPair
*)encryptionKey
61 ForPeerID
:(NSString
*)peerID
62 reply
:(void (^)(BOOL result
,
63 NSError
* _Nullable error
))reply
;
65 - (void)rpcEpochWithConfiguration
:(OTJoiningConfiguration
*)config
66 reply
:(void (^)(uint64_t epoch
,
67 NSError
* _Nullable error
))reply
;
69 - (void)rpcPrepareIdentityAsApplicantWithConfiguration
:(OTJoiningConfiguration
*)config
70 reply
:(void (^)(NSString
* _Nullable peerID
,
71 NSData
* _Nullable permanentInfo
,
72 NSData
* _Nullable permanentInfoSig
,
73 NSData
* _Nullable stableInfo
,
74 NSData
* _Nullable stableInfoSig
,
75 NSError
* _Nullable error
))reply
;
76 - (void)rpcVoucherWithConfiguration
:(OTJoiningConfiguration
*)config
77 peerID
:(NSString
*)peerID
78 permanentInfo
:(NSData
*)permanentInfo
79 permanentInfoSig
:(NSData
*)permanentInfoSig
80 stableInfo
:(NSData
*)stableInfo
81 stableInfoSig
:(NSData
*)stableInfoSig
82 reply
:(void (^)(NSData
* voucher
, NSData
* voucherSig
, NSError
* _Nullable error
))reply
;
84 - (void)rpcJoinWithConfiguration
:(OTJoiningConfiguration
*)config
85 vouchData
:(NSData
*)vouchData
86 vouchSig
:(NSData
*)vouchSig
87 reply
:(void (^)(NSError
* _Nullable error
))reply
;
89 - (void)preflightBottledPeer
:(NSString
*)contextID
91 reply
:(void (^)(NSData
* _Nullable entropy
,
92 NSString
* _Nullable bottleID
,
93 NSData
* _Nullable signingPublicKey
,
94 NSError
* _Nullable error
))reply
;
95 - (void)launchBottledPeer
:(NSString
*)contextID
96 bottleID
:(NSString
*)bottleID
97 reply
:(void (^ _Nullable
)(NSError
* _Nullable error
))reply
;
98 - (void)scrubBottledPeer
:(NSString
*)contextID
99 bottleID
:(NSString
*)bottleID
100 reply
:(void (^ _Nullable
)(NSError
* _Nullable error
))reply
;
102 - (void)status
:(NSString
* _Nullable
)container
103 context
:(NSString
*)context
104 reply
:(void (^)(NSDictionary
* _Nullable result
, NSError
* _Nullable error
))reply
;
106 - (void)fetchEgoPeerID
:(NSString
* _Nullable
)container
107 context
:(NSString
*)context
108 reply
:(void (^)(NSString
* _Nullable peerID
, NSError
* _Nullable error
))reply
;
110 - (void)fetchCliqueStatus
:(NSString
* _Nullable
)container
111 context
:(NSString
*)context
112 configuration
:(OTOperationConfiguration
*)configuration
113 reply
:(void (^)(CliqueStatus cliqueStatus
, NSError
* _Nullable error
))reply
;
115 - (void)fetchTrustStatus
:(NSString
* _Nullable
)container
116 context
:(NSString
*)context
117 configuration
:(OTOperationConfiguration
*)configuration
118 reply
:(void (^)(CliqueStatus status
,
119 NSString
* _Nullable peerID
,
120 NSNumber
* _Nullable numberOfPeersInOctagon
,
122 NSError
* _Nullable error
))reply
;
124 // Likely won't be used once Octagon is turned on for good
125 - (void)startOctagonStateMachine
:(NSString
* _Nullable
)container
126 context
:(NSString
*)context
127 reply
:(void (^)(NSError
* _Nullable error
))reply
;
129 - (void)resetAndEstablish
:(NSString
* _Nullable
)container
130 context
:(NSString
*)context
131 altDSID
:(NSString
*)altDSID
132 resetReason
:(CuttlefishResetReason
)resetReason
133 reply
:(void (^)(NSError
* _Nullable error
))reply
;
135 - (void)establish
:(NSString
* _Nullable
)container
136 context
:(NSString
*)context
137 altDSID
:(NSString
*)altDSID
138 reply
:(void (^)(NSError
* _Nullable
))reply
;
140 - (void)leaveClique
:(NSString
* _Nullable
)container
141 context
:(NSString
*)context
142 reply
:(void (^)(NSError
* _Nullable error
))reply
;
144 - (void)removeFriendsInClique
:(NSString
* _Nullable
)container
145 context
:(NSString
*)context
146 peerIDs
:(NSArray
<NSString
*>*)peerIDs
147 reply
:(void (^)(NSError
* _Nullable error
))reply
;
149 - (void)peerDeviceNamesByPeerID
:(NSString
* _Nullable
)container
150 context
:(NSString
*)context
151 reply
:(void (^)(NSDictionary
<NSString
*, NSString
*>* _Nullable peers
, NSError
* _Nullable error
))reply
;
153 - (void)fetchAllViableBottles
:(NSString
* _Nullable
)container
154 context
:(NSString
*)context
155 reply
:(void (^)(NSArray
<NSString
*>* _Nullable sortedBottleIDs
, NSArray
<NSString
*> * _Nullable sortedPartialBottleIDs
, NSError
* _Nullable error
))reply
;
157 -(void)restore
:(NSString
* _Nullable
)containerName
158 contextID
:(NSString
*)contextID
159 bottleSalt
:(NSString
*)bottleSalt
160 entropy
:(NSData
*)entropy
161 bottleID
:(NSString
*)bottleID
162 reply
:(void (^)(NSError
* _Nullable
))reply
;
164 - (void)fetchEscrowContents
:(NSString
* _Nullable
)containerName
165 contextID
:(NSString
*)contextID
166 reply
:(void (^)(NSData
* _Nullable entropy
,
167 NSString
* _Nullable bottleID
,
168 NSData
* _Nullable signingPublicKey
,
169 NSError
* _Nullable error
))reply
;
171 - (void) createRecoveryKey
:(NSString
* _Nullable
)containerName
172 contextID
:(NSString
*)contextID
173 recoveryKey
:(NSString
*)recoveryKey
174 reply
:(void (^)( NSError
* _Nullable
))reply
;
176 - (void) joinWithRecoveryKey
:(NSString
* _Nullable
)containerName
177 contextID
:(NSString
*)contextID
178 recoveryKey
:(NSString
*)recoveryKey
179 reply
:(void (^)(NSError
* _Nullable
))reply
;
181 - (void)healthCheck
:(NSString
* _Nullable
)container
182 context
:(NSString
*)context
183 skipRateLimitingCheck
:(BOOL
)skipRateLimitingCheck
184 reply
:(void (^)(NSError
*_Nullable error
))reply
;
186 - (void)waitForOctagonUpgrade
:(NSString
* _Nullable
)container
187 context
:(NSString
*)context
188 reply
:(void (^)(NSError
* _Nullable error
))reply
;
190 - (void)postCDPFollowupResult
:(BOOL
)success
191 type
:(OTCliqueCDPContextType
)type
192 error
:(NSError
* _Nullable
)error
193 containerName
:(NSString
* _Nullable
)containerName
194 contextName
:(NSString
*)contextName
195 reply
:(void (^)(NSError
* _Nullable error
))reply
;
197 - (void)tapToRadar
:(NSString
*)action
198 description
:(NSString
*)description
199 radar
:(NSString
*)radar
200 reply
:(void (^)(NSError
* _Nullable error
))reply
;
202 - (void)refetchCKKSPolicy
:(NSString
* _Nullable
)container
203 contextID
:(NSString
*)contextID
204 reply
:(void (^)(NSError
* _Nullable error
))reply
;
206 - (void)setCDPEnabled
:(NSString
* _Nullable
)containerName
207 contextID
:(NSString
*)contextID
208 reply
:(void (^)(NSError
* _Nullable error
))reply
;
210 - (void)getCDPStatus
:(NSString
* _Nullable
)containerName
211 contextID
:(NSString
*)contextID
212 reply
:(void (^)(OTCDPStatus status
, NSError
* _Nullable error
))reply
;
214 - (void)fetchEscrowRecords
:(NSString
* _Nullable
)container
215 contextID
:(NSString
*)contextID
216 forceFetch
:(BOOL
)forceFetch
217 reply
:(void (^)(NSArray
<NSData
*>* _Nullable records
,
218 NSError
* _Nullable error
))reply
;
220 - (void)invalidateEscrowCache
:(NSString
* _Nullable
)containerName
221 contextID
:(NSString
*)contextID
222 reply
:(nonnull
void (^)(NSError
* _Nullable error
))reply
;
225 - (void)setUserControllableViewsSyncStatus
:(NSString
* _Nullable
)containerName
226 contextID
:(NSString
*)contextID
227 enabled
:(BOOL
)enabled
228 reply
:(void (^)(BOOL nowSyncing
, NSError
* _Nullable error
))reply
;
230 - (void)fetchUserControllableViewsSyncStatus
:(NSString
* _Nullable
)containerName
231 contextID
:(NSString
*)contextID
232 reply
:(void (^)(BOOL nowSyncing
, NSError
* _Nullable error
))reply
;
235 NSXPCInterface
* OTSetupControlProtocol(NSXPCInterface
* interface
);
237 NS_ASSUME_NONNULL_END
239 #endif /* SECURITY_OT_OTCONTROLPROTOCOL_H */