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