From 8fa5ea8d221c0cee2b6954662a5ea5c257ef294f Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 22 Jun 2017 17:05:17 -0400 Subject: [PATCH] session clearing must be in IdentityKeyStore implementation Trying to do it in the protocol will not work with multiple devices, because we'll only archive the session of the first sending device. // FREEBIE --- AxolotlKit/Classes/SessionCipher.m | 11 +++-------- AxolotlKit/Classes/Sessions/SessionBuilder.m | 9 +-------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/AxolotlKit/Classes/SessionCipher.m b/AxolotlKit/Classes/SessionCipher.m index ce6b745..92c93d3 100644 --- a/AxolotlKit/Classes/SessionCipher.m +++ b/AxolotlKit/Classes/SessionCipher.m @@ -124,9 +124,7 @@ static dispatch_queue_t _sessionCipherDispatchQueue; userInfo:@{}]; } - if ([self.identityKeyStore saveRemoteIdentity:sessionState.remoteIdentityKey recipientId:self.recipientId]) { - [sessionRecord removePreviousSessionStates]; - } + [self.identityKeyStore saveRemoteIdentity:sessionState.remoteIdentityKey recipientId:self.recipientId]; NSData *ciphertextBody = [AES_CBC encryptCBCMode:paddedMessage withKey:messageKeys.cipherKey withIV:messageKeys.iv]; @@ -202,11 +200,8 @@ static dispatch_queue_t _sessionCipherDispatchQueue; userInfo:@{}]; } - if ([self.identityKeyStore saveRemoteIdentity:sessionRecord.sessionState.remoteIdentityKey - recipientId:self.recipientId]) { - [sessionRecord removePreviousSessionStates]; - } - + [self.identityKeyStore saveRemoteIdentity:sessionRecord.sessionState.remoteIdentityKey + recipientId:self.recipientId]; [self.sessionStore storeSession:self.recipientId deviceId:self.deviceId session:sessionRecord]; return plaintext; diff --git a/AxolotlKit/Classes/Sessions/SessionBuilder.m b/AxolotlKit/Classes/Sessions/SessionBuilder.m index 0276f1b..9d4424e 100644 --- a/AxolotlKit/Classes/Sessions/SessionBuilder.m +++ b/AxolotlKit/Classes/Sessions/SessionBuilder.m @@ -141,14 +141,7 @@ const int kPreKeyOfLastResortId = 0xFFFFFF; break; } - BOOL previousIdentityExisted = - [self.identityStore saveRemoteIdentity:theirIdentityKey recipientId:self.recipientId]; - if (previousIdentityExisted) { - DDLogInfo(@"%@ PKWM removing previous session states for changed identity for recipient:%@", - self.tag, - self.recipientId); - [sessionRecord removePreviousSessionStates]; - } + [self.identityStore saveRemoteIdentity:theirIdentityKey recipientId:self.recipientId]; return unSignedPrekeyId; }