mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.0 KiB
Matlab
67 lines
2.0 KiB
Matlab
5 years ago
|
//
|
||
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "OWSFingerprintBuilder.h"
|
||
|
#import "ContactsManagerProtocol.h"
|
||
|
#import "OWSFingerprint.h"
|
||
|
#import "OWSIdentityManager.h"
|
||
|
#import "TSAccountManager.h"
|
||
|
#import <Curve25519Kit/Curve25519.h>
|
||
|
#import <SessionProtocolKit/SessionProtocolKit.h>
|
||
|
|
||
|
NS_ASSUME_NONNULL_BEGIN
|
||
|
|
||
|
@interface OWSFingerprintBuilder ()
|
||
|
|
||
|
@property (nonatomic, readonly) TSAccountManager *accountManager;
|
||
|
@property (nonatomic, readonly) id<ContactsManagerProtocol> contactsManager;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation OWSFingerprintBuilder
|
||
|
|
||
|
- (instancetype)initWithAccountManager:(TSAccountManager *)accountManager
|
||
|
contactsManager:(id<ContactsManagerProtocol>)contactsManager
|
||
|
{
|
||
|
self = [super init];
|
||
|
if (!self) {
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
_accountManager = accountManager;
|
||
|
_contactsManager = contactsManager;
|
||
|
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
- (nullable OWSFingerprint *)fingerprintWithTheirSignalId:(NSString *)theirSignalId
|
||
|
{
|
||
|
NSData *_Nullable theirIdentityKey = [[OWSIdentityManager sharedManager] identityKeyForRecipientId:theirSignalId];
|
||
|
|
||
|
if (theirIdentityKey == nil) {
|
||
|
OWSFailDebug(@"Missing their identity key");
|
||
|
return nil;
|
||
|
}
|
||
|
|
||
|
return [self fingerprintWithTheirSignalId:theirSignalId theirIdentityKey:theirIdentityKey];
|
||
|
}
|
||
|
|
||
|
- (OWSFingerprint *)fingerprintWithTheirSignalId:(NSString *)theirSignalId theirIdentityKey:(NSData *)theirIdentityKey
|
||
|
{
|
||
|
NSString *theirName = [self.contactsManager displayNameForPhoneIdentifier:theirSignalId];
|
||
|
|
||
|
NSString *mySignalId = [self.accountManager localNumber];
|
||
|
NSData *myIdentityKey = [[OWSIdentityManager sharedManager] identityKeyPair].publicKey;
|
||
|
|
||
|
return [OWSFingerprint fingerprintWithMyStableId:mySignalId
|
||
|
myIdentityKey:myIdentityKey
|
||
|
theirStableId:theirSignalId
|
||
|
theirIdentityKey:theirIdentityKey
|
||
|
theirName:theirName];
|
||
|
}
|
||
|
|
||
|
@end
|
||
|
|
||
|
NS_ASSUME_NONNULL_END
|