Send null messages to mask verified syncs

First construct a null message of random size and contents and send it to the
destination. Then include that same padding in the verification sync.

Note that the sync message is additionally randomly padded like all other sync
messages.

This lets Verified sync messages appear the same as normal sync message traffic.

// FREEBIE
This commit is contained in:
lilia 2017-06-22 15:24:01 -07:00 committed by Scott Nonnenberg
parent bb9c97b960
commit 9f4fcc5afa
2 changed files with 48 additions and 16 deletions

View file

@ -39290,10 +39290,25 @@ MessageSender.prototype = {
var myNumber = textsecure.storage.user.getNumber();
var myDevice = textsecure.storage.user.getDeviceId();
if (myDevice != 1) {
// First send a null message to mask the sync message.
var nullMessage = new textsecure.protobuf.NullMessage();
// Generate a random int from 1 and 512
var buffer = libsignal.crypto.getRandomBytes(1);
var paddingLength = (new Uint8Array(buffer)[0] & 0x1ff) + 1;
// Generate a random padding buffer of the chosen size
nullMessage.padding = libsignal.crypto.getRandomBytes(paddingLength);
var contentMessage = new textsecure.protobuf.Content();
contentMessage.nullMessage = nullMessage;
return this.sendIndividualProto(destination, contentMessage, Date.now()).then(function() {
var verified = new textsecure.protobuf.Verified();
verified.state = state;
verified.destination = destination;
verified.identityKey = identityKey;
verified.nullMessage = nullMessage.padding;
var syncMessage = this.createSyncMessage();
syncMessage.verified = verified;
@ -39302,6 +39317,7 @@ MessageSender.prototype = {
contentMessage.syncMessage = syncMessage;
return this.sendIndividualProto(myNumber, contentMessage, Date.now());
}.bind(this));
}
},

View file

@ -322,10 +322,25 @@ MessageSender.prototype = {
var myNumber = textsecure.storage.user.getNumber();
var myDevice = textsecure.storage.user.getDeviceId();
if (myDevice != 1) {
// First send a null message to mask the sync message.
var nullMessage = new textsecure.protobuf.NullMessage();
// Generate a random int from 1 and 512
var buffer = libsignal.crypto.getRandomBytes(1);
var paddingLength = (new Uint8Array(buffer)[0] & 0x1ff) + 1;
// Generate a random padding buffer of the chosen size
nullMessage.padding = libsignal.crypto.getRandomBytes(paddingLength);
var contentMessage = new textsecure.protobuf.Content();
contentMessage.nullMessage = nullMessage;
return this.sendIndividualProto(destination, contentMessage, Date.now()).then(function() {
var verified = new textsecure.protobuf.Verified();
verified.state = state;
verified.destination = destination;
verified.identityKey = identityKey;
verified.nullMessage = nullMessage.padding;
var syncMessage = this.createSyncMessage();
syncMessage.verified = verified;
@ -334,6 +349,7 @@ MessageSender.prototype = {
contentMessage.syncMessage = syncMessage;
return this.sendIndividualProto(myNumber, contentMessage, Date.now());
}.bind(this));
}
},