]> git.saurik.com Git - apple/security.git/blob - keychain/otpaird/OTPairingSession.m
Security-59754.41.1.tar.gz
[apple/security.git] / keychain / otpaird / OTPairingSession.m
1 #import <KeychainCircle/KeychainCircle.h>
2
3 #if !TARGET_OS_SIMULATOR
4 #import <MobileKeyBag/MobileKeyBag.h>
5 #endif /* !TARGET_OS_SIMULATOR */
6
7 #import "OTPairingSession.h"
8
9 @interface OTPairingSession ()
10 @property (readwrite) NSString *identifier;
11 @property (readwrite) KCPairingChannel *channel;
12 @end
13
14 @implementation OTPairingSession
15
16 - (instancetype)initWithDeviceInfo:(OTDeviceInformationActualAdapter *)deviceInfo
17 {
18 return [self initWithDeviceInfo:deviceInfo identifier:[[NSUUID UUID] UUIDString]];
19 }
20
21 - (instancetype)initWithDeviceInfo:(OTDeviceInformationActualAdapter *)deviceInfo identifier:(NSString *)identifier
22 {
23 KCPairingChannelContext *channelContext = nil;
24
25 if ((self = [super init])) {
26 self.identifier = identifier;
27
28 channelContext = [KCPairingChannelContext new];
29 channelContext.uniqueClientID = [NSUUID UUID].UUIDString;
30 channelContext.uniqueDeviceID = [NSUUID UUID].UUIDString;
31 channelContext.intent = KCPairingIntent_Type_SilentRepair;
32 channelContext.model = deviceInfo.modelID;
33 channelContext.osVersion = deviceInfo.osVersion;
34
35 #if TARGET_OS_WATCH
36 self.channel = [KCPairingChannel pairingChannelInitiator:channelContext];
37 #elif TARGET_OS_IOS
38 self.channel = [KCPairingChannel pairingChannelAcceptor:channelContext];
39 #endif
40 }
41 return self;
42 }
43
44 - (void)dealloc
45 {
46 #if !TARGET_OS_SIMULATOR
47 if (self.lockAssertion) {
48 CFRelease(self.lockAssertion);
49 self.lockAssertion = NULL;
50 }
51 #endif /* !TARGET_OS_SIMULATOR */
52 }
53
54 @end