2 Replies Latest reply on Jul 23, 2017 11:47 PM by cmeng

    Smack 4.2.1-beta2-SNAPSHOT OmemoService#subscribeToDeviceLists starts up too late to process PEP_NODE_DEVICE_LIST_NOTIFY

    cmeng

      Found that OmemoManager#PEPListener deviceListUpdateListener() did not manage to process the following pubsub#event sent from server due to late in PEP_NODE_DEVICE_LIST_NOTIFY listener registration.

       

      aTalk has implemented the reflection method, and it is being called immediately upon xmpp connection to resolve the problem for smack 4.2.1-beta2-SNAPSHOT.

       

      private void subscribeToDeviceLists(OmemoManager omemoManager)
      {
         OmemoService omemoService = OmemoService.getInstance();
         try {
         Method addPEPListener = OmemoService.class.getDeclaredMethod
         ("subscribeToDeviceLists", OmemoManager.class);
         addPEPListener.setAccessible(true);
         addPEPListener.invoke(omemoService, omemoManager);
         }
         catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
         e.printStackTrace();
         }
      }

       

       

      ======

      07-23 23:02:12.599 D/SMACK: RECV (0): <message to='leopard@atalk.org/atalk' from='leopard@atalk.org' type='headline'><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='eu.siacs.conversations.axolotl.devicelist'><item id='5DCA63DDF13FB'><list xmlns='eu.siacs.conversations.axolotl'><device id='1011347036'/></list></item></items></event><delay from='leopard@atalk.org/atalk' stamp='2017-07-21T23:48:45.992891Z' xmlns='urn:xmpp:delay'/></message>

        • Re: Smack 4.2.1-beta2-SNAPSHOT OmemoService#subscribeToDeviceLists starts up too late to process PEP_NODE_DEVICE_LIST_NOTIFY
          cmeng

          Continue testing with the OmemoManager#deviceListUpdateListener() after the reflection private method implementation. In smack omemo deviceListUpdateListener() handling upon receipt of an deviceList stanza, it will perform

          ### mergeCachedDeviceList(OmemoManager.this, from, omemoDeviceListElement);

          in which it will update the "activeDevices" and "inactiveDevices" list with the received omemoDevice ID's;  in the persistent storage. The update does not checked for any new deviceID nor make new entry in the entities table if any. Under the smack omemo default file based backend storage, this works fine as the actual entities information can be added at a later stage (not sure when and how smack omemo update the entities info - guess it is during olmMessage sending?).

           

          aTalk however implements omemo persistent storage using SQLite database, update the device active state without any entry in the entities will fail. If needs to, aTalk can perform check in the below override method and create new/missing entry in the entities table while updating its active state.

          storeCachedDeviceList(OmemoManager omemoManager, BareJid contact, CachedDeviceList deviceList)

           

          Would smack omemo considers enhance the deviceListUpdateListener() method to take care the above scenario i.e. create new identities entry if missing before calling active state update.

          Any other better recommendations?

           

          ========== aTalk log ======================

          07-24 08:22:40.555 D/SMACK: RECV (0): <iq xml:lang='en' to='swan@atalk.org/atalk' from='swan@atalk.org' type='result' id='My7Ue-115'><pubsub xmlns='http://jabber.org/protocol/pubsub'><set xmlns='http://jabber.org/protocol/rsm'><index>1</index><count>1</count><first index='1'>creation@001500:736494:893196</first><last>creation@001500:736494:893 196</last></set><items node='eu.siacs.conversations.axolotl.devicelist'><item id='5DCB3CEED989C'><list xmlns='eu.siacs.conversations.axolotl'><device id='816614937'/><device id='1711246335'/></list></item></items></pubsub></iq>

          07-24 08:22:40.555 W/αTalk: [11] org.atalk.persistance.DatabaseBackend.storeCachedDeviceList().1314 Identities table contains no device: swan@atalk.org:816614937

            • Re: Smack 4.2.1-beta2-SNAPSHOT OmemoService#subscribeToDeviceLists starts up too late to process PEP_NODE_DEVICE_LIST_NOTIFY
              cmeng

              I created a new entry in the identities table for the new deviceId leaving keyPair value empty during the storeCachedDeviceList() if no exist, but found that smack omemoService does not in any point in the whole operation attempts to update the missing keyPair for the newly created identities entry. Neither OmemoService attempts to load the newly created keyPair.

               

              /--------------------------------------/

              Further testing shows that the olmMessage sent from aTalk (swan@atalk.org) contains only <key rid>#2 but excluded #3 (alternate device); whereas olmMessage sent from conversations contains both #2 and #1 (alternate device).

               

              1. swan@atalk.org:1711246335 (S3-aTalk)  <key rid='1711246335'>

              2.  leopard@atalk.org:1011347036 (Note3-aTalk) <key rid='1011347036'>

              3. swan@atalk.org:816614937 (S3-conversations)

               

              =============== olmMessage sent from S3-aTalk to Note3-aTalk (leopard) ==================

              07-24 14:17:12.277 D/SMACK: RECV (0): <message xml:lang='en' to='leopard@atalk.org/atalk' from='swan@atalk.org/atalk' type='chat' id='7Fmk5-136'><encrypted xmlns='eu.siacs.conversations.axolotl'><header sid='1711246335'><key rid='1011347036'>MwohBbNw++gXyOYvrwCqhlrN3SQu4GrGdcCUxr+OzNuOTxB1EAEYAyIw+tVlSC1SZokiODuMTAtBgkQF VujvkWcqbI9kCu5YVdxiZMInL3nN3YdswaX89uMNy5iMvTx5V3k=</key><iv>xwXPRDyyDz5oqJJ2Xr sJmw==</iv></header><payload>niYQqw==</payload></encrypted><store xmlns='urn:xmpp:hints'/><encryption xmlns='urn:xmpp:eme:0' namespace='eu.siacs.conversations.axolotl' name='OMEMO'/><body>I sent you an OMEMO encrypted message but your client doesn’t seem to support that. Find more information on https://conversations.im/omemo</body><thread>56de2403-0b80-4c24-ac16-95fe7a85018b</thread></message>

               

              =============== olmMessage sent from S3-conversations to Note3-aTalk (leopard) ==================

              07-24 14:17:54.777 D/SMACK: RECV (0): <message xml:lang='en' to='leopard@atalk.org/atalk' from='swan@atalk.org/phone' type='chat' id='dfb8adf7-d4db-4dbe-96af-42415686de59'><encrypted xmlns='eu.siacs.conversations.axolotl'><header sid='816614937'><key rid='1711246335' prekey='true'>MwgMEiEFhZCIcePfLlJRNYy+o9vEdckqN/XfWpq51eP5UQHz4GQaIQUUV5ApOiQnNcECsTvKWCH8wDMr Qe4XtFTcxf88Tg61YSJjMwohBRkTFwRc88k+9cDwCt6Igt/5+SwLSgzV/7wuuabv5Ig3EK8BGAAiMIUW w1JbOAx0rj0oIne/Ttv3fp7JG07oPJthIAoiTZUB4/EPFi/i7g9G0d1YWHlSO6KIYRkgva3gKJmcsoUD MAE=</key><key rid='1011347036'>MwohBWhK4U6+HxL2ZrzP+Yt4qddq73NyDfFMtDA+BGb7B55SEAAYASIwNIlGQOxpYu0ghoAzWHFUN77R JMyRKknkcySeKuy7blsetEMhTz+CMvjvZ9dShXK8mLejbIOdqTI=</key><iv>PeK0se/ZpC0RpVzCB9 H3qQ==</iv></header><payload>OJw9</payload></encrypted><markable xmlns='urn:xmpp:chat-markers:0'/><origin-id xmlns='urn:xmpp:sid:0' id='dfb8adf7-d4db-4dbe-96af-42415686de59'/><store xmlns='urn:xmpp:hints'/><encryption xmlns='urn:xmpp:eme:0' namespace='eu.siacs.conversations.axolotl' name='OMEMO'/></message>