7 #import <KeychainCircle/KCSRPContext.h>
8 #import <KeychainCircle/KCAESGCMDuplexSession.h>
9 #include <Security/SecureObjectSync/SOSPeerInfo.h>
10 #include <Security/SecureObjectSync/SOSCloudCircle.h>
13 bool KCJoiningOctagonPiggybackingEnabled(void);
14 bool KCSetJoiningOctagonPiggybackingEnabled(bool value
);
16 NS_ASSUME_NONNULL_BEGIN
18 @protocol KCJoiningRequestCircleDelegate
<NSObject
>
20 Get this devices peer info (As Application)
23 SOSPeerInfoRef object or NULL if we had an error.
25 - (SOSPeerInfoRef
) copyPeerInfoError
: (NSError
**) error
;
28 Handle recipt of confirmed circleJoinData over the channel
30 @parameter circleJoinData
31 Data the acceptor made to allow us to join the circle.
34 Piggybacking protocol version, let's secd know to expect more data
37 - (bool) processCircleJoinData
: (NSData
*) circleJoinData version
:(PiggyBackProtocolVersion
) version error
: (NSError
**)error
;
41 @protocol KCJoiningRequestSecretDelegate
<NSObject
>
43 Get the shared secret for this session.
44 Not called during creation or initialMessage: to allow the initial message to be sent before
46 Called during message processing.
49 String containing shared secret for session
54 Handle verification failure
56 NULL if we should give up. Secret to use on retry, if not.
58 - (NSString
*) verificationFailed
: (bool) codeChanged
;
61 Handle recipt of confirmed accountCode over the channel
63 @parameter accountCode
64 Data the acceptor made to allow us to join the circle.
66 - (bool) processAccountCode
: (NSString
*) accountCode error
: (NSError
**)error
;
70 @interface KCJoiningRequestSecretSession
: NSObject
71 @
property (nullable
, readonly
) KCAESGCMDuplexSession
* session
;
75 - (nullable NSData
*) initialMessage
: (NSError
**) error
;
76 - (nullable NSData
*) processMessage
: (NSData
*) incomingMessage error
: (NSError
**) error
;
78 + (nullable instancetype
)sessionWithSecretDelegate
: (NSObject
<KCJoiningRequestSecretDelegate
>*) secretDelegate
80 error
: (NSError
**) error
;
82 - (nullable instancetype
)initWithSecretDelegate
: (NSObject
<KCJoiningRequestSecretDelegate
>*) secretDelegate
84 error
: (NSError
**)error
;
86 - (nullable instancetype
)initWithSecretDelegate
: (NSObject
<KCJoiningRequestSecretDelegate
>*) secretDelegate
88 rng
: (struct ccrng_state
*)rng
89 error
: (NSError
**)error NS_DESIGNATED_INITIALIZER
;
91 - (instancetype
)init NS_UNAVAILABLE
;
96 @interface KCJoiningRequestCircleSession
: NSObject
100 - (nullable NSData
*) initialMessage
: (NSError
**) error
;
101 - (nullable NSData
*) processMessage
: (NSData
*) incomingMessage error
: (NSError
**) error
;
103 + (instancetype
) sessionWithCircleDelegate
: (NSObject
<KCJoiningRequestCircleDelegate
>*) circleDelegate
104 session
: (KCAESGCMDuplexSession
*) session
105 error
: (NSError
**) error
;
107 - (instancetype
) initWithCircleDelegate
: (NSObject
<KCJoiningRequestCircleDelegate
>*) circleDelegate
108 session
: (KCAESGCMDuplexSession
*) session
109 error
: (NSError
**) error
;
112 - (instancetype
)initWithCircleDelegate
:(NSObject
<KCJoiningRequestCircleDelegate
>*) circleDelegate
113 session
:(KCAESGCMDuplexSession
*) session
114 otcontrol
:(OTControl
*)otcontrol
115 error
:(NSError
**) error NS_DESIGNATED_INITIALIZER
;
117 - (instancetype
)init NS_UNAVAILABLE
;
121 @protocol KCJoiningAcceptCircleDelegate
<NSObject
>
123 Handle the request's peer info and get the blob they can use to get in circle
125 SOSPeerInfo sent from requestor to apply to the circle
127 Error resulting in looking at peer and trying to produce circle join data
129 Data containing blob the requestor can use to get in circle
131 - (NSData
*) circleJoinDataFor
: (SOSPeerInfoRef
) peer
132 error
: (NSError
**) error
;
135 Retrieves initial sync data from the following initial sync views: backupV0, iCloud identity, and ckks tlk
137 Error returns an error if encoding the initial sync data was successful or not
139 Data blob contains tlks, icloud identities, and backupv0
141 -(NSData
*) circleGetInitialSyncViews
:(SOSInitialSyncFlags
)flags error
:(NSError
**) error
;
146 kKCRetryWithSameChallenge
,
147 kKCRetryWithNewChallenge
150 @protocol KCJoiningAcceptSecretDelegate
<NSObject
>
152 Get the shared secret for this session
154 String containing shared secret for session
156 - (NSString
*) secret
;
158 Get the code the other device can use to access the account
160 String containing code to access the account
162 - (NSString
*) accountCode
;
165 Handle verification failure
167 NULL if we should permit retry with the same secret. New secret if we've changed it.
169 - (KCRetryOrNot
) verificationFailed
: (NSError
**) error
;
174 @interface KCJoiningAcceptSession
: NSObject
176 create an appropriate joining session given the initial message.
179 initial message received from the requestor
181 delegate which will provide data and processing (see KCJoiningAcceptSecretDelegate protocol
183 failures to find a session for the initial message
185 KCJoiningAcceptSession that can handle the data from the peer
188 + (nullable instancetype
) sessionWithInitialMessage
: (NSData
*) message
189 secretDelegate
: (NSObject
<KCJoiningAcceptSecretDelegate
>*) delegate
190 circleDelegate
: (NSObject
<KCJoiningAcceptCircleDelegate
>*) delegate
191 dsid
: (uint64_t) dsid
192 error
: (NSError
**) error
;
195 - (nullable instancetype
)initWithSecretDelegate
: (NSObject
<KCJoiningAcceptSecretDelegate
>*) delegate
196 circleDelegate
: (NSObject
<KCJoiningAcceptCircleDelegate
>*) delegate
197 dsid
: (uint64_t) dsid
198 rng
: (struct ccrng_state
*)rng
199 error
: (NSError
**) error NS_DESIGNATED_INITIALIZER
;
202 create an appropriate joining session given the initial message.
204 @parameter incomingMessage
205 message received from the requestor
207 failures parse the message
209 Data to send to the requestor, or NULL if we had an error.
210 Calling this function when we are done results in an error return.
212 - (nullable NSData
*) processMessage
: (NSData
*) incomingMessage error
: (NSError
**) error
;
216 - (id
)init NS_UNAVAILABLE
;
220 NS_ASSUME_NONNULL_END