]> git.saurik.com Git - apple/security.git/blob - keychain/ot/OTManager.h
Security-59306.11.20.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/OTContext.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 #include <securityd/SecDbItem.h>
40 #import <CoreCDP/CDPAccount.h>
41 NS_ASSUME_NONNULL_BEGIN
42
43 @class OTContext;
44 @class OTCuttlefishContext;
45 @class OTClientStateMachine;
46 @class CKKSLockStateTracker;
47 @class CKKSAccountStateTracker;
48
49 @interface OTManager : NSObject <OTControlProtocol>
50
51 @property (nonatomic, readonly) NSDate *lastPostedCoreFollowUp;
52 @property (nonatomic, readonly) CKKSLockStateTracker* lockStateTracker;
53 @property id<CKKSCloudKitAccountStateTrackingProvider> accountStateTracker;
54
55 -(instancetype)init;
56
57 -(instancetype) initWithContext:(OTContext* _Nullable)context
58 localStore:(OTLocalStore* _Nullable)localStore
59 enroll:(OTRamp* _Nullable)enroll
60 restore:(OTRamp* _Nullable)restore
61 cfu:(OTRamp* _Nullable)cfu
62 cfuScheduler:(CKKSNearFutureScheduler* _Nullable)cfuScheduler
63 sosAdapter:(id<OTSOSAdapter>)sosAdapter
64 authKitAdapter:(id<OTAuthKitAdapter>)authKitAdapter
65 deviceInformationAdapter:(id<OTDeviceInformationAdapter>)deviceInformationAdapter
66 apsConnectionClass:(Class<OctagonAPSConnection>)apsConnectionClass
67 escrowRequestClass:(Class<SecEscrowRequestable>)escrowRequestClass
68 loggerClass:(Class<SFAnalyticsProtocol> _Nullable)loggerClass
69 lockStateTracker:(CKKSLockStateTracker* _Nullable)lockStateTracker
70 accountStateTracker:(id<CKKSCloudKitAccountStateTrackingProvider>)accountStateTracker
71 cuttlefishXPCConnection:(id<NSXPCProxyCreating> _Nullable)cuttlefishXPCConnection
72 cdpd:(id<OctagonFollowUpControllerProtocol>)cdpd;
73
74 // Call this to start up the state machinery
75 - (void)initializeOctagon;
76 - (void) moveToCheckTrustedStateForContainer:(NSString* _Nullable)containerName context:(NSString*)context;
77
78 + (instancetype _Nullable)manager;
79 + (instancetype _Nullable)resetManager:(bool)reset to:(OTManager* _Nullable)obj;
80 - (void)xpc24HrNotification:(NSString* _Nullable)containerName context:(NSString*)context skipRateLimitingCheck:(BOOL)skipRateLimitingCheck reply:(void (^)(NSError *error))reply;
81
82 -(BOOL)scheduledCloudKitRampCheck:(NSError**)error;
83
84 - (OTCuttlefishContext*)contextForContainerName:(NSString* _Nullable)containerName
85 contextID:(NSString*)contextID
86 sosAdapter:(id<OTSOSAdapter>)sosAdapter
87 authKitAdapter:(id<OTAuthKitAdapter>)authKitAdapter
88 lockStateTracker:(CKKSLockStateTracker*)lockStateTracker
89 accountStateTracker:(id<CKKSCloudKitAccountStateTrackingProvider>)accountStateTracker
90 deviceInformationAdapter:(id<OTDeviceInformationAdapter>)deviceInformationAdapter;
91
92 - (OTCuttlefishContext*)contextForContainerName:(NSString* _Nullable)containerName
93 contextID:(NSString*)contextID;
94
95 - (void)removeContextForContainerName:(NSString*)containerName
96 contextID:(NSString*)contextID;
97
98 - (OTClientStateMachine*)clientStateMachineForContainerName:(NSString* _Nullable)containerName
99 contextID:(NSString*)contextID
100 clientName:(NSString*)clientName;
101
102 -(BOOL)ghostbustByMidEnabled;
103 -(BOOL)ghostbustBySerialEnabled;
104 -(BOOL)ghostbustByAgeEnabled;
105
106 -(void)restore:(NSString* _Nullable)containerName
107 contextID:(NSString *)contextID
108 bottleSalt:(NSString *)bottleSalt
109 entropy:(NSData *)entropy
110 bottleID:(NSString *)bottleID
111 reply:(void (^)(NSError * _Nullable))reply;
112
113 - (void)createRecoveryKey:(NSString* _Nullable)containerName
114 contextID:(NSString *)contextID
115 recoveryKey:(NSString *)recoveryKey
116 reply:(void (^)( NSError * _Nullable))reply;
117
118 - (void)joinWithRecoveryKey:(NSString* _Nullable)containerName
119 contextID:(NSString *)contextID
120 recoveryKey:(NSString*)recoveryKey
121 reply:(void (^)(NSError * _Nullable))reply;
122
123 - (void)allContextsHalt;
124 - (void)allContextsDisablePendingFlags;
125 - (bool)allContextsPause:(uint64_t)within;
126
127 - (void)waitForOctagonUpgrade:(NSString* _Nullable)container
128 context:(NSString*)context
129 reply:(void (^)(NSError* _Nullable error))reply;
130
131 // Metrics and analytics
132 - (void)postCDPFollowupResult:(BOOL)success
133 type:(OTCliqueCDPContextType)type
134 error:(NSError * _Nullable)error
135 containerName:(NSString* _Nullable)containerName
136 contextName:(NSString *)contextName
137 reply:(void (^)(NSError *error))reply;
138
139 //test only
140 - (void)setSOSEnabledForPlatformFlag:(bool) value;
141 @end
142 NS_ASSUME_NONNULL_END
143
144 #endif // OCTAGON
145