make message clearer when we try to reuse a keyIdx in the ratchet

pull/1370/head
Audric Ackermann 5 years ago
parent 97eaf68085
commit 2f8f79c5d2
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -287,11 +287,7 @@ async function decrypt(
return plaintext;
} catch (error) {
if (
error &&
(error instanceof textsecure.SenderKeyMissing ||
error instanceof DOMException)
) {
if (error && error instanceof textsecure.SenderKeyMissing) {
const groupId = envelope.source;
const { senderIdentity } = error;
if (senderIdentity) {

@ -204,6 +204,11 @@ async function advanceRatchet(
log.error('[idx] not found key for idx: ', idx);
// I probably want a better error handling than this
return null;
} else if (idx === ratchet.keyIdx) {
log.error(
`advanceRatchet() called with idx:${idx}, current ratchetIdx:${ratchet.keyIdx}. We already burnt that keyIdx before.`
);
return null;
}
const { messageKeys } = ratchet;
@ -278,16 +283,12 @@ async function decryptWithSenderKeyInner(
);
return plaintext;
} catch (e) {
window.log.error('Got error during DecryptGCM():', e);
window.log.error('Got error during DecryptGCM()', e);
if (e instanceof DOMException) {
const params = {
timestamp: Date.now(),
groupId,
};
// we consider we don't have the correct key for this sender, so request the latest one
const requestKeysMessage = new MediumGroupRequestKeysMessage(params);
const sender = new PubKey(senderIdentity);
await getMessageQueue().send(sender, requestKeysMessage);
window.log.error(
'Got DOMException during DecryptGCM(). Rethrowing as SenderKeyMissing '
);
throw new window.textsecure.SenderKeyMissing(senderIdentity);
}
}
}

Loading…
Cancel
Save