Untrusted identity is not always a legacy message content

Closes #5924
Fixes #5922
// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-01-12 10:33:23 -08:00
parent 770026d4ee
commit cb23e3a930

View File

@ -604,9 +604,10 @@ public class PushDecryptJob extends ContextJob {
EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context); EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
Recipients recipients = RecipientFactory.getRecipientsFromString(context, envelope.getSource(), false); Recipients recipients = RecipientFactory.getRecipientsFromString(context, envelope.getSource(), false);
long recipientId = recipients.getPrimaryRecipient().getRecipientId(); long recipientId = recipients.getPrimaryRecipient().getRecipientId();
PreKeySignalMessage whisperMessage = new PreKeySignalMessage(envelope.getLegacyMessage()); byte[] ciphertext = envelope.hasLegacyMessage() ? envelope.getLegacyMessage() : envelope.getContent();
PreKeySignalMessage whisperMessage = new PreKeySignalMessage(ciphertext);
IdentityKey identityKey = whisperMessage.getIdentityKey(); IdentityKey identityKey = whisperMessage.getIdentityKey();
String encoded = Base64.encodeBytes(envelope.getLegacyMessage()); String encoded = Base64.encodeBytes(ciphertext);
IncomingTextMessage textMessage = new IncomingTextMessage(envelope.getSource(), envelope.getSourceDevice(), IncomingTextMessage textMessage = new IncomingTextMessage(envelope.getSource(), envelope.getSourceDevice(),
envelope.getTimestamp(), encoded, envelope.getTimestamp(), encoded,
Optional.<SignalServiceGroup>absent(), 0); Optional.<SignalServiceGroup>absent(), 0);