Page MenuHomePhorge

Reduce calls to decryption when possible
Needs ReviewPublic

Authored by tusooa on Mon, Aug 24, 2:26 PM.

Details

Reviewers
None
Group Reviewers
O1: the Kazv Project
Summary

Originally, we always try to re-decrypt to-device messages. This causes two problems. First, olm events cannot be decrypted twice, so if at the first attempt, the decryption succeeds, but we could not verify the event, it will be lost forever. Second, the number of undecryptable events grows larger and larger, and tryDecryptEvents() will take more time as the session proceeds.

We do two things in this diff: One is to add a failedTimes counter to undecryptable to-device events. Once it fails to decrypt and/or verify too many times, we will no longer try to decrypt them again. The other one is that, before performing the actual decryption, we check the error info we already have in the event, which can contain the decrypted raw event in case it is decrypted but unable to verify. We will use the original decrypted event, bypass actual decryption and go straight to verification. This way we correctly keep olm events that we could not verify in the past when the sender's identity key finally comes.

Type: fix

Test Plan

Check unit tests pass. Check you can still normally send and receive olm- and megolm-encrypted events.

Diff Detail

Repository
rL libkazv
Branch
servant
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 713
Build 1408: Invoke BuildbotBuildbot build #2557
Build 1407: arc lint + arc unit