powered by Jive Software

Smack-omemo rework #177 - OmemoService.getUndecidedDevices() includes its ownDevice in the list for TrustState checking during muc omemo messaging encryption

During muc OmemoMessage.Sent encrypt process, OmemoServie included its ownDevice in the devices list for TrustState checking. It also incorrectly uses loadOmemoIdentityKey(userDevice, contactsDevice) to fetch identityKeyPairs, leading to CorruptedOmemoKeyException being thrown and always get included in the undecidedDevices and return to upstream app.

With reference to OmemoMessage.Sent#encrypt method:
On further investigation, I found that the loadCachedDeviceList() is being called twice for ownDevice. This leads to two copies of ownDevice get included in contactsDevices.
removeOurDevice(userDevice, contactsDevices) removes only one of the two, hence gives rise to the observed problem.

I did a simple path as below to allow aTalk continue testing

     * Remove our device from the collection of devices.
     * @param userDevice our OmemoDevice
     * @param devices collection of OmemoDevices
    static void removeOurDevice(OmemoDevice userDevice, Collection<OmemoDevice> devices) {
        while (devices.contains(userDevice)) {

Thanks for the hint. I think this can be fixed by using Set<OmemoDevice> instead of List<OmemoDevice> to handle recipients devices. In that case devices.remove(userDevice); will make sure that the device is no longer in the set.

Edit: I made some changes to the code in this commit. Can you test if it now works for you?

Yes, the new commit code works on aTalk. Thanks.

Can you mark this as resolved then?