]> git.saurik.com Git - apple/security.git/blob - keychain/ckks/CKKSOperationDependencies.m
Security-59754.41.1.tar.gz
[apple/security.git] / keychain / ckks / CKKSOperationDependencies.m
1
2 #if OCTAGON
3
4 #import "keychain/ckks/CKKS.h"
5 #import "keychain/ckks/CKKSOperationDependencies.h"
6
7 @implementation CKKSOperationDependencies
8
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
20 {
21 if((self = [super init])) {
22 _zoneID = zoneID;
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;
33
34 _keysetProviderOperations = [NSHashTable weakObjectsHashTable];
35 }
36 return self;
37 }
38
39 - (NSArray<CKKSPeerProviderState*>*)currentTrustStates
40 {
41 NSArray<id<CKKSPeerProvider>>* peerProviders = self.peerProviders;
42 NSMutableArray<CKKSPeerProviderState*>* trustStates = [NSMutableArray array];
43
44 #if DEBUG
45 NSAssert(![self.databaseProvider insideSQLTransaction], @"Cannot fetch current trust states from inside a SQL transaction, on pain of deadlocK");
46 #endif
47
48 for(id<CKKSPeerProvider> provider in peerProviders) {
49 ckksnotice("ckks", self.zoneID, "Fetching account keys for provider %@", provider);
50 [trustStates addObject:provider.currentState];
51 }
52
53 return trustStates;
54 }
55
56 - (void)provideKeySet:(CKKSCurrentKeySet*)keyset
57 {
58 if(!keyset || !keyset.currentTLKPointer.currentKeyUUID) {
59 ckksnotice("ckkskey", self.zoneID, "No valid keyset provided: %@", keyset);
60 return;
61 }
62 ckksnotice("ckkskey", self.zoneID, "Providing keyset (%@) to listeners", keyset);
63
64 for(CKKSResultOperation<CKKSKeySetProviderOperationProtocol>* op in self.keysetProviderOperations) {
65 [op provideKeySet:keyset];
66 }
67 }
68
69 @end
70
71 #endif // OCTAGON