]>
Commit | Line | Data |
---|---|---|
866f8763 A |
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 | |
b54c578e A |
14 | #define KCPairingErrorOctagonMessageMissing 4 |
15 | #define KCPairingErrorTypeConfusion 5 | |
16 | #define KCPairingErrorNoTrustAvailable 6 | |
17 | #define KCPairingErrorNoStashedCredential 7 | |
866f8763 A |
18 | |
19 | typedef void(^KCPairingChannelCompletion)(BOOL complete, NSData *packet, NSError *error); | |
20 | ||
b54c578e A |
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> | |
866f8763 A |
27 | @property (strong) NSString *model; |
28 | @property (strong) NSString *modelVersion; | |
29 | @property (strong) NSString *modelClass; | |
30 | @property (strong) NSString *osVersion; | |
b54c578e A |
31 | @property (strong) NSString *uniqueDeviceID; |
32 | @property (strong) NSString *uniqueClientID; | |
33 | @property (strong) KCPairingIntent_Type intent; | |
866f8763 A |
34 | @end |
35 | ||
b54c578e A |
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 | ||
866f8763 A |
43 | @interface KCPairingChannel : NSObject |
44 | ||
45 | @property (assign,readonly) BOOL needInitialSync; | |
46 | ||
47 | + (instancetype)pairingChannelInitiator:(KCPairingChannelContext *)peerVersionContext; | |
48 | + (instancetype)pairingChannelAcceptor:(KCPairingChannelContext *)peerVersionContext; | |
49 | ||
b54c578e | 50 | - (instancetype)initAsInitiator:(bool)initiator version:(KCPairingChannelContext *)peerVersionContext; |
866f8763 A |
51 | - (void)validateStart:(void(^)(bool result, NSError *error))complete; |
52 | ||
53 | - (NSData *)exchangePacket:(NSData *)data complete:(bool *)complete error:(NSError **)error; | |
b54c578e | 54 | - (void)exchangePacket:(NSData *)inputCompressedData complete:(KCPairingChannelCompletion)complete; /* async version of above */ |
866f8763 A |
55 | |
56 | /* for tests cases only */ | |
57 | - (void)setXPCConnectionObject:(NSXPCConnection *)connection; | |
b54c578e A |
58 | - (void)setControlObject:(id)control; |
59 | - (void)setConfiguration:(id)config; | |
60 | - (void)setSOSMessageFailForTesting:(BOOL)value; | |
61 | - (void)setOctagonMessageFailForTesting:(BOOL)value; | |
79b9da22 | 62 | + (bool)isSupportedPlatform; |
b54c578e | 63 | - (void)setSessionSupportsOctagonForTesting:(bool)value; |
b3971512 A |
64 | |
65 | + (NSData *)pairingChannelCompressData:(NSData *)data; | |
66 | + (NSData *)pairingChannelDecompressData:(NSData *)data; | |
67 | ||
866f8763 A |
68 | @end |
69 |