Prevent session corruption by using a single serial queue for encrypt and decrypt

coordinate SignalProtocol encryption/decryption on a single serial
queue. Previously message sending encrypted on the sending thread, while
message receiving decrypted on the main thread.

// FREEBIE
This commit is contained in:
Michael Kirk 2017-01-22 18:14:00 -05:00
parent c4eecb24d7
commit 4e72ab92c8
3 changed files with 14 additions and 8 deletions

View File

@ -3,8 +3,9 @@ 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 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git', branch: 'master'
pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git', branch: 'mkirk/session-corruption'
#pod 'AxolotlKit', path: '../SignalProtocolKit'
pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git'
#pod 'SignalServiceKit', path: '../SignalServiceKit'
pod 'OpenSSL'
pod 'PastelogKit', '~> 1.3'

View File

@ -115,31 +115,31 @@ PODS:
- ZXingObjC/All (3.1.0)
DEPENDENCIES:
- AxolotlKit (from `https://github.com/WhisperSystems/SignalProtocolKit.git`)
- AxolotlKit (from `https://github.com/WhisperSystems/SignalProtocolKit.git`, branch `mkirk/session-corruption`)
- FFCircularProgressView (~> 0.5)
- JSQMessagesViewController
- OpenSSL
- PastelogKit (~> 1.3)
- SCWaveformView (~> 1.0)
- SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`, branch `master`)
- SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`)
- SocketRocket (from `https://github.com/facebook/SocketRocket.git`)
- ZXingObjC
EXTERNAL SOURCES:
AxolotlKit:
:branch: mkirk/session-corruption
:git: https://github.com/WhisperSystems/SignalProtocolKit.git
SignalServiceKit:
:branch: master
:git: https://github.com/WhisperSystems/SignalServiceKit.git
SocketRocket:
:git: https://github.com/facebook/SocketRocket.git
CHECKOUT OPTIONS:
AxolotlKit:
:commit: 714f5ebe199ecc999b33c6f97a4bb57e2db90e75
:commit: 55630ef62403de7eee31ac42b8827e390b6194f3
:git: https://github.com/WhisperSystems/SignalProtocolKit.git
SignalServiceKit:
:commit: a112930277890f78676ae32632e9e1ed44034c45
:commit: 32aad85a7861433571c70622fe720098275cad56
:git: https://github.com/WhisperSystems/SignalServiceKit.git
SocketRocket:
:commit: 41b57bb2fc292a814f758441a05243eb38457027
@ -170,6 +170,6 @@ SPEC CHECKSUMS:
YapDatabase: b1e43555a34a5298e23a045be96817a5ef0da58f
ZXingObjC: bf15b3814f7a105b6d99f47da2333c93a063650a
PODFILE CHECKSUM: cb24c78080551874a45d1a20de4a1bef7427b41f
PODFILE CHECKSUM: 0b9f2a480586a683632948584eb8eba8ab0f4283
COCOAPODS: 1.0.1

View File

@ -21,9 +21,11 @@
#import "TSSocketManager.h"
#import "TextSecureKitEnv.h"
#import "VersionMigrations.h"
#import <AxolotlKit/SessionCipher.h>
#import <PastelogKit/Pastelog.h>
#import <PromiseKit/AnyPromise.h>
#import <SignalServiceKit/OWSDisappearingMessagesJob.h>
#import <SignalServiceKit/OWSDispatch.h>
#import <SignalServiceKit/OWSIncomingMessageReadObserver.h>
#import <SignalServiceKit/OWSMessageSender.h>
#import <SignalServiceKit/TSAccountManager.h>
@ -175,6 +177,9 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
}
- (void)setupTSKitEnv {
// Encryption/Descryption mutates session state and must be synchronized on a serial queue.
[SessionCipher setSessionCipherDispatchQueue:[OWSDispatch sessionCipher]];
[TextSecureKitEnv sharedEnv].contactsManager = [Environment getCurrent].contactsManager;
[[TSStorageManager sharedManager] setupDatabase];
[TextSecureKitEnv sharedEnv].notificationsManager = [[NotificationsManager alloc] init];