From ceb210748e68dff5d2d5306b23727e0e98e74c8d Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 6 Jun 2017 14:12:47 -0400 Subject: [PATCH] Sketch out OWSIdentityManager. // FREEBIE --- Podfile | 8 +++---- Podfile.lock | 16 ++++--------- Signal/src/ProfileFetcherJob.swift | 4 ++-- Signal/src/Signal-Bridging-Header.h | 6 ++--- .../FingerprintViewController.m | 2 +- .../OWSLinkDeviceViewController.m | 8 ++++--- .../SafetyNumberConfirmationAlert.swift | 23 +++++++++++-------- Signal/src/call/CallService.swift | 2 +- .../OWS104CreateRecipientIdentities.m | 2 +- 9 files changed, 35 insertions(+), 36 deletions(-) diff --git a/Podfile b/Podfile index 55d7dcd08..4de5fa3a0 100644 --- a/Podfile +++ b/Podfile @@ -3,10 +3,10 @@ source 'https://github.com/CocoaPods/Specs.git' target 'Signal' do pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git' - pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git' - #pod 'AxolotlKit', path: '../SignalProtocolKit' - pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git' - #pod 'SignalServiceKit', path: '../SignalServiceKit' + #pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git' + pod 'AxolotlKit', path: '../SignalProtocolKit' + #pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git' + pod 'SignalServiceKit', path: '../SignalServiceKit' pod 'OpenSSL' pod 'JSQMessagesViewController', git: 'https://github.com/WhisperSystems/JSQMessagesViewController.git', branch: 'mkirk/position-edit-menu' #pod 'JSQMessagesViewController' path: '../JSQMessagesViewController' diff --git a/Podfile.lock b/Podfile.lock index 709615233..e4127585b 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -109,35 +109,29 @@ PODS: - YapDatabase/SQLCipher/Core DEPENDENCIES: - - AxolotlKit (from `https://github.com/WhisperSystems/SignalProtocolKit.git`) + - AxolotlKit (from `../SignalProtocolKit`) - JSQMessagesViewController (from `https://github.com/WhisperSystems/JSQMessagesViewController.git`, branch `mkirk/position-edit-menu`) - OpenSSL - PureLayout - Reachability - - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`) + - SignalServiceKit (from `../SignalServiceKit`) - SocketRocket (from `https://github.com/facebook/SocketRocket.git`) EXTERNAL SOURCES: AxolotlKit: - :git: https://github.com/WhisperSystems/SignalProtocolKit.git + :path: ../SignalProtocolKit JSQMessagesViewController: :branch: mkirk/position-edit-menu :git: https://github.com/WhisperSystems/JSQMessagesViewController.git SignalServiceKit: - :git: https://github.com/WhisperSystems/SignalServiceKit.git + :path: ../SignalServiceKit SocketRocket: :git: https://github.com/facebook/SocketRocket.git CHECKOUT OPTIONS: - AxolotlKit: - :commit: 9179d4e326df58185f35af45831e7a5d7250ab85 - :git: https://github.com/WhisperSystems/SignalProtocolKit.git JSQMessagesViewController: :commit: 7054e4b13ee5bcd6d524adb6dc9a726e8c466308 :git: https://github.com/WhisperSystems/JSQMessagesViewController.git - SignalServiceKit: - :commit: 43d1aa49dc869486cdba8546b56e716beae5c1d0 - :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf :git: https://github.com/facebook/SocketRocket.git @@ -164,6 +158,6 @@ SPEC CHECKSUMS: UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266 -PODFILE CHECKSUM: 48e80d7f1e049bbf544a689fdfdf33e8196c640a +PODFILE CHECKSUM: dc5ed308ade575a81ccadf5c485990530353c4ee COCOAPODS: 1.2.1 diff --git a/Signal/src/ProfileFetcherJob.swift b/Signal/src/ProfileFetcherJob.swift index ad1c1009e..f80ddb517 100644 --- a/Signal/src/ProfileFetcherJob.swift +++ b/Signal/src/ProfileFetcherJob.swift @@ -62,12 +62,12 @@ class ProfileFetcherJob: NSObject { private func verifyIdentityUpToDateAsync(recipientId: String, latestIdentityKey: Data) { OWSDispatch.sessionStoreQueue().async { - if self.storageManager.identityKey(forRecipientId: recipientId) == nil { + if OWSIdentityManager.shared().identityKey(forRecipientId: recipientId) == nil { // first time use, do nothing, since there's no change. return } - if self.storageManager.saveRemoteIdentity(latestIdentityKey, recipientId: recipientId) { + if OWSIdentityManager.shared().saveRemoteIdentity(latestIdentityKey, recipientId: recipientId) { Logger.info("\(self.TAG) updated identity key in fetched profile for recipient: \(recipientId)") self.storageManager.deleteAllSessions(forContact: recipientId) } else { diff --git a/Signal/src/Signal-Bridging-Header.h b/Signal/src/Signal-Bridging-Header.h index 5a2fad749..6aa08aaa7 100644 --- a/Signal/src/Signal-Bridging-Header.h +++ b/Signal/src/Signal-Bridging-Header.h @@ -52,13 +52,14 @@ #import #import #import +#import +#import #import #import +#import #import #import #import -#import -#import #import #import #import @@ -77,7 +78,6 @@ #import #import #import -#import #import #import #import diff --git a/Signal/src/ViewControllers/FingerprintViewController.m b/Signal/src/ViewControllers/FingerprintViewController.m index 913c2406e..372bf25f1 100644 --- a/Signal/src/ViewControllers/FingerprintViewController.m +++ b/Signal/src/ViewControllers/FingerprintViewController.m @@ -11,8 +11,8 @@ #import #import #import +#import #import -#import #import #import diff --git a/Signal/src/ViewControllers/OWSLinkDeviceViewController.m b/Signal/src/ViewControllers/OWSLinkDeviceViewController.m index 1203f9401..73cd9812a 100644 --- a/Signal/src/ViewControllers/OWSLinkDeviceViewController.m +++ b/Signal/src/ViewControllers/OWSLinkDeviceViewController.m @@ -8,7 +8,7 @@ #import "SettingsTableViewController.h" #import #import -#import +#import #import NS_ASSUME_NONNULL_BEGIN @@ -128,8 +128,10 @@ NS_ASSUME_NONNULL_BEGIN - (void)provisionWithParser:(OWSDeviceProvisioningURLParser *)parser { - NSData *myPublicKey = [[TSStorageManager sharedManager] identityKeyPair].publicKey; - NSData *myPrivateKey = [[TSStorageManager sharedManager] identityKeyPair].ows_privateKey; + ECKeyPair *_Nullable identityKeyPair = [[OWSIdentityManager sharedManager] identityKeyPair]; + OWSAssert(identityKeyPair); + NSData *myPublicKey = identityKeyPair.publicKey; + NSData *myPrivateKey = identityKeyPair.ows_privateKey; NSString *accountIdentifier = [TSStorageManager localNumber]; OWSDeviceProvisioner *provisioner = [[OWSDeviceProvisioner alloc] initWithMyPublicKey:myPublicKey diff --git a/Signal/src/ViewControllers/SafetyNumberConfirmationAlert.swift b/Signal/src/ViewControllers/SafetyNumberConfirmationAlert.swift index 6f5515d4f..7c708452c 100644 --- a/Signal/src/ViewControllers/SafetyNumberConfirmationAlert.swift +++ b/Signal/src/ViewControllers/SafetyNumberConfirmationAlert.swift @@ -4,6 +4,7 @@ import Foundation +// TODO: class SafetyNumberConfirmationAlert: NSObject { let TAG = "[SafetyNumberConfirmationAlert]" @@ -69,10 +70,8 @@ class SafetyNumberConfirmationAlert: NSObject { Logger.info("\(self.TAG) Confirmed identity: \(untrustedIdentity)") OWSDispatch.sessionStoreQueue().async { - self.storageManager.saveRemoteIdentity(untrustedIdentity.identityKey, - recipientId: untrustedIdentity.recipientId, - approvedForBlockingUse: true, - approvedForNonBlockingUse: true) + OWSIdentityManager.shared().saveRemoteIdentity(untrustedIdentity.identityKey, + recipientId: untrustedIdentity.recipientId) MarkIdentityAsSeenJob.run(recipientId: untrustedIdentity.recipientId) DispatchQueue.main.async { completion(true) @@ -111,15 +110,19 @@ class SafetyNumberConfirmationAlert: NSObject { } private func unconfirmedIdentities(recipientIds: [String]) -> [OWSRecipientIdentity] { - return recipientIds.flatMap { - self.storageManager.unconfirmedIdentityThatShouldBlockSending(forRecipientId: $0) - } + // TODO: Return the _unverified_ identities. + return [] +// return recipientIds.flatMap { +// OWSIdentityManager.shared().unconfirmedIdentityThatShouldBlockSending(forRecipientId: $0) +// } } private func unseenIdentities(recipientIds: [String]) -> [OWSRecipientIdentity] { - return recipientIds.flatMap { - self.storageManager.unseenIdentityChange(forRecipientId: $0) - } + // TODO: Return the _unverified_ identities. + return [] +// return recipientIds.flatMap { +// OWSIdentityManager.shared().unseenIdentityChange(forRecipientId: $0) +// } } } diff --git a/Signal/src/call/CallService.swift b/Signal/src/call/CallService.swift index 07229e4ad..b5fe03b95 100644 --- a/Signal/src/call/CallService.swift +++ b/Signal/src/call/CallService.swift @@ -470,7 +470,7 @@ protocol CallServiceObserver: class { let newCall = SignalCall.incomingCall(localId: UUID(), remotePhoneNumber: thread.contactIdentifier(), signalingId: callId) - guard self.storageManager.unseenIdentityChange(forRecipientId: thread.contactIdentifier()) == nil else { + guard OWSIdentityManager.shared().isCurrentIdentityTrustedForSending(withRecipientId: thread.contactIdentifier()) else { let callerName = self.contactsManager.displayName(forPhoneIdentifier: thread.contactIdentifier()) self.notificationsAdapter.presentRejectedCallWithUnseenIdentityChange(newCall, callerName: callerName) return diff --git a/Signal/src/environment/Migrations/OWS104CreateRecipientIdentities.m b/Signal/src/environment/Migrations/OWS104CreateRecipientIdentities.m index 7077eaeee..9e51de910 100644 --- a/Signal/src/environment/Migrations/OWS104CreateRecipientIdentities.m +++ b/Signal/src/environment/Migrations/OWS104CreateRecipientIdentities.m @@ -3,8 +3,8 @@ // #import "OWS104CreateRecipientIdentities.h" +#import #import -#import #import #import