Update libaxolotl, handle untrusted identitykey

Previously we had no access to the new untrusted identity
for verification purposes.

// FREEBIE
This commit is contained in:
lilia 2015-07-20 14:13:18 -07:00
parent af48ca9e4b
commit cc303e0802
4 changed files with 16 additions and 10 deletions

View file

@ -44,7 +44,7 @@
return registeredFunctions[this.functionCode].apply(window, this.args); return registeredFunctions[this.functionCode].apply(window, this.args);
}; };
function IncomingIdentityKeyError(number, message) { function IncomingIdentityKeyError(number, message, key) {
ReplayableError.call(this, { ReplayableError.call(this, {
functionCode : Type.INIT_SESSION, functionCode : Type.INIT_SESSION,
args : [number, message] args : [number, message]
@ -52,6 +52,7 @@
}); });
this.name = 'IncomingIdentityKeyError'; this.name = 'IncomingIdentityKeyError';
this.message = "The identity of the sender has changed. This may be malicious, or the sender may have simply reinstalled."; this.message = "The identity of the sender has changed. This may be malicious, or the sender may have simply reinstalled.";
this.identityKey = key;
this.number = number.split('.')[0]; this.number = number.split('.')[0];
} }
IncomingIdentityKeyError.prototype = new ReplayableError(); IncomingIdentityKeyError.prototype = new ReplayableError();
@ -37278,7 +37279,9 @@ window.axolotl.protocol = function(storage_interface) {
closeSession(open_session); // To be returned and saved later closeSession(open_session); // To be returned and saved later
} else { } else {
// ...otherwise create an error that the UI will pick up and ask the user if they want to re-negotiate // ...otherwise create an error that the UI will pick up and ask the user if they want to re-negotiate
throw new Error('Unknown identity key'); var e = new Error('Unknown identity key');
e.identityKey = message.identityKey.toArrayBuffer();
throw e;
} }
} }
return initSession(false, preKeyPair, signedPreKeyPair, encodedNumber, axolotlInternal.utils.convertToArrayBuffer(message.identityKey), axolotlInternal.utils.convertToArrayBuffer(message.baseKey), undefined) return initSession(false, preKeyPair, signedPreKeyPair, encodedNumber, axolotlInternal.utils.convertToArrayBuffer(message.identityKey), axolotlInternal.utils.convertToArrayBuffer(message.baseKey), undefined)
@ -37441,8 +37444,8 @@ window.axolotl.protocol = function(storage_interface) {
} }
// Inits a session (maybe) and then decrypts the message // Inits a session (maybe) and then decrypts the message
self.handlePreKeyWhisperMessage = function(from, encodedMessage) { self.handlePreKeyWhisperMessage = function(from, encodedMessage, encoding) {
var preKeyProto = axolotlInternal.protobuf.PreKeyWhisperMessage.decode(encodedMessage); var preKeyProto = axolotlInternal.protobuf.PreKeyWhisperMessage.decode(encodedMessage, encoding);
return initSessionFromPreKeyWhisperMessage(from, preKeyProto).then(function(sessions) { return initSessionFromPreKeyWhisperMessage(from, preKeyProto).then(function(sessions) {
return doDecryptWhisperMessage(from, axolotlInternal.utils.convertToString(preKeyProto.message), sessions[0], preKeyProto.registrationId).then(function(result) { return doDecryptWhisperMessage(from, axolotlInternal.utils.convertToString(preKeyProto.message), sessions[0], preKeyProto.registrationId).then(function(result) {
if (sessions[1] !== undefined) if (sessions[1] !== undefined)
@ -37800,7 +37803,7 @@ axolotlInternal.RecipientRecord = function() {
if (e.message === 'Unknown identity key') { if (e.message === 'Unknown identity key') {
// create an error that the UI will pick up and ask the // create an error that the UI will pick up and ask the
// user if they want to re-negotiate // user if they want to re-negotiate
throw new textsecure.IncomingIdentityKeyError(fromAddress, blob); throw new textsecure.IncomingIdentityKeyError(fromAddress, blob, e.identityKey);
} }
throw e; throw e;
}); });

View file

@ -21,7 +21,7 @@
if (e.message === 'Unknown identity key') { if (e.message === 'Unknown identity key') {
// create an error that the UI will pick up and ask the // create an error that the UI will pick up and ask the
// user if they want to re-negotiate // user if they want to re-negotiate
throw new textsecure.IncomingIdentityKeyError(fromAddress, blob); throw new textsecure.IncomingIdentityKeyError(fromAddress, blob, e.identityKey);
} }
throw e; throw e;
}); });

View file

@ -43,7 +43,7 @@
return registeredFunctions[this.functionCode].apply(window, this.args); return registeredFunctions[this.functionCode].apply(window, this.args);
}; };
function IncomingIdentityKeyError(number, message) { function IncomingIdentityKeyError(number, message, key) {
ReplayableError.call(this, { ReplayableError.call(this, {
functionCode : Type.INIT_SESSION, functionCode : Type.INIT_SESSION,
args : [number, message] args : [number, message]
@ -51,6 +51,7 @@
}); });
this.name = 'IncomingIdentityKeyError'; this.name = 'IncomingIdentityKeyError';
this.message = "The identity of the sender has changed. This may be malicious, or the sender may have simply reinstalled."; this.message = "The identity of the sender has changed. This may be malicious, or the sender may have simply reinstalled.";
this.identityKey = key;
this.number = number.split('.')[0]; this.number = number.split('.')[0];
} }
IncomingIdentityKeyError.prototype = new ReplayableError(); IncomingIdentityKeyError.prototype = new ReplayableError();

View file

@ -37201,7 +37201,9 @@ window.axolotl.protocol = function(storage_interface) {
closeSession(open_session); // To be returned and saved later closeSession(open_session); // To be returned and saved later
} else { } else {
// ...otherwise create an error that the UI will pick up and ask the user if they want to re-negotiate // ...otherwise create an error that the UI will pick up and ask the user if they want to re-negotiate
throw new Error('Unknown identity key'); var e = new Error('Unknown identity key');
e.identityKey = message.identityKey.toArrayBuffer();
throw e;
} }
} }
return initSession(false, preKeyPair, signedPreKeyPair, encodedNumber, axolotlInternal.utils.convertToArrayBuffer(message.identityKey), axolotlInternal.utils.convertToArrayBuffer(message.baseKey), undefined) return initSession(false, preKeyPair, signedPreKeyPair, encodedNumber, axolotlInternal.utils.convertToArrayBuffer(message.identityKey), axolotlInternal.utils.convertToArrayBuffer(message.baseKey), undefined)
@ -37364,8 +37366,8 @@ window.axolotl.protocol = function(storage_interface) {
} }
// Inits a session (maybe) and then decrypts the message // Inits a session (maybe) and then decrypts the message
self.handlePreKeyWhisperMessage = function(from, encodedMessage) { self.handlePreKeyWhisperMessage = function(from, encodedMessage, encoding) {
var preKeyProto = axolotlInternal.protobuf.PreKeyWhisperMessage.decode(encodedMessage); var preKeyProto = axolotlInternal.protobuf.PreKeyWhisperMessage.decode(encodedMessage, encoding);
return initSessionFromPreKeyWhisperMessage(from, preKeyProto).then(function(sessions) { return initSessionFromPreKeyWhisperMessage(from, preKeyProto).then(function(sessions) {
return doDecryptWhisperMessage(from, axolotlInternal.utils.convertToString(preKeyProto.message), sessions[0], preKeyProto.registrationId).then(function(result) { return doDecryptWhisperMessage(from, axolotlInternal.utils.convertToString(preKeyProto.message), sessions[0], preKeyProto.registrationId).then(function(result) {
if (sessions[1] !== undefined) if (sessions[1] !== undefined)