When a new OMEMO chat session is first setup between two new devices A and B;
if device A sends an OMEMO message to device B, OmemoService on device B will throw NoRawSessionException, as there is no prior raw session being setup between the two devices.
From source, it seems that OmemoService just logged the error message, ignore/discard the newly received OMEMO message, but proceed to repairBrokenSessionWithPreKeyMessage(). However device B is unaware of the problem, and there is no display of the new received OMEMO message.
Prior to sending any OMEMO message, presumably neither Device A or Device B know each other OMEMEO device ID. I am unable to figure a way to build the raw session under this condition.
Does OmemoManager provides a method call to build the raw sessions for new devices before the messages are being sent/received; and what are the steps to do so.
Any alternatives to ensure all OMEMO Devices are able to display the very first OMEMO received.
03-25 08:02:32.004 19291-2870/org.atalk.android D/SMACK: RECV (1):
<message xml:lang='en-GB' to='leopard@atalk.sytes.net/atalk' from='chatroom-mfxm@conference.atalk.sytes.net/swordfish' type='groupchat' id='U3VAE-189'>
<archived by='chatroom-mfxm@conference.atalk.sytes.net' id='1585094551076335' xmlns='urn:xmpp:mam:tmp'/>
<stanza-id by='chatroom-mfxm@conference.atalk.sytes.net' id='1585094551076335' xmlns='urn:xmpp:sid:0'/>
<encrypted xmlns='eu.siacs.conversations.axolotl'>
<header sid='595475613'>
<key rid='2022975859'>
MwohBULW3HTjJIe4n3qtqZRo7nhqWWmZHI+H35n0Tq0LYqguEAEYASIw05iHCUeHN9coZNCAesweSsekJy1Yr5Fdofx2O4iUJ5Cqnz0CLnWhSqF+SIs8je90Y9IMAP/BPQo=
</key>
<iv>
R30a/2e15C/fhg8+Ln+Eqw==
</iv>
</header>
<payload>
tKejCw==
</payload>
</encrypted>
<store xmlns='urn:xmpp:hints'/>
<encryption xmlns='urn:xmpp:eme:0' namespace='eu.siacs.conversations.axolotl' name='OMEMO'/>
<active xmlns='http://jabber.org/protocol/chatstates'/>
<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>
03-25 08:02:32.394 19291-3033/org.atalk.android W/aTalk: [8] org.jivesoftware.smackx.omemo.OmemoService.onOmemoMessageStanzaReceived() No raw session found for contact swordfish@atalk.sytes.net:595475613.
org.jivesoftware.smackx.omemo.exceptions.NoRawSessionException: org.whispersystems.libsignal.InvalidMessageException: No valid sessions.
at org.jivesoftware.smackx.omemo.signal.SignalOmemoRatchet.doubleRatchetDecrypt(SignalOmemoRatchet.java:128)
at org.jivesoftware.smackx.omemo.OmemoRatchet.retrieveMessageKeyAndAuthTag(OmemoRatchet.java:106)
at org.jivesoftware.smackx.omemo.OmemoService.decryptMessage(OmemoService.java:456)
at org.jivesoftware.smackx.omemo.OmemoService.onOmemoMessageStanzaReceived(OmemoService.java:1166)
at org.jivesoftware.smackx.omemo.OmemoManager$3$1.run(OmemoManager.java:945)
at java.lang.Thread.run(Thread.java:818)
Caused by: org.whispersystems.libsignal.InvalidMessageException: No valid sessions.
at org.whispersystems.libsignal.SessionCipher.decrypt(SessionCipher.java:290)
at org.whispersystems.libsignal.SessionCipher.decrypt(SessionCipher.java:243)
at org.whispersystems.libsignal.SessionCipher.decrypt(SessionCipher.java:211)
at org.jivesoftware.smackx.omemo.signal.SignalOmemoRatchet.doubleRatchetDecrypt(SignalOmemoRatchet.java:122)
at org.jivesoftware.smackx.omemo.OmemoRatchet.retrieveMessageKeyAndAuthTag(OmemoRatchet.java:106)
at org.jivesoftware.smackx.omemo.OmemoService.decryptMessage(OmemoService.java:456)
at org.jivesoftware.smackx.omemo.OmemoService.onOmemoMessageStanzaReceived(OmemoService.java:1166)
at org.jivesoftware.smackx.omemo.OmemoManager$3$1.run(OmemoManager.java:945)
at java.lang.Thread.run(Thread.java:818)
Caused by: org.whispersystems.libsignal.InvalidMessageException: Bad Mac!
at org.whispersystems.libsignal.protocol.SignalMessage.verifyMac(SignalMessage.java:119)
at org.whispersystems.libsignal.SessionCipher.decrypt(SessionCipher.java:313)
at org.whispersystems.libsignal.SessionCipher.decrypt(SessionCipher.java:268)
at org.whispersystems.libsignal.SessionCipher.decrypt(SessionCipher.java:243)
at org.whispersystems.libsignal.SessionCipher.decrypt(SessionCipher.java:211)
at org.jivesoftware.smackx.omemo.signal.SignalOmemoRatchet.doubleRatchetDecrypt(SignalOmemoRatchet.java:122)
at org.jivesoftware.smackx.omemo.OmemoRatchet.retrieveMessageKeyAndAuthTag(OmemoRatchet.java:106)
at org.jivesoftware.smackx.omemo.OmemoService.decryptMessage(OmemoService.java:456)
at org.jivesoftware.smackx.omemo.OmemoService.onOmemoMessageStanzaReceived(OmemoService.java:1166)
at org.jivesoftware.smackx.omemo.OmemoManager$3$1.run(OmemoManager.java:945)
at java.lang.Thread.run(Thread.java:818)
03-25 08:02:32.394 19291-3033/org.atalk.android W/aTalk: [8] org.jivesoftware.smackx.omemo.OmemoService.repairBrokenSessionWithPreKeyMessage() Attempt to repair the session by sending a fresh preKey message to swordfish@atalk.sytes.net:595475613