4 #import "keychain/ckks/CKKS.h"
5 #import "keychain/ckks/CKKSOperationDependencies.h"
7 @implementation CKKSOperationDependencies
9 - (instancetype)initWithZoneID:(CKRecordZoneID*)zoneID
10 zoneModifier:(CKKSZoneModifier*)zoneModifier
11 ckoperationGroup:(CKOperationGroup* _Nullable)operationGroup
12 flagHandler:(id<OctagonStateFlagHandler>)flagHandler
13 launchSequence:(CKKSLaunchSequence*)launchSequence
14 lockStateTracker:(CKKSLockStateTracker*)lockStateTracker
15 reachabilityTracker:(CKKSReachabilityTracker*)reachabilityTracker
16 peerProviders:(NSArray<id<CKKSPeerProvider>>*)peerProviders
17 databaseProvider:(id<CKKSDatabaseProviderProtocol>)databaseProvider
18 notifyViewChangedScheduler:(CKKSNearFutureScheduler*)notifyViewChangedScheduler
19 savedTLKNotifier:(CKKSNearFutureScheduler*)savedTLKNotifier
21 if((self = [super init])) {
23 _zoneModifier = zoneModifier;
24 _ckoperationGroup = operationGroup;
25 _flagHandler = flagHandler;
26 _launch = launchSequence;
27 _lockStateTracker = lockStateTracker;
28 _reachabilityTracker = reachabilityTracker;
29 _peerProviders = peerProviders;
30 _databaseProvider = databaseProvider;
31 _notifyViewChangedScheduler = notifyViewChangedScheduler;
32 _savedTLKNotifier = savedTLKNotifier;
34 _keysetProviderOperations = [NSHashTable weakObjectsHashTable];
39 - (NSArray<CKKSPeerProviderState*>*)currentTrustStates
41 NSArray<id<CKKSPeerProvider>>* peerProviders = self.peerProviders;
42 NSMutableArray<CKKSPeerProviderState*>* trustStates = [NSMutableArray array];
45 NSAssert(![self.databaseProvider insideSQLTransaction], @"Cannot fetch current trust states from inside a SQL transaction, on pain of deadlocK");
48 for(id<CKKSPeerProvider> provider in peerProviders) {
49 ckksnotice("ckks", self.zoneID, "Fetching account keys for provider %@", provider);
50 [trustStates addObject:provider.currentState];
56 - (void)provideKeySet:(CKKSCurrentKeySet*)keyset
58 if(!keyset || !keyset.currentTLKPointer.currentKeyUUID) {
59 ckksnotice("ckkskey", self.zoneID, "No valid keyset provided: %@", keyset);
62 ckksnotice("ckkskey", self.zoneID, "Providing keyset (%@) to listeners", keyset);
64 for(CKKSResultOperation<CKKSKeySetProviderOperationProtocol>* op in self.keysetProviderOperations) {
65 [op provideKeySet:keyset];