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 typedef void (^OTNextJoinCompleteBlock
)(BOOL finished
, NSData
* _Nullable message
, NSError
* _Nullable error
);
39 @protocol OTControlProtocol
40 - (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
;
41 - (void)octagonEncryptionPublicKey
:(void (^)(NSData
* _Nullable encryptionKey
, NSError
* _Nullable
))reply
;
42 - (void)octagonSigningPublicKey
:(void (^)(NSData
* _Nullable signingKey
, NSError
* _Nullable
))reply
;
43 - (void)listOfEligibleBottledPeerRecords
:(void (^)(NSArray
* _Nullable listOfRecords
, NSError
* _Nullable
))reply
;
45 // If you're not sure about container, pass nil. If you're not sure about context, pass OTDefaultContext.
46 - (void)signIn
:(NSString
*)altDSID
47 container
:(NSString
* _Nullable
)container
48 context
:(NSString
*)contextID
49 reply
:(void (^)(NSError
* _Nullable error
))reply
;
51 - (void)signOut
:(NSString
* _Nullable
)container
52 context
:(NSString
*)contextID
53 reply
:(void (^)(NSError
* _Nullable error
))reply
;
55 - (void)notifyIDMSTrustLevelChangeForContainer
:(NSString
* _Nullable
)container
56 context
:(NSString
*)contextID
57 reply
:(void (^)(NSError
* _Nullable error
))reply
;
59 - (void)reset
:(void (^)(BOOL result
, NSError
* _Nullable error
))reply
;
61 - (void)handleIdentityChangeForSigningKey
:(SFECKeyPair
*)peerSigningKey
62 ForEncryptionKey
:(SFECKeyPair
*)encryptionKey
63 ForPeerID
:(NSString
*)peerID
64 reply
:(void (^)(BOOL result
,
65 NSError
* _Nullable error
))reply
;
67 - (void)rpcEpochWithConfiguration
:(OTJoiningConfiguration
*)config
68 reply
:(void (^)(uint64_t epoch
,
69 NSError
* _Nullable error
))reply
;
71 - (void)rpcPrepareIdentityAsApplicantWithConfiguration
:(OTJoiningConfiguration
*)config
72 reply
:(void (^)(NSString
* _Nullable peerID
,
73 NSData
* _Nullable permanentInfo
,
74 NSData
* _Nullable permanentInfoSig
,
75 NSData
* _Nullable stableInfo
,
76 NSData
* _Nullable stableInfoSig
,
77 NSError
* _Nullable error
))reply
;
78 - (void)rpcVoucherWithConfiguration
:(OTJoiningConfiguration
*)config
79 peerID
:(NSString
*)peerID
80 permanentInfo
:(NSData
*)permanentInfo
81 permanentInfoSig
:(NSData
*)permanentInfoSig
82 stableInfo
:(NSData
*)stableInfo
83 stableInfoSig
:(NSData
*)stableInfoSig
84 reply
:(void (^)(NSData
* voucher
, NSData
* voucherSig
, NSError
* _Nullable error
))reply
;
86 - (void)rpcJoinWithConfiguration
:(OTJoiningConfiguration
*)config
87 vouchData
:(NSData
*)vouchData
88 vouchSig
:(NSData
*)vouchSig
89 reply
:(void (^)(NSError
* _Nullable error
))reply
;
91 - (void)preflightBottledPeer
:(NSString
*)contextID
93 reply
:(void (^)(NSData
* _Nullable entropy
,
94 NSString
* _Nullable bottleID
,
95 NSData
* _Nullable signingPublicKey
,
96 NSError
* _Nullable error
))reply
;
97 - (void)launchBottledPeer
:(NSString
*)contextID
98 bottleID
:(NSString
*)bottleID
99 reply
:(void (^ _Nullable
)(NSError
* _Nullable error
))reply
;
100 - (void)scrubBottledPeer
:(NSString
*)contextID
101 bottleID
:(NSString
*)bottleID
102 reply
:(void (^ _Nullable
)(NSError
* _Nullable error
))reply
;
104 - (void)status
:(NSString
* _Nullable
)container
105 context
:(NSString
*)context
106 reply
:(void (^)(NSDictionary
* _Nullable result
, NSError
* _Nullable error
))reply
;
108 - (void)fetchEgoPeerID
:(NSString
* _Nullable
)container
109 context
:(NSString
*)context
110 reply
:(void (^)(NSString
* _Nullable peerID
, NSError
* _Nullable error
))reply
;
112 - (void)fetchCliqueStatus
:(NSString
* _Nullable
)container
113 context
:(NSString
*)context
114 configuration
:(OTOperationConfiguration
*)configuration
115 reply
:(void (^)(CliqueStatus cliqueStatus
, NSError
* _Nullable error
))reply
;
117 - (void)fetchTrustStatus
:(NSString
* _Nullable
)container
118 context
:(NSString
*)context
119 configuration
:(OTOperationConfiguration
*)configuration
120 reply
:(void (^)(CliqueStatus status
,
121 NSString
* _Nullable peerID
,
122 NSNumber
* _Nullable numberOfPeersInOctagon
,
124 NSError
* _Nullable error
))reply
;
126 // Likely won't be used once Octagon is turned on for good
127 - (void)startOctagonStateMachine
:(NSString
* _Nullable
)container
128 context
:(NSString
*)context
129 reply
:(void (^)(NSError
* _Nullable error
))reply
;
131 - (void)resetAndEstablish
:(NSString
* _Nullable
)container
132 context
:(NSString
*)context
133 altDSID
:(NSString
*)altDSID
134 resetReason
:(CuttlefishResetReason
)resetReason
135 reply
:(void (^)(NSError
* _Nullable error
))reply
;
137 - (void)establish
:(NSString
* _Nullable
)container
138 context
:(NSString
*)context
139 altDSID
:(NSString
*)altDSID
140 reply
:(void (^)(NSError
* _Nullable
))reply
;
142 - (void)leaveClique
:(NSString
* _Nullable
)container
143 context
:(NSString
*)context
144 reply
:(void (^)(NSError
* _Nullable error
))reply
;
146 - (void)removeFriendsInClique
:(NSString
* _Nullable
)container
147 context
:(NSString
*)context
148 peerIDs
:(NSArray
<NSString
*>*)peerIDs
149 reply
:(void (^)(NSError
* _Nullable error
))reply
;
151 - (void)peerDeviceNamesByPeerID
:(NSString
* _Nullable
)container
152 context
:(NSString
*)context
153 reply
:(void (^)(NSDictionary
<NSString
*, NSString
*>* _Nullable peers
, NSError
* _Nullable error
))reply
;
155 - (void)fetchAllViableBottles
:(NSString
* _Nullable
)container
156 context
:(NSString
*)context
157 reply
:(void (^)(NSArray
<NSString
*>* _Nullable sortedBottleIDs
, NSArray
<NSString
*> * _Nullable sortedPartialBottleIDs
, NSError
* _Nullable error
))reply
;
159 -(void)restore
:(NSString
* _Nullable
)containerName
160 contextID
:(NSString
*)contextID
161 bottleSalt
:(NSString
*)bottleSalt
162 entropy
:(NSData
*)entropy
163 bottleID
:(NSString
*)bottleID
164 reply
:(void (^)(NSError
* _Nullable
))reply
;
166 - (void)fetchEscrowContents
:(NSString
* _Nullable
)containerName
167 contextID
:(NSString
*)contextID
168 reply
:(void (^)(NSData
* _Nullable entropy
,
169 NSString
* _Nullable bottleID
,
170 NSData
* _Nullable signingPublicKey
,
171 NSError
* _Nullable error
))reply
;
173 - (void) createRecoveryKey
:(NSString
* _Nullable
)containerName
174 contextID
:(NSString
*)contextID
175 recoveryKey
:(NSString
*)recoveryKey
176 reply
:(void (^)( NSError
* _Nullable
))reply
;
178 - (void) joinWithRecoveryKey
:(NSString
* _Nullable
)containerName
179 contextID
:(NSString
*)contextID
180 recoveryKey
:(NSString
*)recoveryKey
181 reply
:(void (^)(NSError
* _Nullable
))reply
;
183 - (void)healthCheck
:(NSString
* _Nullable
)container
184 context
:(NSString
*)context
185 skipRateLimitingCheck
:(BOOL
)skipRateLimitingCheck
186 reply
:(void (^)(NSError
*_Nullable error
))reply
;
188 - (void)attemptSosUpgrade
:(NSString
* _Nullable
)container
189 context
:(NSString
*)context
190 reply
:(void (^)(NSError
* _Nullable error
))reply
;
192 - (void)waitForOctagonUpgrade
:(NSString
* _Nullable
)container
193 context
:(NSString
*)context
194 reply
:(void (^)(NSError
* _Nullable error
))reply
;
196 - (void)postCDPFollowupResult
:(BOOL
)success
197 type
:(OTCliqueCDPContextType
)type
198 error
:(NSError
* _Nullable
)error
199 containerName
:(NSString
* _Nullable
)containerName
200 contextName
:(NSString
*)contextName
201 reply
:(void (^)(NSError
* _Nullable error
))reply
;
203 - (void)tapToRadar
:(NSString
*)action
204 description
:(NSString
*)description
205 radar
:(NSString
*)radar
206 reply
:(void (^)(NSError
* _Nullable error
))reply
;
208 - (void)refetchCKKSPolicy
:(NSString
* _Nullable
)container
209 contextID
:(NSString
*)contextID
210 reply
:(void (^)(NSError
* _Nullable error
))reply
;
212 - (void)setCDPEnabled
:(NSString
* _Nullable
)containerName
213 contextID
:(NSString
*)contextID
214 reply
:(void (^)(NSError
* _Nullable error
))reply
;
216 - (void)getCDPStatus
:(NSString
* _Nullable
)containerName
217 contextID
:(NSString
*)contextID
218 reply
:(void (^)(OTCDPStatus status
, NSError
* _Nullable error
))reply
;
222 NSXPCInterface
* OTSetupControlProtocol(NSXPCInterface
* interface
);
224 NS_ASSUME_NONNULL_END
226 #endif /* SECURITY_OT_OTCONTROLPROTOCOL_H */