From ea0c3c8a36a1b7315726b4424a2dfccea3dcbc10 Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Thu, 10 Dec 2020 13:41:54 +1100 Subject: [PATCH] Send "unidentified sender" messages as plain text. --- .../securesms/jobs/PushGroupSendJob.java | 2 +- .../service/loki/crypto/LokiServiceCipher.kt | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java index b8e6b63804..c4faad91d4 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java @@ -135,7 +135,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType { @Override public void onPushSend() - throws IOException, MmsException, NoSuchMessageException, RetryLaterException + throws IOException, MmsException, NoSuchMessageException, RetryLaterException { MmsDatabase database = DatabaseFactory.getMmsDatabase(context); OutgoingMediaMessage message = database.getOutgoingMessage(messageId); diff --git a/libsignal/src/main/java/org/session/libsignal/service/loki/crypto/LokiServiceCipher.kt b/libsignal/src/main/java/org/session/libsignal/service/loki/crypto/LokiServiceCipher.kt index a11ef27c61..e48d04da6b 100644 --- a/libsignal/src/main/java/org/session/libsignal/service/loki/crypto/LokiServiceCipher.kt +++ b/libsignal/src/main/java/org/session/libsignal/service/loki/crypto/LokiServiceCipher.kt @@ -23,13 +23,20 @@ class LokiServiceCipher( override fun decrypt(envelope: SignalServiceEnvelope, ciphertext: ByteArray): Plaintext { // return if (envelope.isFallbackMessage) decryptFallbackMessage(envelope, ciphertext) else super.decrypt(envelope, ciphertext) -// return decryptFallbackMessage(envelope, ciphertext); - //AC: Messages come unencrypted (for refactoring time being). - val transportDetails = PushTransportDetails(FallbackSessionCipher.sessionVersion) - val unpaddedMessageBody = transportDetails.getStrippedPaddingMessageBody(ciphertext) - val metadata = Metadata(envelope.source, envelope.sourceDevice, envelope.timestamp, false) - return Plaintext(metadata, unpaddedMessageBody) + return when { + envelope.isUnidentifiedSender -> { + //AC: Messages come unencrypted (for refactoring time being). + val transportDetails = PushTransportDetails(FallbackSessionCipher.sessionVersion) + val unpaddedMessageBody = transportDetails.getStrippedPaddingMessageBody(ciphertext) + val metadata = Metadata(envelope.source, envelope.sourceDevice, envelope.timestamp, false) + return Plaintext(metadata, unpaddedMessageBody) + } + envelope.isFallbackMessage -> + decryptFallbackMessage(envelope, ciphertext) + else -> + super.decrypt(envelope, ciphertext) + } } private fun decryptFallbackMessage(envelope: SignalServiceEnvelope, ciphertext: ByteArray): Plaintext {