]> git.saurik.com Git - apple/security.git/blob - keychain/ckks/CKKSPeerProvider.h
Security-59306.41.2.tar.gz
[apple/security.git] / keychain / ckks / CKKSPeerProvider.h
1 #if OCTAGON
2
3 #import <Foundation/Foundation.h>
4 #import "keychain/ckks/CKKSPeer.h"
5
6 NS_ASSUME_NONNULL_BEGIN
7
8 @protocol CKKSPeerUpdateListener;
9 @class CKKSPeerProviderState;
10
11 #pragma mark - CKKSPeerProvider protocol
12 @protocol CKKSPeerProvider <NSObject>
13 @property (readonly) NSString* providerID;
14 @property BOOL essential;
15
16 - (CKKSSelves* _Nullable)fetchSelfPeers:(NSError* _Nullable __autoreleasing* _Nullable)error;
17 - (NSSet<id<CKKSRemotePeerProtocol>>* _Nullable)fetchTrustedPeers:(NSError* _Nullable __autoreleasing* _Nullable)error;
18 // Trusted peers should include self peers
19
20 - (void)registerForPeerChangeUpdates:(id<CKKSPeerUpdateListener>)listener;
21 - (void)sendSelfPeerChangedUpdate;
22 - (void)sendTrustedPeerSetChangedUpdate;
23
24 - (CKKSPeerProviderState*)currentState;
25 @end
26
27 #pragma mark - CKKSPeerUpdateListener protocol
28 // A CKKSPeerUpdateListener wants to be notified when a CKKSPeerProvider has new information
29 @protocol CKKSPeerUpdateListener <NSObject>
30 - (void)selfPeerChanged:(id<CKKSPeerProvider> _Nullable)provider;
31 - (void)trustedPeerSetChanged:(id<CKKSPeerProvider> _Nullable)provider;
32 @end
33
34
35 #pragma mark - CKKSPeerProviderState
36
37 @interface CKKSPeerProviderState : NSObject
38 @property NSString* peerProviderID;
39
40 // The peer provider believes trust in this state is essential. Any subsystem using
41 // a peer provider state should fail and pause if this is YES and there are trust errors.
42 @property BOOL essential;
43
44 @property (nonatomic, readonly, nullable) CKKSSelves* currentSelfPeers;
45 @property (nonatomic, readonly, nullable) NSError* currentSelfPeersError;
46 @property (nonatomic, readonly, nullable) NSSet<id<CKKSRemotePeerProtocol>>* currentTrustedPeers;
47 @property (nonatomic, readonly, nullable) NSSet<NSString*>* currentTrustedPeerIDs;
48 @property (nonatomic, readonly, nullable) NSError* currentTrustedPeersError;
49
50 - (instancetype)initWithPeerProviderID:(NSString*)providerID
51 essential:(BOOL)essential
52 selfPeers:(CKKSSelves* _Nullable)selfPeers
53 selfPeersError:(NSError* _Nullable)selfPeersError
54 trustedPeers:(NSSet<id<CKKSPeer>>* _Nullable)currentTrustedPeers
55 trustedPeersError:(NSError* _Nullable)trustedPeersError;
56
57 + (CKKSPeerProviderState*)noPeersState:(id<CKKSPeerProvider>)provider;
58
59 // Intended for use in PeerProviders. Thread-safety is up to the PeerProvider.
60 + (CKKSPeerProviderState*)createFromProvider:(id<CKKSPeerProvider>)provider;
61 @end
62
63
64
65
66 NS_ASSUME_NONNULL_END
67
68
69 #endif