diff --git a/js/libtextsecure.js b/js/libtextsecure.js index cb5dbbab..f8f8225d 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 1957e711..da379a2f 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 45cd3991..e2e2808f 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);