7 #import <KeychainCircle/KCSRPContext.h>
8 #import <KeychainCircle/KCAESGCMDuplexSession.h>
9 #include <Security/SecureObjectSync/SOSPeerInfo.h>
11 NS_ASSUME_NONNULL_BEGIN
13 @protocol KCJoiningRequestCircleDelegate
15 Get this devices peer info (As Application)
18 SOSPeerInfoRef object or NULL if we had an error.
20 - (SOSPeerInfoRef
) copyPeerInfoError
: (NSError
**) error
;
23 Handle recipt of confirmed circleJoinData over the channel
25 @parameter circleJoinData
26 Data the acceptor made to allow us to join the circle.
29 - (bool) processCircleJoinData
: (NSData
*) circleJoinData error
: (NSError
**)error
;
33 @protocol KCJoiningRequestSecretDelegate
35 Get the shared secret for this session.
36 Not called during creation or initialMessage: to allow the initial message to be sent before
38 Called during message processing.
41 String containing shared secret for session
46 Handle verification failure
48 NULL if we should give up. Secret to use on retry, if not.
50 - (NSString
*) verificationFailed
: (bool) codeChanged
;
53 Handle recipt of confirmed accountCode over the channel
55 @parameter accountCode
56 Data the acceptor made to allow us to join the circle.
58 - (bool) processAccountCode
: (NSString
*) accountCode error
: (NSError
**)error
;
62 @interface KCJoiningRequestSecretSession
: NSObject
63 @
property (nullable
, readonly
) KCAESGCMDuplexSession
* session
;
67 - (nullable NSData
*) initialMessage
: (NSError
**) error
;
68 - (nullable NSData
*) processMessage
: (NSData
*) incomingMessage error
: (NSError
**) error
;
70 + (nullable instancetype
)sessionWithSecretDelegate
: (NSObject
<KCJoiningRequestSecretDelegate
>*) secretDelegate
72 error
: (NSError
**) error
;
74 - (nullable instancetype
)initWithSecretDelegate
: (NSObject
<KCJoiningRequestSecretDelegate
>*) secretDelegate
76 error
: (NSError
**)error
;
78 - (nullable instancetype
)initWithSecretDelegate
: (NSObject
<KCJoiningRequestSecretDelegate
>*) secretDelegate
80 rng
: (struct ccrng_state
*)rng
81 error
: (NSError
**)error NS_DESIGNATED_INITIALIZER
;
83 - (instancetype
)init NS_UNAVAILABLE
;
88 @interface KCJoiningRequestCircleSession
: NSObject
92 - (nullable NSData
*) initialMessage
: (NSError
**) error
;
93 - (nullable NSData
*) processMessage
: (NSData
*) incomingMessage error
: (NSError
**) error
;
95 + (instancetype
) sessionWithCircleDelegate
: (NSObject
<KCJoiningRequestCircleDelegate
>*) circleDelegate
96 session
: (KCAESGCMDuplexSession
*) session
97 error
: (NSError
**) error
;
99 - (instancetype
) initWithCircleDelegate
: (NSObject
<KCJoiningRequestCircleDelegate
>*) circleDelegate
100 session
: (KCAESGCMDuplexSession
*) session
101 error
: (NSError
**) error NS_DESIGNATED_INITIALIZER
;
103 - (instancetype
)init NS_UNAVAILABLE
;
107 @protocol KCJoiningAcceptCircleDelegate
109 Handle the request's peer info and get the blob they can use to get in circle
111 SOSPeerInfo sent from requestor to apply to the circle
113 Error resulting in looking at peer and trying to produce circle join data
115 Data containing blob the requestor can use to get in circle
117 - (NSData
*) circleJoinDataFor
: (SOSPeerInfoRef
) peer
118 error
: (NSError
**) error
;
123 kKCRetryWithSameChallenge
,
124 kKCRetryWithNewChallenge
127 @protocol KCJoiningAcceptSecretDelegate
129 Get the shared secret for this session
131 String containing shared secret for session
133 - (NSString
*) secret
;
135 Get the code the other device can use to access the account
137 String containing code to access the account
139 - (NSString
*) accountCode
;
142 Handle verification failure
144 NULL if we should permit retry with the same secret. New secret if we've changed it.
146 - (KCRetryOrNot
) verificationFailed
: (NSError
**) error
;
151 @interface KCJoiningAcceptSession
: NSObject
153 create an appropriate joining session given the initial message.
156 initial message received from the requestor
158 delegate which will provide data and processing (see KCJoiningAcceptSecretDelegate protocol
160 failures to find a session for the initial message
162 KCJoiningAcceptSession that can handle the data from the peer
165 + (nullable instancetype
) sessionWithInitialMessage
: (NSData
*) message
166 secretDelegate
: (NSObject
<KCJoiningAcceptSecretDelegate
>*) delegate
167 circleDelegate
: (NSObject
<KCJoiningAcceptCircleDelegate
>*) delegate
168 dsid
: (uint64_t) dsid
169 error
: (NSError
**) error
;
172 - (nullable instancetype
)initWithSecretDelegate
: (NSObject
<KCJoiningAcceptSecretDelegate
>*) delegate
173 circleDelegate
: (NSObject
<KCJoiningAcceptCircleDelegate
>*) delegate
174 dsid
: (uint64_t) dsid
175 rng
: (struct ccrng_state
*)rng
176 error
: (NSError
**) error NS_DESIGNATED_INITIALIZER
;
179 create an appropriate joining session given the initial message.
181 @parameter incomingMessage
182 message received from the requestor
184 failures parse the message
186 Data to send to the requestor, or NULL if we had an error.
187 Calling this function when we are done results in an error return.
189 - (nullable NSData
*) processMessage
: (NSData
*) incomingMessage error
: (NSError
**) error
;
193 - (id
)init NS_UNAVAILABLE
;
197 NS_ASSUME_NONNULL_END