]> git.saurik.com Git - apple/security.git/blob - KeychainCircle/PairingChannel.h
Security-59306.101.1.tar.gz
[apple/security.git] / KeychainCircle / PairingChannel.h
1 //
2 // SecurityPairing.h
3 // Security
4 //
5
6 #import <Foundation/Foundation.h>
7 #import <Security/SecureObjectSync/SOSTypes.h>
8
9 extern NSString *kKCPairingChannelErrorDomain;
10
11 #define KCPairingErrorNoControlChannel 1
12 #define KCPairingErrorTooManySteps 2
13 #define KCPairingErrorAccountCredentialMissing 3
14 #define KCPairingErrorOctagonMessageMissing 4
15 #define KCPairingErrorTypeConfusion 5
16 #define KCPairingErrorNoTrustAvailable 6
17 #define KCPairingErrorNoStashedCredential 7
18
19 typedef void(^KCPairingChannelCompletion)(BOOL complete, NSData *packet, NSError *error);
20
21 typedef NSString* KCPairingIntent_Type NS_STRING_ENUM;
22 extern KCPairingIntent_Type KCPairingIntent_Type_None;
23 extern KCPairingIntent_Type KCPairingIntent_Type_SilentRepair;
24 extern KCPairingIntent_Type KCPairingIntent_Type_UserDriven;
25
26 @interface KCPairingChannelContext : NSObject <NSSecureCoding>
27 @property (strong) NSString *model;
28 @property (strong) NSString *modelVersion;
29 @property (strong) NSString *modelClass;
30 @property (strong) NSString *osVersion;
31 @property (strong) NSString *uniqueDeviceID;
32 @property (strong) NSString *uniqueClientID;
33 @property (strong) KCPairingIntent_Type intent;
34 @end
35
36 /**
37 * Pairing channel provides the channel used in OOBE / D2D and HomePod/AppleTV (TapToFix) setup.
38 *
39 * The initiator is the device that wants to get into the circle, the acceptor is the device that is already in.
40 * The interface require the caller to hold a lock assertion over the whole transaction, both on the initiator and acceptor.
41 */
42
43 @interface KCPairingChannel : NSObject
44
45 @property (assign,readonly) BOOL needInitialSync;
46
47 + (instancetype)pairingChannelInitiator:(KCPairingChannelContext *)peerVersionContext;
48 + (instancetype)pairingChannelAcceptor:(KCPairingChannelContext *)peerVersionContext;
49
50 - (instancetype)initAsInitiator:(bool)initiator version:(KCPairingChannelContext *)peerVersionContext;
51 - (void)validateStart:(void(^)(bool result, NSError *error))complete;
52
53 - (NSData *)exchangePacket:(NSData *)data complete:(bool *)complete error:(NSError **)error;
54 - (void)exchangePacket:(NSData *)inputCompressedData complete:(KCPairingChannelCompletion)complete; /* async version of above */
55
56 /* for tests cases only */
57 - (void)setXPCConnectionObject:(NSXPCConnection *)connection;
58 - (void)setControlObject:(id)control;
59 - (void)setConfiguration:(id)config;
60 - (void)setSOSMessageFailForTesting:(BOOL)value;
61 - (void)setOctagonMessageFailForTesting:(BOOL)value;
62 + (bool)isSupportedPlatform;
63 - (void)setSessionSupportsOctagonForTesting:(bool)value;
64
65 + (NSData *)pairingChannelCompressData:(NSData *)data;
66 + (NSData *)pairingChannelDecompressData:(NSData *)data;
67
68 @end
69