]> git.saurik.com Git - apple/security.git/blob - keychain/ckks/CKKSViewManager.h
Security-59306.80.4.tar.gz
[apple/security.git] / keychain / ckks / CKKSViewManager.h
1 /*
2 * Copyright (c) 2016 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24
25 #import <Foundation/Foundation.h>
26
27 #if OCTAGON
28
29 #include "keychain/securityd/SecDbItem.h"
30 #import "keychain/ckks/CKKS.h"
31 #import "keychain/ckks/OctagonAPSReceiver.h"
32 #import "keychain/ckks/CKKSAccountStateTracker.h"
33 #import "keychain/ckks/CKKSCloudKitClassDependencies.h"
34 #import "keychain/ckks/CKKSCondition.h"
35 #import "keychain/ckks/CKKSControlProtocol.h"
36 #import "keychain/ckks/CKKSLockStateTracker.h"
37 #import "keychain/ckks/CKKSReachabilityTracker.h"
38 #import "keychain/ckks/CKKSNotifier.h"
39 #import "keychain/ckks/CKKSPeer.h"
40 #import "keychain/ckks/CKKSRateLimiter.h"
41 #import "keychain/ckks/CloudKitDependencies.h"
42 #import "keychain/ckks/CKKSZoneChangeFetcher.h"
43 #import "keychain/ckks/CKKSZoneModifier.h"
44
45 #import "keychain/ot/OTSOSAdapter.h"
46 #import "keychain/ot/OTDefines.h"
47
48 NS_ASSUME_NONNULL_BEGIN
49
50 @class CKKSKeychainView, CKKSRateLimiter, TPPolicy;
51
52 @interface CKKSViewManager : NSObject <CKKSControlProtocol>
53
54 @property CKContainer* container;
55 @property CKKSAccountStateTracker* accountTracker;
56 @property CKKSLockStateTracker* lockStateTracker;
57 @property CKKSReachabilityTracker *reachabilityTracker;
58 @property CKKSZoneChangeFetcher* zoneChangeFetcher;
59 @property CKKSZoneModifier* zoneModifier;
60
61 // Signaled when SecCKKSInitialize is complete, as it's async and likes to fire after tests are complete
62 @property CKKSCondition* completedSecCKKSInitialize;
63
64 @property CKKSRateLimiter* globalRateLimiter;
65
66 @property id<OTSOSAdapter> sosPeerAdapter;
67
68 @property (nullable) TPPolicy* policy;
69
70 @property NSMutableDictionary<NSString*, CKKSKeychainView*>* views;
71
72 - (instancetype)initWithContainerName:(NSString*)containerName
73 usePCS:(bool)usePCS
74 sosAdapter:(id<OTSOSAdapter> _Nullable)sosAdapter
75 cloudKitClassDependencies:(CKKSCloudKitClassDependencies*)cloudKitClassDependencies;
76
77 - (CKKSKeychainView*)findView:(NSString*)viewName;
78 - (CKKSKeychainView*)findOrCreateView:(NSString*)viewName;
79 - (void)setView:(CKKSKeychainView*)obj;
80 - (void)clearView:(NSString*)viewName;
81
82 - (NSSet<CKKSKeychainView*>*)currentViews;
83
84 - (NSDictionary<NSString*, NSString*>*)activeTLKs;
85
86 - (void)setupAnalytics;
87
88 - (NSString*)viewNameForItem:(SecDbItemRef)item;
89
90 - (void)handleKeychainEventDbConnection:(SecDbConnectionRef)dbconn
91 source:(SecDbTransactionSource)txionSource
92 added:(SecDbItemRef _Nullable)added
93 deleted:(SecDbItemRef _Nullable)deleted;
94
95 - (void)setCurrentItemForAccessGroup:(NSData* _Nonnull)newItemPersistentRef
96 hash:(NSData*)newItemSHA1
97 accessGroup:(NSString*)accessGroup
98 identifier:(NSString*)identifier
99 viewHint:(NSString*)viewHint
100 replacing:(NSData* _Nullable)oldCurrentItemPersistentRef
101 hash:(NSData* _Nullable)oldItemSHA1
102 complete:(void (^)(NSError* operror))complete;
103
104 - (void)getCurrentItemForAccessGroup:(NSString*)accessGroup
105 identifier:(NSString*)identifier
106 viewHint:(NSString*)viewHint
107 fetchCloudValue:(bool)fetchCloudValue
108 complete:(void (^)(NSString* uuid, NSError* operror))complete;
109
110 - (void)registerSyncStatusCallback:(NSString*)uuid callback:(SecBoolNSErrorCallback)callback;
111
112 // Cancels pending operations owned by this view manager
113 - (void)cancelPendingOperations;
114
115 // Use these to acquire (and set) the singleton
116 + (instancetype)manager;
117 + (instancetype _Nullable)resetManager:(bool)reset setTo:(CKKSViewManager* _Nullable)obj;
118
119 // Called by XPC every 24 hours
120 - (void)xpc24HrNotification;
121
122 /* White-box testing only */
123 - (CKKSKeychainView*)restartZone:(NSString*)viewName;
124
125 // Returns the viewList for a CKKSViewManager
126 - (NSSet<NSString*>*)viewList;
127
128 - (NSSet<NSString*>*)defaultViewList;
129
130 - (void)setViewList:(NSSet<NSString*>* _Nullable)newViewList;
131
132 - (void)clearAllViews;
133
134 // Create all views, but don't begin CK/network operations
135 - (void)createViews;
136
137 // Call this to begin CK operation of all views
138 - (void)beginCloudKitOperationOfAllViews;
139
140 // Notify sbd to re-backup.
141 - (void)notifyNewTLKsInKeychain;
142 - (void)syncBackupAndNotifyAboutSync;
143
144 // allow user blocking operation to block on trust status trying to sort it-self out the
145 // first time after launch, only waits the the initial call
146 - (BOOL)waitForTrustReady;
147
148 // For testing
149 - (void)setOverrideCKKSViewsFromPolicy:(BOOL)value;
150 - (BOOL)useCKKSViewsFromPolicy;
151 - (void)haltAll;
152
153 @end
154 NS_ASSUME_NONNULL_END
155
156 #else
157 @interface CKKSViewManager : NSObject
158 @end
159 #endif // OCTAGON