diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index c158f3643..b07966ab0 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -705,16 +705,16 @@ MessageReceiver.prototype.extend({ switch (envelope.type) { case textsecure.protobuf.Envelope.Type.CIPHERTEXT: window.log.info('message from', this.getEnvelopeId(envelope)); - promise = sessionCipher.decryptWhisperMessage(ciphertext); - // TODO: restore unpadding (?) - // .then(this.unpad); + promise = sessionCipher.decryptWhisperMessage(ciphertext) + .then(this.unpad); break; case textsecure.protobuf.Envelope.Type.FRIEND_REQUEST: window.log.info('friend-request message from ', envelope.source); const fallBackSessionCipher = new libloki.FallBackSessionCipher( address ); - promise = fallBackSessionCipher.decrypt(ciphertext.toArrayBuffer()); + promise = fallBackSessionCipher.decrypt(ciphertext.toArrayBuffer()) + .then(this.unpad); break; case textsecure.protobuf.Envelope.Type.PREKEY_BUNDLE: window.log.info('prekey message from', this.getEnvelopeId(envelope)); @@ -826,7 +826,6 @@ MessageReceiver.prototype.extend({ }, async decryptPreKeyWhisperMessage(ciphertext, sessionCipher, address) { const padded = await sessionCipher.decryptPreKeyWhisperMessage(ciphertext); - return padded; try { return this.unpad(padded); diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index fb8c949f2..4a01fdbfd 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -207,13 +207,11 @@ OutgoingMessage.prototype = { getPlaintext() { if (!this.plaintext) { const messageBuffer = this.message.toArrayBuffer(); - this.plaintext = new Uint8Array(messageBuffer.byteLength); - // TODO: figure out why we needed padding in the first place - // this.plaintext = new Uint8Array( - // this.getPaddedMessageLength(messageBuffer.byteLength + 1) - 1 - // ); + this.plaintext = new Uint8Array( + this.getPaddedMessageLength(messageBuffer.byteLength + 1) - 1 + ); this.plaintext.set(new Uint8Array(messageBuffer)); - // this.plaintext[messageBuffer.byteLength] = 0x80; + this.plaintext[messageBuffer.byteLength] = 0x80; } return this.plaintext; },