7 #import <KeychainCircle/KCSRPContext.h>
8 #import <KeychainCircle/KCAESGCMDuplexSession.h>
9 #include <Security/SecureObjectSync/SOSPeerInfo.h>
10 #include <Security/SecureObjectSync/SOSCloudCircle.h>
12 NS_ASSUME_NONNULL_BEGIN
14 @protocol KCJoiningRequestCircleDelegate
<NSObject
>
16 Get this devices peer info (As Application)
19 SOSPeerInfoRef object or NULL if we had an error.
21 - (SOSPeerInfoRef
) copyPeerInfoError
: (NSError
**) error
;
24 Handle recipt of confirmed circleJoinData over the channel
26 @parameter circleJoinData
27 Data the acceptor made to allow us to join the circle.
30 Piggybacking protocol version, let's secd know to expect more data
33 - (bool) processCircleJoinData
: (NSData
*) circleJoinData version
:(PiggyBackProtocolVersion
) version error
: (NSError
**)error
;
37 @protocol KCJoiningRequestSecretDelegate
<NSObject
>
39 Get the shared secret for this session.
40 Not called during creation or initialMessage: to allow the initial message to be sent before
42 Called during message processing.
45 String containing shared secret for session
50 Handle verification failure
52 NULL if we should give up. Secret to use on retry, if not.
54 - (NSString
*) verificationFailed
: (bool) codeChanged
;
57 Handle recipt of confirmed accountCode over the channel
59 @parameter accountCode
60 Data the acceptor made to allow us to join the circle.
62 - (bool) processAccountCode
: (NSString
*) accountCode error
: (NSError
**)error
;
66 @interface KCJoiningRequestSecretSession
: NSObject
67 @
property (nullable
, readonly
) KCAESGCMDuplexSession
* session
;
71 - (nullable NSData
*) initialMessage
: (NSError
**) error
;
72 - (nullable NSData
*) processMessage
: (NSData
*) incomingMessage error
: (NSError
**) error
;
74 + (nullable instancetype
)sessionWithSecretDelegate
: (NSObject
<KCJoiningRequestSecretDelegate
>*) secretDelegate
76 error
: (NSError
**) error
;
78 - (nullable instancetype
)initWithSecretDelegate
: (NSObject
<KCJoiningRequestSecretDelegate
>*) secretDelegate
80 error
: (NSError
**)error
;
82 - (nullable instancetype
)initWithSecretDelegate
: (NSObject
<KCJoiningRequestSecretDelegate
>*) secretDelegate
84 rng
: (struct ccrng_state
*)rng
85 error
: (NSError
**)error NS_DESIGNATED_INITIALIZER
;
87 - (instancetype
)init NS_UNAVAILABLE
;
92 @interface KCJoiningRequestCircleSession
: NSObject
96 - (nullable NSData
*) initialMessage
: (NSError
**) error
;
97 - (nullable NSData
*) processMessage
: (NSData
*) incomingMessage error
: (NSError
**) error
;
99 + (instancetype
) sessionWithCircleDelegate
: (NSObject
<KCJoiningRequestCircleDelegate
>*) circleDelegate
100 session
: (KCAESGCMDuplexSession
*) session
101 error
: (NSError
**) error
;
103 - (instancetype
) initWithCircleDelegate
: (NSObject
<KCJoiningRequestCircleDelegate
>*) circleDelegate
104 session
: (KCAESGCMDuplexSession
*) session
105 error
: (NSError
**) error NS_DESIGNATED_INITIALIZER
;
107 - (instancetype
)init NS_UNAVAILABLE
;
111 @protocol KCJoiningAcceptCircleDelegate
<NSObject
>
113 Handle the request's peer info and get the blob they can use to get in circle
115 SOSPeerInfo sent from requestor to apply to the circle
117 Error resulting in looking at peer and trying to produce circle join data
119 Data containing blob the requestor can use to get in circle
121 - (NSData
*) circleJoinDataFor
: (SOSPeerInfoRef
) peer
122 error
: (NSError
**) error
;
125 Retrieves initial sync data from the following initial sync views: backupV0, iCloud identity, and ckks tlk
127 Error returns an error if encoding the initial sync data was successful or not
129 Data blob contains tlks, icloud identities, and backupv0
131 -(NSData
*) circleGetInitialSyncViews
: (NSError
**) error
;
136 kKCRetryWithSameChallenge
,
137 kKCRetryWithNewChallenge
140 @protocol KCJoiningAcceptSecretDelegate
<NSObject
>
142 Get the shared secret for this session
144 String containing shared secret for session
146 - (NSString
*) secret
;
148 Get the code the other device can use to access the account
150 String containing code to access the account
152 - (NSString
*) accountCode
;
155 Handle verification failure
157 NULL if we should permit retry with the same secret. New secret if we've changed it.
159 - (KCRetryOrNot
) verificationFailed
: (NSError
**) error
;
164 @interface KCJoiningAcceptSession
: NSObject
166 create an appropriate joining session given the initial message.
169 initial message received from the requestor
171 delegate which will provide data and processing (see KCJoiningAcceptSecretDelegate protocol
173 failures to find a session for the initial message
175 KCJoiningAcceptSession that can handle the data from the peer
178 + (nullable instancetype
) sessionWithInitialMessage
: (NSData
*) message
179 secretDelegate
: (NSObject
<KCJoiningAcceptSecretDelegate
>*) delegate
180 circleDelegate
: (NSObject
<KCJoiningAcceptCircleDelegate
>*) delegate
181 dsid
: (uint64_t) dsid
182 error
: (NSError
**) error
;
185 - (nullable instancetype
)initWithSecretDelegate
: (NSObject
<KCJoiningAcceptSecretDelegate
>*) delegate
186 circleDelegate
: (NSObject
<KCJoiningAcceptCircleDelegate
>*) delegate
187 dsid
: (uint64_t) dsid
188 rng
: (struct ccrng_state
*)rng
189 error
: (NSError
**) error NS_DESIGNATED_INITIALIZER
;
192 create an appropriate joining session given the initial message.
194 @parameter incomingMessage
195 message received from the requestor
197 failures parse the message
199 Data to send to the requestor, or NULL if we had an error.
200 Calling this function when we are done results in an error return.
202 - (nullable NSData
*) processMessage
: (NSData
*) incomingMessage error
: (NSError
**) error
;
206 - (id
)init NS_UNAVAILABLE
;
210 NS_ASSUME_NONNULL_END