Update libsignal-protocol v1.1.0
Moves padding operations to the service library. // FREEBIE
This commit is contained in:
parent
b8fddfbbdd
commit
167f19153c
4 changed files with 76 additions and 46 deletions
|
@ -98,14 +98,31 @@ OutgoingMessage.prototype = {
|
|||
});
|
||||
},
|
||||
|
||||
getPaddedMessageLength: function(messageLength) {
|
||||
var messageLengthWithTerminator = messageLength + 1;
|
||||
var messagePartCount = Math.floor(messageLengthWithTerminator / 160);
|
||||
|
||||
if (messageLengthWithTerminator % 160 !== 0) {
|
||||
messagePartCount++;
|
||||
}
|
||||
|
||||
return messagePartCount * 160;
|
||||
},
|
||||
|
||||
doSendMessage: function(number, deviceIds, recurse) {
|
||||
var ciphers = {};
|
||||
var plaintext = this.message.toArrayBuffer();
|
||||
var paddedPlaintext = new Uint8Array(
|
||||
this.getPaddedMessageLength(plaintext.byteLength + 1) - 1
|
||||
);
|
||||
paddedPlaintext.set(new Uint8Array(plaintext));
|
||||
paddedPlaintext[plaintext.byteLength] = 0x80;
|
||||
|
||||
return Promise.all(deviceIds.map(function(deviceId) {
|
||||
var address = new libsignal.SignalProtocolAddress(number, deviceId);
|
||||
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
||||
ciphers[address.getDeviceId()] = sessionCipher;
|
||||
return this.encryptToDevice(address, plaintext, sessionCipher);
|
||||
return this.encryptToDevice(address, paddedPlaintext, sessionCipher);
|
||||
}.bind(this))).then(function(jsonData) {
|
||||
return this.transmitMessage(number, jsonData, this.timestamp).then(function() {
|
||||
this.successfulNumbers[this.successfulNumbers.length] = number;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue