Remove handlePreKeyWhisperMessage from protocol_wrapper

// FREEBIE
This commit is contained in:
lilia 2016-05-01 15:00:06 -07:00
parent 8010a09045
commit 0d5ec60a7a
3 changed files with 42 additions and 50 deletions

View file

@ -109,7 +109,6 @@ MessageReceiver.prototype.extend({
this.dispatchEvent(ev);
},
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);
@ -118,7 +117,27 @@ MessageReceiver.prototype.extend({
promise = sessionCipher.decryptWhisperMessage(ciphertext.toArrayBuffer());
break;
case textsecure.protobuf.Envelope.Type.PREKEY_BUNDLE:
promise = textsecure.protocol_wrapper.handlePreKeyWhisperMessage(fromAddress, ciphertext);
console.log('prekey whisper message');
ciphertext.mark();
var version = ciphertext.readUint8();
if ((version & 0xF) > 3 || (version >> 4) < 3) {
// min version > 3 or max version < 3
throw new Error("Incompatible version byte");
}
promise = sessionCipher.decryptPreKeyWhisperMessage(ciphertext).catch(function(e) {
if (e.message === 'Unknown identity key') {
ciphertext.reset(); // restore the version byte.
// create an error that the UI will pick up and ask the
// user if they want to re-negotiate
throw new textsecure.IncomingIdentityKeyError(
address.toString(),
ciphertext.toArrayBuffer(),
e.identityKey
);
}
throw e;
});
break;
default:
promise = Promise.reject(new Error("Unknown message type"));