During the testing the fix for identitykey index=0, I have observed the following on (Note-3 with omemoDevice user2@myserver.ltd:148608352)
Below is a description of the observation, I am not sure if the problem arise is due to aTalk DB design; or there is additional process aTalk needs to perform when below scenario happen.
While attempt to send an omemo message to contacts, omemoService will make call to the method below to get the fingerPrint->loadOmemoIdentityKey for each contact in the recipient list:
OmemoStore.getFingerprint(OmemoStore.java:609) →
loadOmemoIdentityKey(userDevice, contactsDevice)
(no sure why the contact identity table row has both the publickey and fingerPrint contain null)
a. Upon receive a null identityKey in reply from a specific contact, omemoStore throws an NoIdentityKeyException;
b. omemoService then add this contact into the undecidedDevices list and
c. return the undecidedDevices to the send message caller.
I see that omemoServie also proceed to fetch the prekeys bundle from the server for the contact with null identityKey. However this newly fetched contact publicKey info is not being updated to the database.
The user is unable to send the message; as above cycle repeats itself whenever user is trying to send another new omemo message.
Need your clarification on the followings:
- After fetching the new identityKey bundle, should omemoServer makes a call to
OmemoStore.storeOmemoIdentityKey(OmemoDevice userDevice, OmemoDevice contactDevice, IdentityKey contactKey) - Otherwise, is that something aTalk needs to do to get omemStore or aTalk to save the new contact prekey info into the database.
08-26 08:09:36.805 1870-1870/org.atalk.android W/aTalk: [1] org.jivesoftware.smackx.omemo.OmemoService.getUndecidedDevices() Could not load fingerprint of user1@myserver.ltd:1367773246
org.jivesoftware.smackx.omemo.exceptions.NoIdentityKeyException
at org.jivesoftware.smackx.omemo.OmemoStore.getFingerprint(OmemoStore.java:609)
at org.jivesoftware.smackx.omemo.OmemoService.getUndecidedDevices(OmemoService.java:846)
at org.jivesoftware.smackx.omemo.OmemoService.encrypt(OmemoService.java:361)
at org.jivesoftware.smackx.omemo.OmemoService.createOmemoMessage(OmemoService.java:537)
at org.jivesoftware.smackx.omemo.OmemoManager.encrypt(OmemoManager.java:342)
at org.jivesoftware.smackx.omemo.OmemoManager.encrypt(OmemoManager.java:315)
at net.java.sip.communicator.impl.protocol.jabber.OperationSetBasicInstantMessagingJabberImpl.sendInstantMessage(OperationSetBasicInstantMessagingJabberImpl.java:506)
at org.atalk.android.gui.chat.MetaContactChatTransport.sendInstantMessage(MetaContactChatTransport.java:413)
at org.atalk.android.gui.chat.ChatController.sendMessage(ChatController.java:294)
at org.atalk.android.gui.chat.ChatController.onClick(ChatController.java:419)
08-26 08:09:36.945 1870-2103/org.atalk.android D/SMACK: SENT (0):
<iq to='user1@myserver.ltd' id='5PUFZ-119' type='get'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<items node='eu.siacs.conversations.axolotl.bundles:1367773246'/>
</pubsub>
</iq>
08-26 08:09:37.425 1870-2104/org.atalk.android D/SMACK: RECV (0):
<iq xml:lang='en' to='user2@myserver.ltd/atalk' from='user1@myserver.ltd' type='result' id='5PUFZ-119'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<items node='eu.siacs.conversations.axolotl.bundles:1367773246'>
<item id='61EBCDC16D901'>
<bundle xmlns='eu.siacs.conversations.axolotl'>
<signedPreKeyPublic signedPreKeyId='1'>
BcmSAz/M3BSBlz5crR4WYrHId1azx4GBxhiGbCM7OAg9
</signedPreKeyPublic>
<signedPreKeySignature>
m890vfBB2be9ygtHPdmPOqi7de4zX4WOcHJaiSp7SPjxs78SZOs7XrK0qIyqwVmTxJe6qvK9l9927auWmQd4AQ==
</signedPreKeySignature>
<identityKey>
Bb7i7uw0ZJwf7KHMcLt70R8TIvIoU/b+oTI+khZKh1hR
</identityKey>
=========================
Further testing show that if the problem on Note-3 is not resolved, send a message from my Note-8 (user1@myserver.ltd:1367773246) is also not working. Although the message is sent successfully by Note-8, but Note-3 cannot repair the broken session, and hence no display of the received omemo message.
- Any proposal for the fix of all these observed problem?
Note: your proposed fix for index=0 is verified working.
<message xml:lang='en' to='user2@myserver.ltd/atalk' from='user1@myserver.ltd/atalk' type='chat' id='1566786562185188302834'>
<archived by='user2@myserver.ltd' id='1566786563118350' xmlns='urn:xmpp:mam:tmp'/>
<stanza-id by='user2@myserver.ltd' id='1566786563118350' xmlns='urn:xmpp:sid:0'/>
<encrypted xmlns='eu.siacs.conversations.axolotl'>
<header sid='1367773246'>
<key prekey='true' rid='1481970607'>
MwgyEiEF0KVrvBOEY8yw3Sv+FIRn9asw+yNufAbjL1NqdOS8i2EaIQW+4u7sNGScH+yhzHC7e9EfEyLyKFP2/qEyPpIWSodYUSJiMwohBRh37lvGXmGrno8QiwaeWpGSlkEnWtgtGF4JVw52xfxeEAEYACIwiaaqPsEGizcBVUhqL5B+woRP8hlzk1ENsEGsGE79QFEI8MxNO1WU8UK0AxErAXLJpylMyDwjzqMoADAB
</key>
<key prekey='true' rid='944885071'>
MwgiEiEFRWf7vpABbGsE2hZd3/NqZTJ5SxFiUVNKOkujY2HtIjUaIQXtZA8Hhk9pABEUK+8UsUT/3wXNKAT7qsXHqt64u/ofQCJiMwohBfZkzhjVqy8GqjBOMw19bZTCiNKPL28NkgmPlSl9b9V3EAgYACIwjaDCl5QBwW1vnfCjBeB51MyU7w3tuzNFyWmwKeKPfgW44n0m0jmX8wiVx52yjlfZk9tRGt34fSooADAB
</key>
<key prekey='true' rid='1361'>
MwhfEiEFKfnfAs92mpQHHlocyoYWkF912ecTo9W6Xnf8psQx5wUaIQW+4u7sNGScH+yhzHC7e9EfEyLyKFP2/qEyPpIWSodYUSJiMwohBeAXAakfcGY9d6HTdBS5VldTdZy9Gzr4ka1Frargs8tpEAEYACIwYUuxj17Ued/S1fYpTTfd85KSGB5B3ug6Ht2gauyeqgaJsk79CWYHLo10rprzUcSk0jZ9g2Ad3HwoADAA
</key>
<key rid='148608352'>
MwohBSSY7Diw0Ep2x6VEbuJthbhG0H+iza
08-26 10:29:24.736 9133-14056/org.atalk.android D/SMACK: RECV (1): omk0xUGbUkzQdNEAMYACIweJGyQaPxTs0sDJ7CG2kB29jg5Wzas/Rono9u9QcOvJtlyv9xTvTADhy9fg8n8C1t47QiaZqGtxM=
</key>
<key prekey='true' rid='1389276080'>
Mwg7EiEF3bnGwa6e160S4rv3k8ro8DOXP2+s30/GxpELQulF6E4aIQXtZA8Hhk9pABEUK+8UsUT/3wXNKAT7qsXHqt64u/ofQCJiMwohBYOr7MXV4tN5fuf6TubfbWKkMb38fL0H6CLC+KE+fCpkEAgYACIwPL29/OmGqOCI2PWROcLvm49Bu35/ZzskzTi1+b+xDJE/+MZgvNALYRT56A1Qels5LtN8Imb1hbIoADAB
</key>
<iv>
KB1Stdi9fe6YhngRCb0rqg==
</iv>
</header>
<payload>
/qQ7
</payload>
</encrypted>
<store xmlns='urn:xmpp:hints'/>
<encryption xmlns='urn:xmpp:eme:0' namespace='eu.siacs.conversations.axolotl' name='OMEMO'/>
<request xmlns='urn:xmpp:receipts'/>
<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>
</message>
08-26 10:29:24.746 9133-14055/org.atalk.android D/SMACK: SENT (1):
<message to='user1@myserver.ltd/atalk' id='HCH53-341' type='chat'>
<received xmlns='urn:xmpp:receipts' id='1566786562185188302834'/>
</message>
<r xmlns='urn:xmpp:sm:3'/>
08-26 10:29:24.746 9133-14056/org.atalk.android D/SMACK: RECV (1):
<r xmlns='urn:xmpp:sm:3'/>
08-26 10:29:24.746 9133-14055/org.atalk.android D/SMACK: SENT (1):
<a xmlns='urn:xmpp:sm:3' h='88'/>
08-26 10:29:24.756 9133-19383/org.atalk.android W/aTalk: [6] org.jivesoftware.smackx.omemo.OmemoService.onOmemoMessageStanzaReceived() No raw session found for contact user1@myserver.ltd:1367773246.
org.jivesoftware.smackx.omemo.exceptions.NoRawSessionException: org.whispersystems.libsignal.NoSessionException: No session for: user1@myserver.ltd:1367773246
at org.jivesoftware.smackx.omemo.signal.SignalOmemoRatchet.doubleRatchetDecrypt(SignalOmemoRatchet.java:127)
at org.jivesoftware.smackx.omemo.OmemoRatchet.retrieveMessageKeyAndAuthTag(OmemoRatchet.java:103)
at org.jivesoftware.smackx.omemo.OmemoService.decryptMessage(OmemoService.java:456)
at org.jivesoftware.smackx.omemo.OmemoService.onOmemoMessageStanzaReceived(OmemoService.java:1159)
at org.jivesoftware.smackx.omemo.OmemoManager$3$1.run(OmemoManager.java:957)
at java.lang.Thread.run(Thread.java:818)
Caused by: org.whispersystems.libsignal.NoSessionException: No session for: user1@myserver.ltd:1367773246
at org.whispersystems.libsignal.SessionCipher.decrypt(SessionCipher.java:239)
at org.whispersystems.libsignal.SessionCipher.decrypt(SessionCipher.java:211)
at org.jivesoftware.smackx.omemo.signal.SignalOmemoRatchet.doubleRatchetDecrypt(SignalOmemoRatchet.java:121)
at org.jivesoftware.smackx.omemo.OmemoRatchet.retrieveMessageKeyAndAuthTag(OmemoRatchet.java:103)
at org.jivesoftware.smackx.omemo.OmemoService.decryptMessage(OmemoService.java:456)
at org.jivesoftware.smackx.omemo.OmemoService.onOmemoMessageStanzaReceived(OmemoService.java:1159)
at org.jivesoftware.smackx.omemo.OmemoManager$3$1.run(OmemoManager.java:957)
at java.lang.Thread.run(Thread.java:818)
08-26 10:29:24.756 9133-19383/org.atalk.android W/aTalk: [6] org.jivesoftware.smackx.omemo.OmemoService.repairBrokenSessionWithPreKeyMessage() Attempt to repair the session by sending a fresh preKey message to user1@myserver.ltd:1367773246
08-26 10:29:24.766 9133-14055/org.atalk.android D/SMACK: SENT (1):
<iq to='user1@myserver.ltd' id='HCH53-342' type='get'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<items node='eu.siacs.conversations.axolotl.bundles:1367773246'/>
</pubsub>
</iq>
08-26 10:29:25.136 9133-14056/org.atalk.android D/SMACK: RECV (1):
<a h='57' xmlns='urn:xmpp:sm:3'/>
08-26 10:29:25.666 9133-14056/org.atalk.android D/SMACK: RECV (1):
<iq xml:lang='en' to='user2@myserver.ltd/atalk' from='user1@myserver.ltd' type='result' id='HCH53-342'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<items node='eu.siacs.conversations.axolotl.bundles:1367773246'>
<item id='61EBFE649DC37'>
<bundle xmlns='eu.siacs.conversations.axolotl'>
<signedPreKeyPublic signedPreKeyId='1'>
BcmSAz/M3BSBlz5crR4WYrHId1azx4GBxhiGbCM7OAg9
</signedPreKeyPublic>
<signedPreKeySignature>
m890vfBB2be9ygtHPdmPOqi7de4zX4WOcHJaiSp7SPjxs78SZOs7XrK0qIyqwVmTxJe6qvK9l9927auWmQd4AQ==
</signedPreKeySignature>
<identityKey>
Bb7i7uw0ZJwf7KHMcLt70R8TIvIoU/b+oTI+khZKh1hR
</identityKey>
<prekeys>
<preKeyPublic preKeyId='1'>
BaM6jPM2U6f5ciIT+YoixsxYSC1Z7qdoq82k47QxCSlL
</preKeyPublic>
<preKeyPublic preKeyId='2'>
Bd9rLgwqeYbvSxr45+sZbU4TNIXyrqN2hT35ukMl6HFo
</preKeyPublic>
<preKeyPublic preKeyId='3'>
Bf15eqgMWDG4l/6l1Rv/WWfdZBTyMnlArpVcSlo70NUO
</preKeyPublic>
08-26 10:29:25.736 9133-19383/org.atalk.android W/aTalk: [6] org.jivesoftware.smackx.omemo.OmemoService.repairBrokenSessionWithPreKeyMessage() Unable to repair session with user1@myserver.ltd:1367773246
org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException: org.whispersystems.libsignal.InvalidKeyException: Invalid signature on device key!
at org.jivesoftware.smackx.omemo.signal.SignalOmemoService.processBundle(SignalOmemoService.java:107)
at org.jivesoftware.smackx.omemo.signal.SignalOmemoService.processBundle(SignalOmemoService.java:48)
at org.jivesoftware.smackx.omemo.OmemoService.buildFreshSessionWithDevice(OmemoService.java:786)
at org.jivesoftware.smackx.omemo.OmemoService.repairBrokenSessionWithPreKeyMessage(OmemoService.java:1294)
at org.jivesoftware.smackx.omemo.OmemoService.onOmemoMessageStanzaReceived(OmemoService.java:1180)
at org.jivesoftware.smackx.omemo.OmemoManager$3$1.run(OmemoManager.java:957)
at java.lang.Thread.run(Thread.java:818)
Caused by: org.whispersystems.libsignal.InvalidKeyException: Invalid signature on device key!
at org.whispersystems.libsignal.SessionBuilder.process(SessionBuilder.java:176)
at org.jivesoftware.smackx.omemo.signal.SignalOmemoService.processBundle(SignalOmemoService.java:104)
at org.jivesoftware.smackx.omemo.signal.SignalOmemoService.processBundle(SignalOmemoService.java:48)
at org.jivesoftware.smackx.omemo.OmemoService.buildFreshSessionWithDevice(OmemoService.java:786)
at org.jivesoftware.smackx.omemo.OmemoService.repairBrokenSessionWithPreKeyMessage(OmemoService.java:1294)
at org.jivesoftware.smackx.omemo.OmemoService.onOmemoMessageStanzaReceived(OmemoService.java:1180)
at org.jivesoftware.smackx.omemo.OmemoManager$3$1.run(OmemoManager.java:957)
at java.lang.Thread.run(Thread.java:818)
=====================