Smack -omemo for 4.2.1 with E2E Encryption

Afaict you are almost there. I think you use the wrong version of libsignal (yours is too new. you should use libsignal-protocol-java 2.4.0)

Hi Paul thanks For your support.

i have tried the code last night it is able to generate all the key store as well as all the keys i can check in my folder as well but when i am trying to encrypt any message it gives me some error like

Exception in thread ā€œmainā€ java.lang.AssertionError: java.security.InvalidKeyException: Illegal key size
at org.whispersystems.libsignal.SessionCipher.getCipher(SessionCipher.java:443)
at org.whispersystems.libsignal.SessionCipher.getCiphertext(SessionCipher.java:388)
at org.whispersystems.libsignal.SessionCipher.encrypt(SessionCipher.java:100)
at org.jivesoftware.smackx.omemo.signal.SignalOmemoSession.encryptMessageKey(SignalOmemoSession.java:99)
at org.jivesoftware.smackx.omemo.util.OmemoMessageBuilder.addRecipient(OmemoMessageBuilder.java:203)
at org.jivesoftware.smackx.omemo.util.OmemoMessageBuilder.addRecipient(OmemoMessageBuilder.java:179)
at org.jivesoftware.smackx.omemo.OmemoService.encryptOmemoMessage(OmemoService.java:982)
at org.jivesoftware.smackx.omemo.OmemoService.processSendingMessage(OmemoService.java:887)
at org.jivesoftware.smackx.omemo.OmemoService.processSendingMessage(OmemoService.java:793)
at org.jivesoftware.smackx.omemo.OmemoManager.encrypt(OmemoManager.java:229)
at com.smack.demo.E2E.main(E2E.java:108)
Caused by: java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1024)
at javax.crypto.Cipher.implInit(Cipher.java:790)
at javax.crypto.Cipher.chooseProvider(Cipher.java:849)
at javax.crypto.Cipher.init(Cipher.java:1348)
at javax.crypto.Cipher.init(Cipher.java:1282)
at org.whispersystems.libsignal.SessionCipher.getCipher(SessionCipher.java:438)
ā€¦ 10 more

I am attching my src code as well as key structure please help me for the final time.

test@hiren.rar (16.0 KB)

src code : E2E.java (5.4 KB)

Thanks in advanced.

Any chance you are running the code on a windows machine?
In that case you might want to download the Java Cryptography Extension to make it work.
See https://stackoverflow.com/a/6481658

Thanks for your fast response.
I am running on windows 7 now.
Will try to cryptographic extension.

Hi paul,

Thanks fir your support.

now i can easily encrypt and decrypt messages on one-to-one chat.

Is there any mechanism using which we can establish E2E in group chat or MUC.

Basically it works the same way. MUCs must be non-anonymous and you have to have all members in your contact list.
Then you can use OmemoManager.encrypt(MultiUserChat, ā€¦) method to encrypt messages for a MUC and register an OmemoMucMessageListener to listen for OMEMO muc messages.

Hi paul i got stuck on another problem

for 2 user it is working fine without any issue we can encrypt and decrypt messages easily now but for new user sometimes we found some error like

WARNING: Could not fetch device list of hiren@hiren
org.jivesoftware.smackx.pubsub.PubSubException$NotAPubSubNodeExceptionat org.jivesoftware.smackx.pubsub.PubSubManager.getNode(PubSubManager.java:254)
at org.jivesoftware.smackx.pubsub.PubSubManager.getLeafNode(PubSubManager.java:331)
at org.jivesoftware.smackx.omemo.OmemoService.fetchDeviceListNode(OmemoService.java:436)
at org.jivesoftware.smackx.omemo.OmemoService.fetchDeviceList(OmemoService.java:455)
at org.jivesoftware.smackx.omemo.OmemoService.refreshDeviceList(OmemoService.java:507)
at org.jivesoftware.smackx.omemo.OmemoService.buildOrCreateOmemoSessionsFromBundles(OmemoService.java:611)
at org.jivesoftware.smackx.omemo.OmemoService.processSendingMessage(OmemoService.java:816)
at org.jivesoftware.smackx.omemo.OmemoService.processSendingMessage(OmemoService.java:793)
at org.jivesoftware.smackx.omemo.OmemoManager.encrypt(OmemoManager.java:229)

hiren- user
@hiren - domain so donā€™t confuse with that one.

could you please help me to understand this issues.

Thanks,
Hiren

This probably means, that your user doesnā€™t have access to hirens deviceList. That might be because your user and hiren didnt subscribe to each others presence (aka didnā€™t add each other to the roster).
It might also be that hiren didnt publish his deviceList in the first place (for example because his client doesnt support OMEMO). Or maybe the list got deleted for some reason (server restart for example).

Hi paul,

Thanks for you response.

i used the same source code for both the client so i think there is no way that client is not supported.

Both user have subscribed to each other but not find any active device in omemo store path.

Might be possible that hiren havenā€™t publish the device list so is there any way to publish it again to all the users.

Because after some time it got working using the same code so not sure what is going wrong.

Thanks,
Hiren

I received bug reports in the past which suggesting, that the device list might only get published on the second start of the app (which I cannot reproduce, but maybe this helps you to pin point the issue).

Hi Paul,

I found discovered bug from openfire server why it is not responding correctly to PEP request.

I have fixed in my local machine and working fine now no need to restart the PC it is working fine now. Bug is sometime null node against the newly created user is inserted into cache memory and when other user asking the information about the node then without asking to DB it throws null object.

I Want to apply this fix to openfire server so i am not sure the process how to do that could you please suggest how to do that?

Thanks for the support.

Iā€™d suggest you to open a ticket in the Openfire forums about that :slight_smile:

@Hiren1 has your issue resolved? If so, can you close this thread?

i donā€™t know my issue have been taken care or not yet i have to open a ticket.

Donā€™t know how to do that.

THanks,
Hiren Vavadiya

Just make a post in the Openfire category, describe your issue and maybe link to this thread :slight_smile: