CKKSKeychainView.h [plain text]
#ifndef CKKSKeychainView_h
#define CKKSKeychainView_h
#import <Foundation/Foundation.h>
#include <dispatch/dispatch.h>
#if OCTAGON
#import "keychain/ckks/CloudKitDependencies.h"
#import "keychain/ckks/CKKSAPSReceiver.h"
#import "keychain/ckks/CKKSLockStateTracker.h"
#endif
#include <utilities/SecDb.h>
#include <securityd/SecDbItem.h>
#import "keychain/ckks/CKKS.h"
#import "keychain/ckks/CKKSIncomingQueueOperation.h"
#import "keychain/ckks/CKKSOutgoingQueueOperation.h"
#import "keychain/ckks/CKKSNearFutureScheduler.h"
#import "keychain/ckks/CKKSNewTLKOperation.h"
#import "keychain/ckks/CKKSProcessReceivedKeysOperation.h"
#import "keychain/ckks/CKKSReencryptOutgoingItemsOperation.h"
#import "keychain/ckks/CKKSFetchAllRecordZoneChangesOperation.h"
#import "keychain/ckks/CKKSScanLocalItemsOperation.h"
#import "keychain/ckks/CKKSUpdateDeviceStateOperation.h"
#import "keychain/ckks/CKKSGroupOperation.h"
#import "keychain/ckks/CKKSZone.h"
#import "keychain/ckks/CKKSZoneChangeFetcher.h"
#import "keychain/ckks/CKKSNotifier.h"
#import "keychain/ckks/CKKSPeer.h"
#import "keychain/ckks/CKKSTLKShare.h"
#include "CKKS.h"
# if !OCTAGON
@interface CKKSKeychainView : NSObject {
NSString* _containerName;
}
@end
#else // OCTAGON
@class CKKSKey;
@class CKKSAESSIVKey;
@class CKKSSynchronizeOperation;
@class CKKSRateLimiter;
@class CKKSManifest;
@class CKKSEgoManifest;
@class CKKSOutgoingQueueEntry;
@class CKKSZoneChangeFetcher;
@interface CKKSKeychainView : CKKSZone <CKKSZoneUpdateReceiver,
CKKSChangeFetcherErrorOracle,
CKKSPeerUpdateListener> {
CKKSZoneKeyState* _keyHierarchyState;
}
@property CKKSLockStateTracker* lockStateTracker;
@property CKKSZoneKeyState* keyHierarchyState;
@property NSError* keyHierarchyError;
@property CKOperationGroup* keyHierarchyOperationGroup;
@property NSOperation* keyStateMachineOperation;
@property bool keyStateMachineRefetched;
@property CKKSEgoManifest* egoManifest;
@property CKKSManifest* latestManifest;
@property CKKSResultOperation* keyStateReadyDependency;
@property (readonly) NSString *lastActiveTLKUUID;
@property NSMutableDictionary<CKKSZoneKeyState*, CKKSCondition*>* keyHierarchyConditions;
@property CKKSZoneChangeFetcher* zoneChangeFetcher;
@property (weak) CKKSNearFutureScheduler* savedTLKNotifier;
@property CKKSGroupOperation* viewSetupOperation;
@property CKKSIncomingQueueOperation* lastIncomingQueueOperation;
@property CKKSNewTLKOperation* lastNewTLKOperation;
@property CKKSOutgoingQueueOperation* lastOutgoingQueueOperation;
@property CKKSProcessReceivedKeysOperation* lastProcessReceivedKeysOperation;
@property CKKSFetchAllRecordZoneChangesOperation* lastRecordZoneChangesOperation;
@property CKKSReencryptOutgoingItemsOperation* lastReencryptOutgoingItemsOperation;
@property CKKSScanLocalItemsOperation* lastScanLocalItemsOperation;
@property CKKSSynchronizeOperation* lastSynchronizeOperation;
@property CKKSResultOperation* lastFixupOperation;
@property NSOperation* holdReencryptOutgoingItemsOperation;
@property NSOperation* holdOutgoingQueueOperation;
@property CKKSNearFutureScheduler* notifyViewChangedScheduler;
@property (nonatomic, readonly) CKKSSelves* currentSelfPeers;
@property (nonatomic, readonly) NSError* currentSelfPeersError;
@property (nonatomic, readonly) NSSet<id<CKKSPeer>>* currentTrustedPeers;
@property (nonatomic, readonly) NSError* currentTrustedPeersError;
- (instancetype)initWithContainer: (CKContainer*) container
zoneName: (NSString*) zoneName
accountTracker:(CKKSCKAccountStateTracker*) accountTracker
lockStateTracker:(CKKSLockStateTracker*) lockStateTracker
savedTLKNotifier:(CKKSNearFutureScheduler*) savedTLKNotifier
peerProvider:(id<CKKSPeerProvider>)peerProvider
fetchRecordZoneChangesOperationClass: (Class<CKKSFetchRecordZoneChangesOperation>) fetchRecordZoneChangesOperationClass
fetchRecordsOperationClass: (Class<CKKSFetchRecordsOperation>)fetchRecordsOperationClass
queryOperationClass:(Class<CKKSQueryOperation>)queryOperationClass
modifySubscriptionsOperationClass: (Class<CKKSModifySubscriptionsOperation>) modifySubscriptionsOperationClass
modifyRecordZonesOperationClass: (Class<CKKSModifyRecordZonesOperation>) modifyRecordZonesOperationClass
apsConnectionClass: (Class<CKKSAPSConnection>) apsConnectionClass
notifierClass: (Class<CKKSNotifier>) notifierClass;
- (void) handleKeychainEventDbConnection:(SecDbConnectionRef) dbconn
added:(SecDbItemRef) added
deleted:(SecDbItemRef) deleted
rateLimiter:(CKKSRateLimiter*) rateLimiter
syncCallback:(SecBoolNSErrorCallback) syncCallback;
-(void)setCurrentItemForAccessGroup:(SecDbItemRef)newItem
hash:(NSData*)newItemSHA1
accessGroup:(NSString*)accessGroup
identifier:(NSString*)identifier
replacing:(SecDbItemRef)oldItem
hash:(NSData*)oldItemSHA1
complete:(void (^) (NSError* operror)) complete;
-(void)getCurrentItemForAccessGroup:(NSString*)accessGroup
identifier:(NSString*)identifier
fetchCloudValue:(bool)fetchCloudValue
complete:(void (^) (NSString* uuid, NSError* operror)) complete;
- (bool) outgoingQueueEmpty: (NSError * __autoreleasing *) error;
- (CKKSResultOperation*)waitForFetchAndIncomingQueueProcessing;
- (void) waitForKeyHierarchyReadiness;
- (void) cancelAllOperations;
- (CKKSKey*) keyForItem: (SecDbItemRef) item error: (NSError * __autoreleasing *) error;
- (bool)_onqueueWithAccountKeysCheckTLK: (CKKSKey*) proposedTLK error: (NSError * __autoreleasing *) error;
- (void) initializeZone;
- (CKKSOutgoingQueueOperation*)processOutgoingQueue:(CKOperationGroup*)ckoperationGroup;
- (CKKSOutgoingQueueOperation*)processOutgoingQueueAfter:(CKKSResultOperation*)after ckoperationGroup:(CKOperationGroup*)ckoperationGroup;
- (CKKSIncomingQueueOperation*) processIncomingQueue:(bool)failOnClassA;
- (CKKSIncomingQueueOperation*) processIncomingQueue:(bool)failOnClassA after: (CKKSResultOperation*) after;
- (void)processIncomingQueueAfterNextUnlock;
- (CKKSUpdateDeviceStateOperation*)updateDeviceState:(bool)rateLimit
waitForKeyHierarchyInitialization:(uint64_t)timeout
ckoperationGroup:(CKOperationGroup*)ckoperationGroup;
- (CKKSSynchronizeOperation*) resyncWithCloud;
- (CKKSResultOperation*)fetchAndProcessCKChanges:(CKKSFetchBecause*)because;
- (CKKSResultOperation*)resetLocalData;
- (CKKSResultOperation*)resetCloudKitZone;
- (void)advanceKeyStateMachine;
- (void)keyStateMachineRequestProcess;
- (void) dispatchAsync: (bool (^)(void)) block;
- (void) dispatchSync: (bool (^)(void)) block;
- (void)dispatchSyncWithAccountKeys:(bool (^)(void))block;
- (void)_onqueueKeyStateMachineRequestFetch;
- (void)_onqueueKeyStateMachineRequestFullRefetch;
- (void)_onqueueKeyStateMachineRequestProcess;
- (void)_onqueueAdvanceKeyStateMachineToState: (CKKSZoneKeyState*) state withError: (NSError*) error;
- (bool)_onqueueChangeOutgoingQueueEntry: (CKKSOutgoingQueueEntry*) oqe toState: (NSString*) state error: (NSError* __autoreleasing*) error;
- (bool)_onqueueErrorOutgoingQueueEntry: (CKKSOutgoingQueueEntry*) oqe itemError: (NSError*) itemError error: (NSError* __autoreleasing*) error;
- (bool)_onqueueCKWriteFailed:(NSError*)ckerror attemptedRecordsChanged:(NSDictionary<CKRecordID*,CKRecord*>*)savedRecords;
- (bool) _onqueueCKRecordChanged:(CKRecord*)record resync:(bool)resync;
- (bool) _onqueueCKRecordDeleted:(CKRecordID*)recordID recordType:(NSString*)recordType resync:(bool)resync;
- (NSSet<id<CKKSPeer>>*)_onqueueFindPeersMissingShare:(CKKSKey*)key error:(NSError* __autoreleasing*)error;
- (NSSet<CKKSTLKShare*>*)_onqueueCreateMissingKeyShares:(CKKSKey*)key error:(NSError* __autoreleasing*)error;
- (bool)_onQueueUpdateLatestManifestWithError:(NSError**)error;
- (CKKSDeviceStateEntry*)_onqueueCurrentDeviceStateEntry: (NSError* __autoreleasing*)error;
- (bool) isFatalCKFetchError: (NSError*) error;
@property NSHashTable<CKKSIncomingQueueOperation*>* incomingQueueOperations;
@property NSHashTable<CKKSOutgoingQueueOperation*>* outgoingQueueOperations;
@property CKKSScanLocalItemsOperation* initialScanOperation;
-(NSDictionary<NSString*, NSString*>*)status;
@end
#endif // OCTAGON
#define SecTranslateError(nserrorptr, cferror) \
if(nserrorptr) { \
*nserrorptr = (__bridge_transfer NSError*) cferror; \
} else { \
CFReleaseNull(cferror); \
}
#endif