From bd67150eaa70180fa518d54430e5845507936582 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Wed, 20 May 2015 15:04:21 -0700 Subject: [PATCH] Remove support for plaintext message type. // FREEBIE --- .../api/crypto/TextSecureCipher.java | 5 +- .../api/messages/TextSecureEnvelope.java | 7 -- .../api/messages/TextSecureMessage.java | 13 +--- .../internal/push/PushMessageProtos.java | 71 ++++++++----------- protobuf/IncomingPushMessageSignal.proto | 2 +- protobuf/Makefile | 2 +- 6 files changed, 36 insertions(+), 64 deletions(-) diff --git a/java/src/main/java/org/whispersystems/textsecure/api/crypto/TextSecureCipher.java b/java/src/main/java/org/whispersystems/textsecure/api/crypto/TextSecureCipher.java index 1e511f1227..ed3c62f07c 100644 --- a/java/src/main/java/org/whispersystems/textsecure/api/crypto/TextSecureCipher.java +++ b/java/src/main/java/org/whispersystems/textsecure/api/crypto/TextSecureCipher.java @@ -112,8 +112,6 @@ public class TextSecureCipher { paddedMessage = sessionCipher.decrypt(new PreKeyWhisperMessage(envelope.getMessage())); } else if (envelope.isWhisperMessage()) { paddedMessage = sessionCipher.decrypt(new WhisperMessage(envelope.getMessage())); - } else if (envelope.isPlaintext()) { - paddedMessage = envelope.getMessage(); } else { throw new InvalidMessageException("Unknown type: " + envelope.getType()); } @@ -132,7 +130,6 @@ public class TextSecureCipher { TextSecureSyncContext syncContext = createSyncContext(envelope, content); List attachments = new LinkedList<>(); boolean endSession = ((content.getFlags() & PushMessageContent.Flags.END_SESSION_VALUE) != 0); - boolean secure = envelope.isWhisperMessage() || envelope.isPreKeyWhisperMessage(); for (PushMessageContent.AttachmentPointer pointer : content.getAttachmentsList()) { attachments.add(new TextSecureAttachmentPointer(pointer.getId(), @@ -142,7 +139,7 @@ public class TextSecureCipher { } return new TextSecureMessage(envelope.getTimestamp(), groupInfo, attachments, - content.getBody(), syncContext, secure, endSession); + content.getBody(), syncContext, endSession); } private TextSecureSyncContext createSyncContext(TextSecureEnvelope envelope, PushMessageContent content) { diff --git a/java/src/main/java/org/whispersystems/textsecure/api/messages/TextSecureEnvelope.java b/java/src/main/java/org/whispersystems/textsecure/api/messages/TextSecureEnvelope.java index 9e1588752a..ef1e73fc56 100644 --- a/java/src/main/java/org/whispersystems/textsecure/api/messages/TextSecureEnvelope.java +++ b/java/src/main/java/org/whispersystems/textsecure/api/messages/TextSecureEnvelope.java @@ -180,13 +180,6 @@ public class TextSecureEnvelope { return signal.getType().getNumber() == IncomingPushMessageSignal.Type.PREKEY_BUNDLE_VALUE; } - /** - * @return true if the containing message is plaintext. - */ - public boolean isPlaintext() { - return signal.getType().getNumber() == IncomingPushMessageSignal.Type.PLAINTEXT_VALUE; - } - /** * @return true if the containing message is a delivery receipt. */ diff --git a/java/src/main/java/org/whispersystems/textsecure/api/messages/TextSecureMessage.java b/java/src/main/java/org/whispersystems/textsecure/api/messages/TextSecureMessage.java index d5ef352fcb..6551814cef 100644 --- a/java/src/main/java/org/whispersystems/textsecure/api/messages/TextSecureMessage.java +++ b/java/src/main/java/org/whispersystems/textsecure/api/messages/TextSecureMessage.java @@ -31,7 +31,6 @@ public class TextSecureMessage { private final Optional body; private final Optional group; private final Optional syncContext; - private final boolean secure; private final boolean endSession; /** @@ -68,7 +67,7 @@ public class TextSecureMessage { * @param body The message contents. */ public TextSecureMessage(long timestamp, TextSecureGroup group, List attachments, String body) { - this(timestamp, group, attachments, body, null, true, false); + this(timestamp, group, attachments, body, null, false); } /** @@ -78,15 +77,13 @@ public class TextSecureMessage { * @param group The group information (or null if none). * @param attachments The attachments (or null if none). * @param body The message contents. - * @param secure Flag indicating whether this message is to be encrypted. * @param endSession Flag indicating whether this message should close a session. */ - public TextSecureMessage(long timestamp, TextSecureGroup group, List attachments, String body, TextSecureSyncContext syncContext, boolean secure, boolean endSession) { + public TextSecureMessage(long timestamp, TextSecureGroup group, List attachments, String body, TextSecureSyncContext syncContext, boolean endSession) { this.timestamp = timestamp; this.body = Optional.fromNullable(body); this.group = Optional.fromNullable(group); this.syncContext = Optional.fromNullable(syncContext); - this.secure = secure; this.endSession = endSession; if (attachments != null && !attachments.isEmpty()) { @@ -132,10 +129,6 @@ public class TextSecureMessage { return syncContext; } - public boolean isSecure() { - return secure; - } - public boolean isEndSession() { return endSession; } @@ -191,7 +184,7 @@ public class TextSecureMessage { public TextSecureMessage build() { if (timestamp == 0) timestamp = System.currentTimeMillis(); - return new TextSecureMessage(timestamp, group, attachments, body, null, true, endSession); + return new TextSecureMessage(timestamp, group, attachments, body, null, endSession); } } } diff --git a/java/src/main/java/org/whispersystems/textsecure/internal/push/PushMessageProtos.java b/java/src/main/java/org/whispersystems/textsecure/internal/push/PushMessageProtos.java index e720e132f7..db02e48e4d 100644 --- a/java/src/main/java/org/whispersystems/textsecure/internal/push/PushMessageProtos.java +++ b/java/src/main/java/org/whispersystems/textsecure/internal/push/PushMessageProtos.java @@ -236,18 +236,14 @@ public final class PushMessageProtos { * PREKEY_BUNDLE = 3; */ PREKEY_BUNDLE(3, 3), - /** - * PLAINTEXT = 4; - */ - PLAINTEXT(4, 4), /** * RECEIPT = 5; + * + *
+       *    PLAINTEXT     = 4; // No longer supported
+       * 
*/ - RECEIPT(5, 5), - /** - * COPY = 6; - */ - COPY(6, 6), + RECEIPT(4, 5), ; /** @@ -266,18 +262,14 @@ public final class PushMessageProtos { * PREKEY_BUNDLE = 3; */ public static final int PREKEY_BUNDLE_VALUE = 3; - /** - * PLAINTEXT = 4; - */ - public static final int PLAINTEXT_VALUE = 4; /** * RECEIPT = 5; + * + *
+       *    PLAINTEXT     = 4; // No longer supported
+       * 
*/ public static final int RECEIPT_VALUE = 5; - /** - * COPY = 6; - */ - public static final int COPY_VALUE = 6; public final int getNumber() { return value; } @@ -288,9 +280,7 @@ public final class PushMessageProtos { case 1: return CIPHERTEXT; case 2: return KEY_EXCHANGE; case 3: return PREKEY_BUNDLE; - case 4: return PLAINTEXT; case 5: return RECEIPT; - case 6: return COPY; default: return null; } } @@ -4846,32 +4836,31 @@ public final class PushMessageProtos { static { java.lang.String[] descriptorData = { "\n\037IncomingPushMessageSignal.proto\022\ntexts" + - "ecure\"\236\002\n\031IncomingPushMessageSignal\0228\n\004t" + + "ecure\"\205\002\n\031IncomingPushMessageSignal\0228\n\004t" + "ype\030\001 \001(\0162*.textsecure.IncomingPushMessa" + "geSignal.Type\022\016\n\006source\030\002 \001(\t\022\024\n\014sourceD" + "evice\030\007 \001(\r\022\r\n\005relay\030\003 \001(\t\022\021\n\ttimestamp\030" + - "\005 \001(\004\022\017\n\007message\030\006 \001(\014\"n\n\004Type\022\013\n\007UNKNOW" + + "\005 \001(\004\022\017\n\007message\030\006 \001(\014\"U\n\004Type\022\013\n\007UNKNOW" + "N\020\000\022\016\n\nCIPHERTEXT\020\001\022\020\n\014KEY_EXCHANGE\020\002\022\021\n" + - "\rPREKEY_BUNDLE\020\003\022\r\n\tPLAINTEXT\020\004\022\013\n\007RECEI" + - "PT\020\005\022\010\n\004COPY\020\006\"\206\005\n\022PushMessageContent\022\014\n" + - "\004body\030\001 \001(\t\022E\n\013attachments\030\002 \003(\01320.texts", - "ecure.PushMessageContent.AttachmentPoint" + - "er\022:\n\005group\030\003 \001(\0132+.textsecure.PushMessa" + - "geContent.GroupContext\022\r\n\005flags\030\004 \001(\r\022?\n" + - "\004sync\030\005 \001(\01321.textsecure.PushMessageCont" + - "ent.SyncMessageContext\032A\n\021AttachmentPoin" + - "ter\022\n\n\002id\030\001 \001(\006\022\023\n\013contentType\030\002 \001(\t\022\013\n\003" + - "key\030\003 \001(\014\032\363\001\n\014GroupContext\022\n\n\002id\030\001 \001(\014\022>" + - "\n\004type\030\002 \001(\01620.textsecure.PushMessageCon" + - "tent.GroupContext.Type\022\014\n\004name\030\003 \001(\t\022\017\n\007" + - "members\030\004 \003(\t\022@\n\006avatar\030\005 \001(\01320.textsecu", - "re.PushMessageContent.AttachmentPointer\"" + - "6\n\004Type\022\013\n\007UNKNOWN\020\000\022\n\n\006UPDATE\020\001\022\013\n\007DELI" + - "VER\020\002\022\010\n\004QUIT\020\003\032<\n\022SyncMessageContext\022\023\n" + - "\013destination\030\001 \001(\t\022\021\n\ttimestamp\030\002 \001(\004\"\030\n" + - "\005Flags\022\017\n\013END_SESSION\020\001B@\n+org.whispersy" + - "stems.textsecure.internal.pushB\021PushMess" + - "ageProtos" + "\rPREKEY_BUNDLE\020\003\022\013\n\007RECEIPT\020\005\"\206\005\n\022PushMe" + + "ssageContent\022\014\n\004body\030\001 \001(\t\022E\n\013attachment" + + "s\030\002 \003(\01320.textsecure.PushMessageContent.", + "AttachmentPointer\022:\n\005group\030\003 \001(\0132+.texts" + + "ecure.PushMessageContent.GroupContext\022\r\n" + + "\005flags\030\004 \001(\r\022?\n\004sync\030\005 \001(\01321.textsecure." + + "PushMessageContent.SyncMessageContext\032A\n" + + "\021AttachmentPointer\022\n\n\002id\030\001 \001(\006\022\023\n\013conten" + + "tType\030\002 \001(\t\022\013\n\003key\030\003 \001(\014\032\363\001\n\014GroupContex" + + "t\022\n\n\002id\030\001 \001(\014\022>\n\004type\030\002 \001(\01620.textsecure" + + ".PushMessageContent.GroupContext.Type\022\014\n" + + "\004name\030\003 \001(\t\022\017\n\007members\030\004 \003(\t\022@\n\006avatar\030\005" + + " \001(\01320.textsecure.PushMessageContent.Att", + "achmentPointer\"6\n\004Type\022\013\n\007UNKNOWN\020\000\022\n\n\006U" + + "PDATE\020\001\022\013\n\007DELIVER\020\002\022\010\n\004QUIT\020\003\032<\n\022SyncMe" + + "ssageContext\022\023\n\013destination\030\001 \001(\t\022\021\n\ttim" + + "estamp\030\002 \001(\004\"\030\n\005Flags\022\017\n\013END_SESSION\020\001B@" + + "\n+org.whispersystems.textsecure.internal" + + ".pushB\021PushMessageProtos" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { diff --git a/protobuf/IncomingPushMessageSignal.proto b/protobuf/IncomingPushMessageSignal.proto index 4dd54b1200..61b2afaf7a 100644 --- a/protobuf/IncomingPushMessageSignal.proto +++ b/protobuf/IncomingPushMessageSignal.proto @@ -9,7 +9,7 @@ message IncomingPushMessageSignal { CIPHERTEXT = 1; KEY_EXCHANGE = 2; PREKEY_BUNDLE = 3; - PLAINTEXT = 4; +// PLAINTEXT = 4; // No longer supported RECEIPT = 5; } optional Type type = 1; diff --git a/protobuf/Makefile b/protobuf/Makefile index 70c811fb96..d9591b8711 100644 --- a/protobuf/Makefile +++ b/protobuf/Makefile @@ -1,3 +1,3 @@ all: - protoc --java_out=../src/main/java/ IncomingPushMessageSignal.proto Provisioning.proto WebSocketResources.proto + protoc --java_out=../java/src/main/java/ IncomingPushMessageSignal.proto Provisioning.proto WebSocketResources.proto