Store arrayBuffers in database for remote identity keys

This commit is contained in:
Scott Nonnenberg 2018-10-26 11:37:51 -07:00
parent 68af1ae1ea
commit 70eed938d9
3 changed files with 13 additions and 16 deletions

View file

@ -35837,7 +35837,7 @@ SessionBuilder.prototype = {
record.updateSessionState(session);
return Promise.all([
this.storage.storeSession(address, record.serialize()),
this.storage.saveIdentity(this.remoteAddress.toString(), session.indexInfo.remoteIdentityKey)
this.storage.saveIdentity(this.remoteAddress.toString(), device.identityKey)
]);
}.bind(this));
}.bind(this));
@ -36080,9 +36080,12 @@ SessionCipher.prototype = {
msg.ciphertext = ciphertext;
var encodedMsg = msg.toArrayBuffer();
var ourIdentityKeyBuffer = util.toArrayBuffer(ourIdentityKey.pubKey);
var theirIdentityKey = util.toArrayBuffer(session.indexInfo.remoteIdentityKey);
var macInput = new Uint8Array(encodedMsg.byteLength + 33*2 + 1);
macInput.set(new Uint8Array(util.toArrayBuffer(ourIdentityKey.pubKey)));
macInput.set(new Uint8Array(util.toArrayBuffer(session.indexInfo.remoteIdentityKey)), 33);
macInput.set(new Uint8Array(ourIdentityKeyBuffer));
macInput.set(new Uint8Array(theirIdentityKey), 33);
macInput[33*2] = (3 << 4) | 3;
macInput.set(new Uint8Array(encodedMsg), 33*2 + 1);
@ -36093,13 +36096,13 @@ SessionCipher.prototype = {
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
this.remoteAddress.getName(), theirIdentityKey, this.storage.Direction.SENDING
).then(function(trusted) {
if (!trusted) {
throw new Error('Identity key changed');
}
}).then(function() {
return this.storage.saveIdentity(this.remoteAddress.toString(), session.indexInfo.remoteIdentityKey);
return this.storage.saveIdentity(this.remoteAddress.toString(), theirIdentityKey);
}.bind(this)).then(function() {
record.updateSessionState(session);
return this.storage.storeSession(address, record.serialize()).then(function() {