]> git.saurik.com Git - apple/security.git/blob - keychain/ot/OTManager.h
Security-59306.101.1.tar.gz
[apple/security.git] / keychain / ot / OTManager.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 #import "Analytics/SFAnalytics.h"
29 #import "keychain/ot/OTManager.h"
30 #import "keychain/ot/OTRamping.h"
31 #import "keychain/ot/OTFollowup.h"
32 #import "keychain/ot/OTControlProtocol.h"
33 #import "keychain/ot/OTSOSAdapter.h"
34 #import "keychain/ot/OTAuthKitAdapter.h"
35 #import "keychain/ot/OTDeviceInformationAdapter.h"
36 #import "keychain/ot/OTCuttlefishAccountStateHolder.h"
37 #import "keychain/escrowrequest/Framework/SecEscrowRequest.h"
38 #import "keychain/ckks/CKKSAccountStateTracker.h"
39 #import "keychain/ckks/CKKSViewManager.h"
40 #include "keychain/securityd/SecDbItem.h"
41 #import <CoreCDP/CDPAccount.h>
42 NS_ASSUME_NONNULL_BEGIN
43
44 @class OTContext;
45 @class OTCuttlefishContext;
46 @class OTClientStateMachine;
47 @class CKKSLockStateTracker;
48 @class CKKSAccountStateTracker;
49 @class CloudKitClassDependencies;
50
51 @interface OTManager : NSObject <OTControlProtocol>
52
53 @property (nonatomic, readonly) CKKSLockStateTracker* lockStateTracker;
54 @property CKKSAccountStateTracker* accountStateTracker;
55
56 @property (readonly) CKContainer* cloudKitContainer;
57 @property (nullable) CKKSViewManager* viewManager;
58
59 // Creates an OTManager ready for use with live external systems.
60 - (instancetype)init;
61
62 - (instancetype)initWithSOSAdapter:(id<OTSOSAdapter>)sosAdapter
63 authKitAdapter:(id<OTAuthKitAdapter>)authKitAdapter
64 deviceInformationAdapter:(id<OTDeviceInformationAdapter>)deviceInformationAdapter
65 apsConnectionClass:(Class<OctagonAPSConnection>)apsConnectionClass
66 escrowRequestClass:(Class<SecEscrowRequestable>)escrowRequestClass
67 loggerClass:(Class<SFAnalyticsProtocol>)loggerClass
68 lockStateTracker:(CKKSLockStateTracker*)lockStateTracker
69 cloudKitClassDependencies:(CKKSCloudKitClassDependencies*)cloudKitClassDependencies
70 cuttlefishXPCConnection:(id<NSXPCProxyCreating> _Nullable)cuttlefishXPCConnection
71 cdpd:(id<OctagonFollowUpControllerProtocol>)cdpd;
72
73 // Call this to start up the state machinery
74 - (void)initializeOctagon;
75 - (BOOL)waitForReady:(NSString* _Nullable)containerName context:(NSString*)context wait:(int64_t)wait;
76 - (void)moveToCheckTrustedStateForContainer:(NSString* _Nullable)containerName context:(NSString*)context;
77
78 // Call this to ensure SFA is ready
79 - (void)setupAnalytics;
80
81 + (instancetype _Nullable)manager;
82 + (instancetype _Nullable)resetManager:(bool)reset to:(OTManager* _Nullable)obj;
83 - (void)xpc24HrNotification;
84
85 - (OTCuttlefishContext*)contextForContainerName:(NSString* _Nullable)containerName
86 contextID:(NSString*)contextID
87 sosAdapter:(id<OTSOSAdapter>)sosAdapter
88 authKitAdapter:(id<OTAuthKitAdapter>)authKitAdapter
89 lockStateTracker:(CKKSLockStateTracker*)lockStateTracker
90 accountStateTracker:(id<CKKSCloudKitAccountStateTrackingProvider>)accountStateTracker
91 deviceInformationAdapter:(id<OTDeviceInformationAdapter>)deviceInformationAdapter;
92
93 - (OTCuttlefishContext*)contextForContainerName:(NSString* _Nullable)containerName
94 contextID:(NSString*)contextID;
95
96 - (void)removeContextForContainerName:(NSString*)containerName
97 contextID:(NSString*)contextID;
98
99 - (OTClientStateMachine*)clientStateMachineForContainerName:(NSString* _Nullable)containerName
100 contextID:(NSString*)contextID
101 clientName:(NSString*)clientName;
102
103 -(BOOL)ghostbustByMidEnabled;
104 -(BOOL)ghostbustBySerialEnabled;
105 -(BOOL)ghostbustByAgeEnabled;
106
107 -(void)restore:(NSString* _Nullable)containerName
108 contextID:(NSString *)contextID
109 bottleSalt:(NSString *)bottleSalt
110 entropy:(NSData *)entropy
111 bottleID:(NSString *)bottleID
112 reply:(void (^)(NSError * _Nullable))reply;
113
114 - (void)createRecoveryKey:(NSString* _Nullable)containerName
115 contextID:(NSString *)contextID
116 recoveryKey:(NSString *)recoveryKey
117 reply:(void (^)( NSError * _Nullable))reply;
118
119 - (void)joinWithRecoveryKey:(NSString* _Nullable)containerName
120 contextID:(NSString *)contextID
121 recoveryKey:(NSString*)recoveryKey
122 reply:(void (^)(NSError * _Nullable))reply;
123
124 - (void)allContextsHalt;
125 - (void)allContextsDisablePendingFlags;
126 - (bool)allContextsPause:(uint64_t)within;
127
128 - (void)waitForOctagonUpgrade:(NSString* _Nullable)container
129 context:(NSString*)context
130 reply:(void (^)(NSError* _Nullable error))reply;
131
132 // Metrics and analytics
133 - (void)postCDPFollowupResult:(BOOL)success
134 type:(OTCliqueCDPContextType)type
135 error:(NSError * _Nullable)error
136 containerName:(NSString* _Nullable)containerName
137 contextName:(NSString *)contextName
138 reply:(void (^)(NSError *error))reply;
139 @end
140
141 @interface OTManager (Testing)
142 - (void)setSOSEnabledForPlatformFlag:(bool) value;
143
144 - (void)clearAllContexts;
145
146 // Note that the OTManager returned by this will not work particularly well, if you want to do Octagon things
147 // This should only be used for the CKKS tests
148 - (instancetype)initWithSOSAdapter:(id<OTSOSAdapter>)sosAdapter
149 lockStateTracker:(CKKSLockStateTracker*)lockStateTracker
150 cloudKitClassDependencies:(CKKSCloudKitClassDependencies*)cloudKitClassDependencies;
151 @end
152
153 NS_ASSUME_NONNULL_END
154
155 #endif // OCTAGON
156