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,18 +39290,34 @@ MessageSender.prototype = {
var myNumber = textsecure.storage.user.getNumber();
var myDevice = textsecure.storage.user.getDeviceId();
if (myDevice != 1) {
var verified = new textsecure.protobuf.Verified();
verified.state = state;
verified.destination = destination;
verified.identityKey = identityKey;
// First send a null message to mask the sync message.
var nullMessage = new textsecure.protobuf.NullMessage();
var syncMessage = this.createSyncMessage();
syncMessage.verified = verified;
// 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.syncMessage = syncMessage;
contentMessage.nullMessage = nullMessage;
return this.sendIndividualProto(myNumber, contentMessage, Date.now());
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;
var contentMessage = new textsecure.protobuf.Content();
contentMessage.syncMessage = syncMessage;
return this.sendIndividualProto(myNumber, contentMessage, Date.now());
}.bind(this));
}
},

View file

@ -322,18 +322,34 @@ MessageSender.prototype = {
var myNumber = textsecure.storage.user.getNumber();
var myDevice = textsecure.storage.user.getDeviceId();
if (myDevice != 1) {
var verified = new textsecure.protobuf.Verified();
verified.state = state;
verified.destination = destination;
verified.identityKey = identityKey;
// First send a null message to mask the sync message.
var nullMessage = new textsecure.protobuf.NullMessage();
var syncMessage = this.createSyncMessage();
syncMessage.verified = verified;
// 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.syncMessage = syncMessage;
contentMessage.nullMessage = nullMessage;
return this.sendIndividualProto(myNumber, contentMessage, Date.now());
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;
var contentMessage = new textsecure.protobuf.Content();
contentMessage.syncMessage = syncMessage;
return this.sendIndividualProto(myNumber, contentMessage, Date.now());
}.bind(this));
}
},