]> git.saurik.com Git - apple/security.git/blob - keychain/otpaird/OTPairingSession.m
Security-59306.101.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 self = [super init];
26 if (self != nil) {
27 self.identifier = identifier;
28
29 channelContext = [KCPairingChannelContext new];
30 channelContext.uniqueClientID = [NSUUID UUID].UUIDString;
31 channelContext.uniqueDeviceID = [NSUUID UUID].UUIDString;
32 channelContext.intent = KCPairingIntent_Type_SilentRepair;
33 channelContext.model = deviceInfo.modelID;
34 channelContext.osVersion = deviceInfo.osVersion;
35
36 #if TARGET_OS_WATCH
37 self.channel = [KCPairingChannel pairingChannelInitiator:channelContext];
38 #elif TARGET_OS_IOS
39 self.channel = [KCPairingChannel pairingChannelAcceptor:channelContext];
40 #endif
41 }
42 return self;
43 }
44
45 - (void)dealloc
46 {
47 #if !TARGET_OS_SIMULATOR
48 if (self.lockAssertion) {
49 CFRelease(self.lockAssertion);
50 self.lockAssertion = NULL;
51 }
52 #endif /* !TARGET_OS_SIMULATOR */
53 }
54
55 @end