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; return plaintext;
} catch (error) { } catch (error) {
if ( if (error && error instanceof textsecure.SenderKeyMissing) {
error &&
(error instanceof textsecure.SenderKeyMissing ||
error instanceof DOMException)
) {
const groupId = envelope.source; const groupId = envelope.source;
const { senderIdentity } = error; const { senderIdentity } = error;
if (senderIdentity) { if (senderIdentity) {

@ -204,6 +204,11 @@ async function advanceRatchet(
log.error('[idx] not found key for idx: ', idx); log.error('[idx] not found key for idx: ', idx);
// I probably want a better error handling than this // I probably want a better error handling than this
return null; 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; const { messageKeys } = ratchet;
@ -278,16 +283,12 @@ async function decryptWithSenderKeyInner(
); );
return plaintext; return plaintext;
} catch (e) { } catch (e) {
window.log.error('Got error during DecryptGCM():', e); window.log.error('Got error during DecryptGCM()', e);
if (e instanceof DOMException) { if (e instanceof DOMException) {
const params = { window.log.error(
timestamp: Date.now(), 'Got DOMException during DecryptGCM(). Rethrowing as SenderKeyMissing '
groupId, );
}; throw new window.textsecure.SenderKeyMissing(senderIdentity);
// 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);
} }
} }
} }

Loading…
Cancel
Save