Update libsignal-protocol
// FREEBIE
This commit is contained in:
parent
1b9eb83422
commit
d295fa7057
2 changed files with 65 additions and 21 deletions
|
@ -35950,7 +35950,7 @@ SessionBuilder.prototype = {
|
|||
processPreKey: function(device) {
|
||||
return Internal.SessionLock.queueJobForNumber(this.remoteAddress.toString(), function() {
|
||||
return this.storage.isTrustedIdentity(
|
||||
this.remoteAddress.getName(), device.identityKey
|
||||
this.remoteAddress.getName(), device.identityKey, this.storage.Direction.SENDING
|
||||
).then(function(trusted) {
|
||||
if (!trusted) {
|
||||
throw new Error('Identity key changed');
|
||||
|
@ -36003,7 +36003,7 @@ SessionBuilder.prototype = {
|
|||
processV3: function(record, message) {
|
||||
var preKeyPair, signedPreKeyPair, session;
|
||||
return this.storage.isTrustedIdentity(
|
||||
this.remoteAddress.getName(), message.identityKey.toArrayBuffer()
|
||||
this.remoteAddress.getName(), message.identityKey.toArrayBuffer(), this.storage.Direction.RECEIVING
|
||||
).then(function(trusted) {
|
||||
if (!trusted) {
|
||||
var e = new Error('Unknown identity key');
|
||||
|
@ -36247,12 +36247,22 @@ SessionCipher.prototype = {
|
|||
result.set(new Uint8Array(encodedMsg), 1);
|
||||
result.set(new Uint8Array(mac, 0, 8), encodedMsg.byteLength + 1);
|
||||
|
||||
return this.storage.isTrustedIdentity(
|
||||
this.remoteAddress.getName(), util.toArrayBuffer(session.indexInfo.remoteIdentityKey), this.storage.Direction.SENDING
|
||||
).then(function(trusted) {
|
||||
if (!trusted) {
|
||||
throw new Error('Identity key changed');
|
||||
}
|
||||
}).then(function() {
|
||||
return this.storage.saveIdentity(this.remoteAddress.getName(), session.indexInfo.remoteIdentityKey);
|
||||
}.bind(this)).then(function() {
|
||||
record.updateSessionState(session);
|
||||
return this.storage.storeSession(address, record.serialize()).then(function() {
|
||||
return result;
|
||||
});
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}.bind(this)).then(function(message) {
|
||||
if (session.pendingPreKey !== undefined) {
|
||||
var preKeyMsg = new Internal.protobuf.PreKeyWhisperMessage();
|
||||
|
@ -36318,6 +36328,16 @@ SessionCipher.prototype = {
|
|||
record.archiveCurrentState();
|
||||
record.promoteState(result.session);
|
||||
}
|
||||
|
||||
return this.storage.isTrustedIdentity(
|
||||
this.remoteAddress.getName(), util.toArrayBuffer(result.session.indexInfo.remoteIdentityKey), this.storage.Direction.SENDING
|
||||
).then(function(trusted) {
|
||||
if (!trusted) {
|
||||
throw new Error('Identity key changed');
|
||||
}
|
||||
}).then(function() {
|
||||
return this.storage.saveIdentity(this.remoteAddress.getName(), result.session.indexInfo.remoteIdentityKey);
|
||||
}.bind(this)).then(function() {
|
||||
record.updateSessionState(result.session);
|
||||
return this.storage.storeSession(address, record.serialize()).then(function() {
|
||||
return result.plaintext;
|
||||
|
@ -36326,6 +36346,7 @@ SessionCipher.prototype = {
|
|||
}.bind(this));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
},
|
||||
decryptPreKeyWhisperMessage: function(buffer, encoding) {
|
||||
buffer = dcodeIO.ByteBuffer.wrap(buffer, encoding);
|
||||
|
@ -36346,6 +36367,7 @@ SessionCipher.prototype = {
|
|||
);
|
||||
}
|
||||
var builder = new SessionBuilder(this.storage, this.remoteAddress);
|
||||
// isTrustedIdentity is called within processV3, no need to call it here
|
||||
return builder.processV3(record, preKeyProto).then(function(preKeyId) {
|
||||
var session = record.getSessionByBaseKey(preKeyProto.baseKey);
|
||||
return this.doDecryptWhisperMessage(
|
||||
|
@ -38101,7 +38123,7 @@ var TextSecureServer = (function() {
|
|||
// update our own identity key, which may have changed
|
||||
// if we're relinking after a reinstall on the master device
|
||||
var putIdentity = textsecure.storage.protocol.saveIdentity.bind(
|
||||
null, number, identityKeyPair.pubKey
|
||||
null, number, identityKeyPair.pubKey, true, true
|
||||
);
|
||||
textsecure.storage.protocol.removeIdentityKey(number).then(putIdentity, putIdentity);
|
||||
|
||||
|
|
|
@ -35813,7 +35813,7 @@ SessionBuilder.prototype = {
|
|||
processPreKey: function(device) {
|
||||
return Internal.SessionLock.queueJobForNumber(this.remoteAddress.toString(), function() {
|
||||
return this.storage.isTrustedIdentity(
|
||||
this.remoteAddress.getName(), device.identityKey
|
||||
this.remoteAddress.getName(), device.identityKey, this.storage.Direction.SENDING
|
||||
).then(function(trusted) {
|
||||
if (!trusted) {
|
||||
throw new Error('Identity key changed');
|
||||
|
@ -35866,7 +35866,7 @@ SessionBuilder.prototype = {
|
|||
processV3: function(record, message) {
|
||||
var preKeyPair, signedPreKeyPair, session;
|
||||
return this.storage.isTrustedIdentity(
|
||||
this.remoteAddress.getName(), message.identityKey.toArrayBuffer()
|
||||
this.remoteAddress.getName(), message.identityKey.toArrayBuffer(), this.storage.Direction.RECEIVING
|
||||
).then(function(trusted) {
|
||||
if (!trusted) {
|
||||
var e = new Error('Unknown identity key');
|
||||
|
@ -36110,12 +36110,22 @@ SessionCipher.prototype = {
|
|||
result.set(new Uint8Array(encodedMsg), 1);
|
||||
result.set(new Uint8Array(mac, 0, 8), encodedMsg.byteLength + 1);
|
||||
|
||||
return this.storage.isTrustedIdentity(
|
||||
this.remoteAddress.getName(), util.toArrayBuffer(session.indexInfo.remoteIdentityKey), this.storage.Direction.SENDING
|
||||
).then(function(trusted) {
|
||||
if (!trusted) {
|
||||
throw new Error('Identity key changed');
|
||||
}
|
||||
}).then(function() {
|
||||
return this.storage.saveIdentity(this.remoteAddress.getName(), session.indexInfo.remoteIdentityKey);
|
||||
}.bind(this)).then(function() {
|
||||
record.updateSessionState(session);
|
||||
return this.storage.storeSession(address, record.serialize()).then(function() {
|
||||
return result;
|
||||
});
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}.bind(this)).then(function(message) {
|
||||
if (session.pendingPreKey !== undefined) {
|
||||
var preKeyMsg = new Internal.protobuf.PreKeyWhisperMessage();
|
||||
|
@ -36181,6 +36191,16 @@ SessionCipher.prototype = {
|
|||
record.archiveCurrentState();
|
||||
record.promoteState(result.session);
|
||||
}
|
||||
|
||||
return this.storage.isTrustedIdentity(
|
||||
this.remoteAddress.getName(), util.toArrayBuffer(result.session.indexInfo.remoteIdentityKey), this.storage.Direction.SENDING
|
||||
).then(function(trusted) {
|
||||
if (!trusted) {
|
||||
throw new Error('Identity key changed');
|
||||
}
|
||||
}).then(function() {
|
||||
return this.storage.saveIdentity(this.remoteAddress.getName(), result.session.indexInfo.remoteIdentityKey);
|
||||
}.bind(this)).then(function() {
|
||||
record.updateSessionState(result.session);
|
||||
return this.storage.storeSession(address, record.serialize()).then(function() {
|
||||
return result.plaintext;
|
||||
|
@ -36189,6 +36209,7 @@ SessionCipher.prototype = {
|
|||
}.bind(this));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
},
|
||||
decryptPreKeyWhisperMessage: function(buffer, encoding) {
|
||||
buffer = dcodeIO.ByteBuffer.wrap(buffer, encoding);
|
||||
|
@ -36209,6 +36230,7 @@ SessionCipher.prototype = {
|
|||
);
|
||||
}
|
||||
var builder = new SessionBuilder(this.storage, this.remoteAddress);
|
||||
// isTrustedIdentity is called within processV3, no need to call it here
|
||||
return builder.processV3(record, preKeyProto).then(function(preKeyId) {
|
||||
var session = record.getSessionByBaseKey(preKeyProto.baseKey);
|
||||
return this.doDecryptWhisperMessage(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue