From 8010a09045ecfa5feb89dd49e5425b12b987bba6 Mon Sep 17 00:00:00 2001 From: lilia Date: Sun, 1 May 2016 14:49:33 -0700 Subject: [PATCH] Remove decryptWhisperMessage from protocol_wrapper // FREEBIE --- js/libtextsecure.js | 11 +++-------- libtextsecure/message_receiver.js | 4 +++- libtextsecure/protocol_wrapper.js | 7 ------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index cb5dbbab827..f8f8225d9c0 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -35493,13 +35493,6 @@ Internal.SessionLock.queueJobForNumber = function queueJobForNumber(number, runJ window.textsecure = window.textsecure || {}; window.textsecure.protocol_wrapper = { - decryptWhisperMessage: function(fromAddress, message) { - return queueJobForNumber(fromAddress, function() { - var address = libsignal.SignalProtocolAddress.fromString(fromAddress); - var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address); - return sessionCipher.decryptWhisperMessage(message.toArrayBuffer()); - }); - }, closeOpenSessionForDevice: function(encodedNumber) { return queueJobForNumber(encodedNumber, function() { return protocolInstance.closeOpenSessionForDevice(encodedNumber); @@ -37134,9 +37127,11 @@ MessageReceiver.prototype.extend({ decrypt: function(envelope, ciphertext) { var fromAddress = [envelope.source , (envelope.sourceDevice || 0)].join('.'); var promise; + var address = new libsignal.SignalProtocolAddress(envelope.source, envelope.sourceDevice); + var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address); switch(envelope.type) { case textsecure.protobuf.Envelope.Type.CIPHERTEXT: - promise = textsecure.protocol_wrapper.decryptWhisperMessage(fromAddress, ciphertext); + promise = sessionCipher.decryptWhisperMessage(ciphertext.toArrayBuffer()); break; case textsecure.protobuf.Envelope.Type.PREKEY_BUNDLE: promise = textsecure.protocol_wrapper.handlePreKeyWhisperMessage(fromAddress, ciphertext); diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 1957e711664..da379a2f655 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -111,9 +111,11 @@ MessageReceiver.prototype.extend({ decrypt: function(envelope, ciphertext) { var fromAddress = [envelope.source , (envelope.sourceDevice || 0)].join('.'); var promise; + var address = new libsignal.SignalProtocolAddress(envelope.source, envelope.sourceDevice); + var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address); switch(envelope.type) { case textsecure.protobuf.Envelope.Type.CIPHERTEXT: - promise = textsecure.protocol_wrapper.decryptWhisperMessage(fromAddress, ciphertext); + promise = sessionCipher.decryptWhisperMessage(ciphertext.toArrayBuffer()); break; case textsecure.protobuf.Envelope.Type.PREKEY_BUNDLE: promise = textsecure.protocol_wrapper.handlePreKeyWhisperMessage(fromAddress, ciphertext); diff --git a/libtextsecure/protocol_wrapper.js b/libtextsecure/protocol_wrapper.js index 45cd3991abb..e2e2808fcda 100644 --- a/libtextsecure/protocol_wrapper.js +++ b/libtextsecure/protocol_wrapper.js @@ -28,13 +28,6 @@ window.textsecure = window.textsecure || {}; window.textsecure.protocol_wrapper = { - decryptWhisperMessage: function(fromAddress, message) { - return queueJobForNumber(fromAddress, function() { - var address = libsignal.SignalProtocolAddress.fromString(fromAddress); - var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address); - return sessionCipher.decryptWhisperMessage(message.toArrayBuffer()); - }); - }, closeOpenSessionForDevice: function(encodedNumber) { return queueJobForNumber(encodedNumber, function() { return protocolInstance.closeOpenSessionForDevice(encodedNumber);