From 40edf1992a0a37d8db80a5385dc47af6c3c556c6 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Tue, 23 Jul 2019 16:00:27 +1000 Subject: [PATCH] Verify friend request stuff before decrypting --- SignalServiceKit/src/Loki/Crypto/SessionCipher+Loki.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SignalServiceKit/src/Loki/Crypto/SessionCipher+Loki.m b/SignalServiceKit/src/Loki/Crypto/SessionCipher+Loki.m index 466cba9af..be36b6684 100644 --- a/SignalServiceKit/src/Loki/Crypto/SessionCipher+Loki.m +++ b/SignalServiceKit/src/Loki/Crypto/SessionCipher+Loki.m @@ -27,13 +27,14 @@ NSString *const kNSNotificationKey_ContactPubKey = @"kNSNotificationKey_ContactP // Our state before we decrypt the message SessionState *_Nullable state = [self getCurrentState:protocolContext]; - // While decrypting our state may change internally - NSData *plainText = [self throws_decrypt:whisperMessage protocolContext:protocolContext]; - // Loki: Verify incoming friend request messages if (!state) { [self throws_verifyFriendRequestAcceptPreKeyForMessage:whisperMessage protocolContext:protocolContext]; } + + // While decrypting our state may change internally + NSData *plainText = [self throws_decrypt:whisperMessage protocolContext:protocolContext]; + // Loki: Handle any session resets [self handleSessionReset:whisperMessage previousState:state protocolContext:protocolContext];