Send "unidentified sender" messages as plain text.

This commit is contained in:
Anton Chekulaev 2020-12-10 13:41:54 +11:00
parent 63d1e7087a
commit ea0c3c8a36
2 changed files with 14 additions and 7 deletions

View File

@ -23,14 +23,21 @@ 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);
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 {
val cipher = FallbackSessionCipher(userPrivateKey, envelope.source)