From a951d11d97ddd2a9de51d8848a0ab9c44f422401 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 6 Apr 2017 19:49:59 -0400 Subject: [PATCH 1/4] [SSK] move iOSVersion to SSK // FREEBIE --- Podfile | 2 +- Podfile.lock | 7 ++++--- Signal/Signal-Prefix.pch | 2 +- Signal/src/environment/iOSVersions.h | 14 -------------- Signal/src/util/UIFont+OWS.m | 1 - 5 files changed, 6 insertions(+), 20 deletions(-) delete mode 100644 Signal/src/environment/iOSVersions.h diff --git a/Podfile b/Podfile index 52b196b6c6..9a76318238 100644 --- a/Podfile +++ b/Podfile @@ -5,7 +5,7 @@ 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', git: 'https://github.com/WhisperSystems/SignalServiceKit.git', commit: '60dcadb0d704458728d2b96f24eefc803bd80c92' #pod 'SignalServiceKit', path: '../SignalServiceKit' pod 'OpenSSL' pod 'SCWaveformView', '~> 1.0' diff --git a/Podfile.lock b/Podfile.lock index d9a1338fb4..3cd1711222 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -116,13 +116,14 @@ DEPENDENCIES: - OpenSSL - PureLayout - SCWaveformView (~> 1.0) - - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`) + - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`, commit `60dcadb0d704458728d2b96f24eefc803bd80c92`) - SocketRocket (from `https://github.com/facebook/SocketRocket.git`) EXTERNAL SOURCES: AxolotlKit: :git: https://github.com/WhisperSystems/SignalProtocolKit.git SignalServiceKit: + :commit: 60dcadb0d704458728d2b96f24eefc803bd80c92 :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :git: https://github.com/facebook/SocketRocket.git @@ -132,7 +133,7 @@ CHECKOUT OPTIONS: :commit: cbf2f47d59dd54d6d720fe787f835bd767443bb6 :git: https://github.com/WhisperSystems/SignalProtocolKit.git SignalServiceKit: - :commit: 4f9e053248dd87f59e198be5d00be5b9bd48bfa9 + :commit: 60dcadb0d704458728d2b96f24eefc803bd80c92 :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf @@ -161,6 +162,6 @@ SPEC CHECKSUMS: UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d YapDatabase: b1e43555a34a5298e23a045be96817a5ef0da58f -PODFILE CHECKSUM: a060377074cb361576f346a58d1503b3bd708440 +PODFILE CHECKSUM: 9666e5c942b3ab24f46ad5b00cf1397beef6276d COCOAPODS: 1.2.0 diff --git a/Signal/Signal-Prefix.pch b/Signal/Signal-Prefix.pch index f5ce9f9e98..fb20452f68 100644 --- a/Signal/Signal-Prefix.pch +++ b/Signal/Signal-Prefix.pch @@ -19,7 +19,7 @@ #import #import #import - #import "iOSVersions.h" + #import #define SignalAlertView(title,msg) [[[UIAlertView alloc] initWithTitle:title message:msg delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil, nil] show] #endif diff --git a/Signal/src/environment/iOSVersions.h b/Signal/src/environment/iOSVersions.h deleted file mode 100644 index d1f60d207d..0000000000 --- a/Signal/src/environment/iOSVersions.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// iOSVersions.h -// Signal -// -// Created by Frederic Jacobs on 03/08/14. -// Copyright (c) 2014 Open Whisper Systems. All rights reserved. -// - -#import -#include - -#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(major, minor) \ - ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){.majorVersion = major, .minorVersion = minor, .patchVersion = 0}]) - diff --git a/Signal/src/util/UIFont+OWS.m b/Signal/src/util/UIFont+OWS.m index 8f5aa895e4..7757294aee 100644 --- a/Signal/src/util/UIFont+OWS.m +++ b/Signal/src/util/UIFont+OWS.m @@ -3,7 +3,6 @@ // #import "UIFont+OWS.h" -#import "iOSVersions.h" @implementation UIFont (OWS) From 398ee22f50615b81b4859b59fb16121779e3d942 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 6 Apr 2017 19:51:06 -0400 Subject: [PATCH 2/4] [SSK] rename cipher queue to sessionStoreQueue // FREEBIE --- Podfile | 2 +- Podfile.lock | 8 ++++---- Signal/src/AppDelegate.m | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Podfile b/Podfile index 9a76318238..3d7be3b777 100644 --- a/Podfile +++ b/Podfile @@ -5,7 +5,7 @@ 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', commit: '60dcadb0d704458728d2b96f24eefc803bd80c92' + pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git', commit: '7578176e378c4602b5295f97c3329d254498523b' #pod 'SignalServiceKit', path: '../SignalServiceKit' pod 'OpenSSL' pod 'SCWaveformView', '~> 1.0' diff --git a/Podfile.lock b/Podfile.lock index 3cd1711222..d0d2a9f525 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -116,14 +116,14 @@ DEPENDENCIES: - OpenSSL - PureLayout - SCWaveformView (~> 1.0) - - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`, commit `60dcadb0d704458728d2b96f24eefc803bd80c92`) + - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`, commit `7578176e378c4602b5295f97c3329d254498523b`) - SocketRocket (from `https://github.com/facebook/SocketRocket.git`) EXTERNAL SOURCES: AxolotlKit: :git: https://github.com/WhisperSystems/SignalProtocolKit.git SignalServiceKit: - :commit: 60dcadb0d704458728d2b96f24eefc803bd80c92 + :commit: 7578176e378c4602b5295f97c3329d254498523b :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :git: https://github.com/facebook/SocketRocket.git @@ -133,7 +133,7 @@ CHECKOUT OPTIONS: :commit: cbf2f47d59dd54d6d720fe787f835bd767443bb6 :git: https://github.com/WhisperSystems/SignalProtocolKit.git SignalServiceKit: - :commit: 60dcadb0d704458728d2b96f24eefc803bd80c92 + :commit: 7578176e378c4602b5295f97c3329d254498523b :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf @@ -162,6 +162,6 @@ SPEC CHECKSUMS: UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d YapDatabase: b1e43555a34a5298e23a045be96817a5ef0da58f -PODFILE CHECKSUM: 9666e5c942b3ab24f46ad5b00cf1397beef6276d +PODFILE CHECKSUM: 29bf376adcb82f35d46545ccdb7c77522af4f155 COCOAPODS: 1.2.0 diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index a991ef06dd..88d303f19a 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -191,7 +191,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify"; [Environment setCurrent:[Release releaseEnvironment]]; // Encryption/Descryption mutates session state and must be synchronized on a serial queue. - [SessionCipher setSessionCipherDispatchQueue:[OWSDispatch sessionCipher]]; + [SessionCipher setSessionCipherDispatchQueue:[OWSDispatch sessionStoreQueue]]; TextSecureKitEnv *sharedEnv = [[TextSecureKitEnv alloc] initWithCallMessageHandler:[Environment getCurrent].callMessageHandler From caabae0024f28fe8e4532db260d542e7c71bafd5 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 6 Apr 2017 19:51:40 -0400 Subject: [PATCH 3/4] Add new debug method to delete session // FREEBIE --- .../DebugUITableViewController.m | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/Signal/src/ViewControllers/DebugUITableViewController.m b/Signal/src/ViewControllers/DebugUITableViewController.m index 2af90b643f..300080ed3b 100644 --- a/Signal/src/ViewControllers/DebugUITableViewController.m +++ b/Signal/src/ViewControllers/DebugUITableViewController.m @@ -67,12 +67,29 @@ NS_ASSUME_NONNULL_BEGIN }], ]]]; - [contents addSection:[OWSTableSection sectionWithTitle:@"Print to Debug Log" - items:@[ [OWSTableItem itemWithTitle:@"Print all sessions" - actionBlock:^{ - [[TSStorageManager sharedManager] - printAllSessions]; - }] ]]]; + [contents + addSection:[OWSTableSection + sectionWithTitle:@"Session State" + items:@[ + [OWSTableItem itemWithTitle:@"Print all sessions" + actionBlock:^{ + dispatch_async([OWSDispatch sessionStoreQueue], ^{ + [[TSStorageManager sharedManager] printAllSessions]; + }); + }], + [OWSTableItem itemWithTitle:@"Delete session (Contact Thread Only)" + actionBlock:^{ + if (![thread isKindOfClass:[TSContactThread class]]) { + DDLogError(@"Trying to delete session for group thread."); + OWSAssert(NO); + } + dispatch_async([OWSDispatch sessionStoreQueue], ^{ + [[TSStorageManager sharedManager] + deleteAllSessionsForContact:thread.contactIdentifier]; + }); + }], + + ]]]; DebugUITableViewController *viewController = [DebugUITableViewController new]; viewController.contents = contents; From 87845525b6bf4b7b231c29c4992a29e242658219 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 6 Apr 2017 20:10:36 -0400 Subject: [PATCH 4/4] [SSK] serialize all read/write to sessionStore Attempt to avoid session corruption happening due to an inconsistent view of the session store by ensuring all access to the session store happens on a serialized queue // FREEBIE --- Podfile | 2 +- Podfile.lock | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Podfile b/Podfile index 3d7be3b777..52b196b6c6 100644 --- a/Podfile +++ b/Podfile @@ -5,7 +5,7 @@ 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', commit: '7578176e378c4602b5295f97c3329d254498523b' + pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git' #pod 'SignalServiceKit', path: '../SignalServiceKit' pod 'OpenSSL' pod 'SCWaveformView', '~> 1.0' diff --git a/Podfile.lock b/Podfile.lock index d0d2a9f525..04daa08c19 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -116,14 +116,13 @@ DEPENDENCIES: - OpenSSL - PureLayout - SCWaveformView (~> 1.0) - - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`, commit `7578176e378c4602b5295f97c3329d254498523b`) + - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`) - SocketRocket (from `https://github.com/facebook/SocketRocket.git`) EXTERNAL SOURCES: AxolotlKit: :git: https://github.com/WhisperSystems/SignalProtocolKit.git SignalServiceKit: - :commit: 7578176e378c4602b5295f97c3329d254498523b :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :git: https://github.com/facebook/SocketRocket.git @@ -133,7 +132,7 @@ CHECKOUT OPTIONS: :commit: cbf2f47d59dd54d6d720fe787f835bd767443bb6 :git: https://github.com/WhisperSystems/SignalProtocolKit.git SignalServiceKit: - :commit: 7578176e378c4602b5295f97c3329d254498523b + :commit: 45b8dc9c96fe3aeb6e0c46eff7912670d2fc41a9 :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf @@ -162,6 +161,6 @@ SPEC CHECKSUMS: UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d YapDatabase: b1e43555a34a5298e23a045be96817a5ef0da58f -PODFILE CHECKSUM: 29bf376adcb82f35d46545ccdb7c77522af4f155 +PODFILE CHECKSUM: a060377074cb361576f346a58d1503b3bd708440 COCOAPODS: 1.2.0