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 preapprovedKeys
:(NSArray
<NSData
*>* _Nullable
)preapprovedKeys
90 reply
:(void (^)(NSError
* _Nullable error
))reply
;
92 - (void)preflightBottledPeer
:(NSString
*)contextID
94 reply
:(void (^)(NSData
* _Nullable entropy
,
95 NSString
* _Nullable bottleID
,
96 NSData
* _Nullable signingPublicKey
,
97 NSError
* _Nullable error
))reply
;
98 - (void)launchBottledPeer
:(NSString
*)contextID
99 bottleID
:(NSString
*)bottleID
100 reply
:(void (^ _Nullable
)(NSError
* _Nullable error
))reply
;
101 - (void)scrubBottledPeer
:(NSString
*)contextID
102 bottleID
:(NSString
*)bottleID
103 reply
:(void (^ _Nullable
)(NSError
* _Nullable error
))reply
;
105 - (void)status
:(NSString
* _Nullable
)container
106 context
:(NSString
*)context
107 reply
:(void (^)(NSDictionary
* _Nullable result
, NSError
* _Nullable error
))reply
;
109 - (void)fetchEgoPeerID
:(NSString
* _Nullable
)container
110 context
:(NSString
*)context
111 reply
:(void (^)(NSString
* _Nullable peerID
, NSError
* _Nullable error
))reply
;
113 - (void)fetchCliqueStatus
:(NSString
* _Nullable
)container
114 context
:(NSString
*)context
115 configuration
:(OTOperationConfiguration
*)configuration
116 reply
:(void (^)(CliqueStatus cliqueStatus
, NSError
* _Nullable error
))reply
;
118 - (void)fetchTrustStatus
:(NSString
* _Nullable
)container
119 context
:(NSString
*)context
120 configuration
:(OTOperationConfiguration
*)configuration
121 reply
:(void (^)(CliqueStatus status
,
122 NSString
* _Nullable peerID
,
123 NSNumber
* _Nullable numberOfPeersInOctagon
,
125 NSError
* _Nullable error
))reply
;
127 // Likely won't be used once Octagon is turned on for good
128 - (void)startOctagonStateMachine
:(NSString
* _Nullable
)container
129 context
:(NSString
*)context
130 reply
:(void (^)(NSError
* _Nullable error
))reply
;
132 - (void)resetAndEstablish
:(NSString
* _Nullable
)container
133 context
:(NSString
*)context
134 altDSID
:(NSString
*)altDSID
135 resetReason
:(CuttlefishResetReason
)resetReason
136 reply
:(void (^)(NSError
* _Nullable error
))reply
;
138 - (void)establish
:(NSString
* _Nullable
)container
139 context
:(NSString
*)context
140 altDSID
:(NSString
*)altDSID
141 reply
:(void (^)(NSError
* _Nullable
))reply
;
143 - (void)leaveClique
:(NSString
* _Nullable
)container
144 context
:(NSString
*)context
145 reply
:(void (^)(NSError
* _Nullable error
))reply
;
147 - (void)removeFriendsInClique
:(NSString
* _Nullable
)container
148 context
:(NSString
*)context
149 peerIDs
:(NSArray
<NSString
*>*)peerIDs
150 reply
:(void (^)(NSError
* _Nullable error
))reply
;
152 - (void)peerDeviceNamesByPeerID
:(NSString
* _Nullable
)container
153 context
:(NSString
*)context
154 reply
:(void (^)(NSDictionary
<NSString
*, NSString
*>* _Nullable peers
, NSError
* _Nullable error
))reply
;
156 - (void)fetchAllViableBottles
:(NSString
* _Nullable
)container
157 context
:(NSString
*)context
158 reply
:(void (^)(NSArray
<NSString
*>* _Nullable sortedBottleIDs
, NSArray
<NSString
*> * _Nullable sortedPartialBottleIDs
, NSError
* _Nullable error
))reply
;
160 -(void)restore
:(NSString
* _Nullable
)containerName
161 contextID
:(NSString
*)contextID
162 bottleSalt
:(NSString
*)bottleSalt
163 entropy
:(NSData
*)entropy
164 bottleID
:(NSString
*)bottleID
165 reply
:(void (^)(NSError
* _Nullable
))reply
;
167 - (void)fetchEscrowContents
:(NSString
* _Nullable
)containerName
168 contextID
:(NSString
*)contextID
169 reply
:(void (^)(NSData
* _Nullable entropy
,
170 NSString
* _Nullable bottleID
,
171 NSData
* _Nullable signingPublicKey
,
172 NSError
* _Nullable error
))reply
;
174 - (void) createRecoveryKey
:(NSString
* _Nullable
)containerName
175 contextID
:(NSString
*)contextID
176 recoveryKey
:(NSString
*)recoveryKey
177 reply
:(void (^)( NSError
* _Nullable
))reply
;
179 - (void) joinWithRecoveryKey
:(NSString
* _Nullable
)containerName
180 contextID
:(NSString
*)contextID
181 recoveryKey
:(NSString
*)recoveryKey
182 reply
:(void (^)(NSError
* _Nullable
))reply
;
184 - (void)healthCheck
:(NSString
* _Nullable
)container
185 context
:(NSString
*)context
186 skipRateLimitingCheck
:(BOOL
)skipRateLimitingCheck
187 reply
:(void (^)(NSError
*_Nullable error
))reply
;
189 - (void)attemptSosUpgrade
:(NSString
* _Nullable
)container
190 context
:(NSString
*)context
191 reply
:(void (^)(NSError
* _Nullable error
))reply
;
193 - (void)waitForOctagonUpgrade
:(NSString
* _Nullable
)container
194 context
:(NSString
*)context
195 reply
:(void (^)(NSError
* _Nullable error
))reply
;
197 - (void)postCDPFollowupResult
:(BOOL
)success
198 type
:(OTCliqueCDPContextType
)type
199 error
:(NSError
* _Nullable
)error
200 containerName
:(NSString
* _Nullable
)containerName
201 contextName
:(NSString
*)contextName
202 reply
:(void (^)(NSError
* _Nullable error
))reply
;
204 - (void)tapToRadar
:(NSString
*)action
205 description
:(NSString
*)description
206 radar
:(NSString
*)radar
207 reply
:(void (^)(NSError
* _Nullable error
))reply
;
211 NSXPCInterface
* OTSetupControlProtocol(NSXPCInterface
* interface
);
213 NS_ASSUME_NONNULL_END
215 #endif /* SECURITY_OT_OTCONTROLPROTOCOL_H */