Additional logging in unusual error cases
* Add more logging with 'Over 5000 messages into future' error * When a Bad MAC error happens on decrypt, print out more info * Fix loggin
This commit is contained in:
parent
5e8ee73de5
commit
c930b6c349
1 changed files with 17 additions and 4 deletions
|
@ -36297,14 +36297,27 @@ SessionCipher.prototype = {
|
|||
});
|
||||
}.bind(this)).then(function(keys) {
|
||||
return this.storage.getIdentityKeyPair().then(function(ourIdentityKey) {
|
||||
var remoteIdentityKey = util.toArrayBuffer(session.indexInfo.remoteIdentityKey);
|
||||
var ourPubKey = util.toArrayBuffer(ourIdentityKey.pubKey);
|
||||
|
||||
var macInput = new Uint8Array(messageProto.byteLength + 33*2 + 1);
|
||||
macInput.set(new Uint8Array(util.toArrayBuffer(session.indexInfo.remoteIdentityKey)));
|
||||
macInput.set(new Uint8Array(util.toArrayBuffer(ourIdentityKey.pubKey)), 33);
|
||||
macInput.set(new Uint8Array(remoteIdentityKey));
|
||||
macInput.set(new Uint8Array(ourPubKey), 33);
|
||||
macInput[33*2] = (3 << 4) | 3;
|
||||
macInput.set(new Uint8Array(messageProto), 33*2 + 1);
|
||||
|
||||
return Internal.verifyMAC(macInput.buffer, keys[1], mac, 8);
|
||||
return Internal.verifyMAC(macInput.buffer, keys[1], mac, 8).catch(function(error) {
|
||||
function logArrayBuffer(name, arrayBuffer) {
|
||||
console.log('Bad MAC: ' + name + ' - truthy: ' + Boolean(arrayBuffer) +', length: ' + (arrayBuffer ? arrayBuffer.byteLength : 'NaN'));
|
||||
}
|
||||
|
||||
logArrayBuffer('ourPubKey', ourPubKey);
|
||||
logArrayBuffer('remoteIdentityKey', remoteIdentityKey);
|
||||
logArrayBuffer('messageProto', messageProto);
|
||||
logArrayBuffer('mac', mac);
|
||||
|
||||
throw error;
|
||||
});
|
||||
}.bind(this)).then(function() {
|
||||
return Internal.crypto.decrypt(keys[0], message.ciphertext.toArrayBuffer(), keys[2].slice(0, 16));
|
||||
});
|
||||
|
@ -36319,7 +36332,7 @@ SessionCipher.prototype = {
|
|||
}
|
||||
|
||||
if (counter - chain.chainKey.counter > 5000) {
|
||||
throw new Error('Over 5000 messages into the future!');
|
||||
throw new Error('Over 5000 messages into the future! New: ' + counter + ', Existing: ' + chain.chainKey.counter);
|
||||
}
|
||||
|
||||
if (chain.chainKey.key === undefined) {
|
||||
|
|
Loading…
Add table
Reference in a new issue