gkdr / lurch

XEP-0384: OMEMO Encryption for libpurple.
GNU General Public License v3.0
289 stars 32 forks source link

Can't receive encrypted messages #146

Closed Flamefire closed 3 years ago

Flamefire commented 4 years ago

Using pidigin and installed it according to Readme but receiving messages only shows: [This message is OMEMO encrypted]

I had to restart pidgin after installing and enabling the plugin just as reported in https://github.com/gkdr/lurch/issues/72

Still no luck

gkdr commented 4 years ago

What is the other client?

Flamefire commented 4 years ago

My colleague was using dino-im

selurvedu commented 4 years ago

For me this issue has been around since I first tried Dino 2 years ago. I regularly checked, but not much changed since then.

gkdr commented 4 years ago

Would you mind trying the dev branch? The commit d82c8b4 should have fixed that.

selurvedu commented 4 years ago

@gkdr I tried it and did not notice any change. A few other people from my contact list have this problem too.

gkdr commented 4 years ago

@selurvedu did you update the git submodules too?

XRevan86 commented 4 years ago

@gkdr, I have back-ported that particular commit to the lurch package in openSUSE 8 months ago, and have been using it ever since. It does help, as one person with whom I'm communicating is using two Dino's, and one of their Dino's, after that commit, is able to communicate with lurch. But not the other one, and not anyone else. So I guess it is necessary but insufficient.

iv4nhoe commented 3 years ago

I'm having the same issue, both with master and dev branches.

gkdr commented 3 years ago

@iv4nhoe thanks for the report. is it also with dino? could you copy and paste from the debug log when that happens?

iv4nhoe commented 3 years ago

@iv4nhoe thanks for the report. is it also with dino? could you copy and paste from the debug log when that happens?

Yes, it is with dino. In the log it says: lurch: received omemo message that does not contain a key for this device, skipping

gkdr commented 3 years ago

thanks for the quick response! if if remember correctly, this client discovery issue has been there for a while in different iterations. could you please open the xmpp console and manually check your device list as described in the troubleshooting section of the README?

iv4nhoe commented 3 years ago

thanks for the quick response! if if remember correctly, this client discovery issue has been there for a while in different iterations. could you please open the xmpp console and manually check your device list as described in the troubleshooting section of the README?

It lists the same devices as /lurch id list, I'm not sure if that's what you wanted to know. We can also continue this on pidgin's IRC if you like, so this thread doesn't get cluttered.

gkdr commented 3 years ago

so you see your own device in the server response? that's good. now the last thing to check is: do you see in the raw xml of the incoming xmpp message that there is in fact no key for your device ID?

i think it's not bad to have a permanent log of this, you're right though that it's easier when it is more interactive. i'm in irc now :slightly_smiling_face:

iv4nhoe commented 3 years ago

so you see your own device in the server response? that's good. now the last thing to check is: do you see in the raw xml of the incoming xmpp message that there is in fact no key for your device ID?

i think it's not bad to have a permanent log of this, you're right though that it's easier when it is more interactive. i'm in irc now slightly_smiling_face

ok, here's the debug output for a message I (MY_USER) received from OTHER_USER:

<message to='MY_USER' type='chat' from='OTHER_USER' id='e46fd7e9-d3bd-465d-827b-12d167478475'><body>[This message is OMEMO encrypted]</body><encrypted xmlns='eu.siacs.conversations.axolotl'><header sid='510152406'><iv>vO2imvNilgkfCpaW</iv><key rid='1448265191'>MwohBbue520IhLs/h++MPPbYSFjlIUj09KKuf1cYHLEiSgF4EBcYACIw17meW0Snr/aWxniVjLtg3C4n/r2ZEQ2HWPqaOnK0krKF1g/LQZDu/HxddAZGntfFOv1UX/kJ+FY=</key><key rid='168348112' prekey='true'>MwhiEiEFWbV35Nt/U2KdNW8ayuBsO0RPcwHvJGo/4jBwVYT03AoaIQW48E9ew2jA7fc4Tn01DY+jov+sN8k8qdvnXRH7vX88KyJiMwohBQ0g58hiwZwq2X/7/pRN1IE11KFyvP4wmchCzyTOyW4fEBMYACIw/FbVzCSEOg2ezH9IGh/CUc7JChjk3QXz0GKNIjpL9XS62k8KqcgZ8ZAJY+h0rM9EOCTYgXkxNxko1p2h8wEwAA==</key><key rid='620603299'>MwohBfcg4LjUmJMD6YYhoaip4hbsHeK3nQl2CzQixBwGercSEAAYACIwnwOWCQxZ8grFCkjZNyynDk3dGfPWLBN6KBkyn5D5Bn1jePaXvnJPgLuhlFVSy67Xaq4gRnir8zQ=</key><key rid='1239029576'>MwohBehNJ/Qecu/Ju5MIWYFBrxJBPerPh+yB1oqqZLRZQDomEOsRGFAiMHfo2ym5/cKkHbzgRJBE5Hll4rMGWsMLssFXdbY6zfmam275WX2mf/pM+tYavFvjepwn7GFy8u80</key><key rid='323657168'>MwohBbMIzIHJMEsWjebOViQFSkIlLjpSYtUC0w3sFDoc7UEkEJ4RGJAKIjC/ORt4U57ALHxohGFCugF26mVaODdNwSvOr6n4XNXNFV0pBjVSkHw8Ptv9KZ8i2dT8zdHKinCmGg==</key><key rid='1985038800'>MwohBWGH3Y23somxka/hQX72Scij3SyazQLYBA62QzYtHS8mEMABGMoOIjALTfHlM7haAlFWbnN+2/AkHSCfzLWcaIsU6RQsupZzr0GzqAyEYP5pWpqTMsuxzJVDlUkcE7KiYA==</key></header><payload>W+gtbx6B+/YmfCt7Dw==</payload></encrypted><encryption xmlns='urn:xmpp:eme:0' name='OMEMO' namespace='eu.siacs.conversations.axolotl'/><request xmlns='urn:xmpp:receipts'/><active xmlns='http://jabber.org/protocol/chatstates'/><markable xmlns='urn:xmpp:chat-markers:0'/><stanza-id xmlns='urn:xmpp:sid:0' by='MY_USER' id='ffc59d6e-6618-4bf6-b557-9e89dfa26e3f'/></message>
(13:18:08) jabber: XML parser error for JabberStream 0x558a8b7869b0: Domain 3, code 100, level 1: xmlns: URI eu.siacs.conversations.axolotl is not absolute
(13:18:08) lurch: received omemo message that does not contain a key for this device, skipping
selurvedu commented 3 years ago

I'm sorry to interrupt you, but since lurch is a XMPP thing, isn't devel@conference.pidgin.im a better place than IRC? 😜

gkdr commented 3 years ago

@selurvedu it does seem like it. is there any one in there? :slightly_smiling_face:

@iv4nhoe based on the input you provided, i created the testcase you see below. i was not able to reproduce the error - every key contained in the header could be found.

void test_message_get_encrypted_key_with_rid(void ** state) {
  (void) state;

  char * msg = "<message to='MY_USER' type='chat' from='OTHER_USER' id='e46fd7e9-d3bd-465d-827b-12d167478475'>"
  "<body>[This message is OMEMO encrypted]</body>"
  "<encrypted xmlns='eu.siacs.conversations.axolotl'>"
    "<header sid='510152406'>"
      "<iv>vO2imvNilgkfCpaW</iv>"
      "<key rid='1448265191'>MwohBbue520IhLs/h++MPPbYSFjlIUj09KKuf1cYHLEiSgF4EBcYACIw17meW0Snr/aWxniVjLtg3C4n/r2ZEQ2HWPqaOnK0krKF1g/LQZDu/HxddAZGntfFOv1UX/kJ+FY=</key>"
      "<key rid='168348112' prekey='true'>MwhiEiEFWbV35Nt/U2KdNW8ayuBsO0RPcwHvJGo/4jBwVYT03AoaIQW48E9ew2jA7fc4Tn01DY+jov+sN8k8qdvnXRH7vX88KyJiMwohBQ0g58hiwZwq2X/7/pRN1IE11KFyvP4wmchCzyTOyW4fEBMYACIw/FbVzCSEOg2ezH9IGh/CUc7JChjk3QXz0GKNIjpL9XS62k8KqcgZ8ZAJY+h0rM9EOCTYgXkxNxko1p2h8wEwAA==</key>"
      "<key rid='620603299'>MwohBfcg4LjUmJMD6YYhoaip4hbsHeK3nQl2CzQixBwGercSEAAYACIwnwOWCQxZ8grFCkjZNyynDk3dGfPWLBN6KBkyn5D5Bn1jePaXvnJPgLuhlFVSy67Xaq4gRnir8zQ=</key>"
      "<key rid='1239029576'>MwohBehNJ/Qecu/Ju5MIWYFBrxJBPerPh+yB1oqqZLRZQDomEOsRGFAiMHfo2ym5/cKkHbzgRJBE5Hll4rMGWsMLssFXdbY6zfmam275WX2mf/pM+tYavFvjepwn7GFy8u80</key>"
      "<key rid='323657168'>MwohBbMIzIHJMEsWjebOViQFSkIlLjpSYtUC0w3sFDoc7UEkEJ4RGJAKIjC/ORt4U57ALHxohGFCugF26mVaODdNwSvOr6n4XNXNFV0pBjVSkHw8Ptv9KZ8i2dT8zdHKinCmGg==</key>"
      "<key rid='1985038800'>MwohBWGH3Y23somxka/hQX72Scij3SyazQLYBA62QzYtHS8mEMABGMoOIjALTfHlM7haAlFWbnN+2/AkHSCfzLWcaIsU6RQsupZzr0GzqAyEYP5pWpqTMsuxzJVDlUkcE7KiYA==</key>"
    "</header>"
    "<payload>W+gtbx6B+/YmfCt7Dw==</payload>"
    "</encrypted>"
    "<encryption xmlns='urn:xmpp:eme:0' name='OMEMO' namespace='eu.siacs.conversations.axolotl'/>"
    "<request xmlns='urn:xmpp:receipts'/>"
    "<active xmlns='http://jabber.org/protocol/chatstates'/>"
    "<markable xmlns='urn:xmpp:chat-markers:0'/>"
    "<stanza-id xmlns='urn:xmpp:sid:0' by='MY_USER' id='ffc59d6e-6618-4bf6-b557-9e89dfa26e3f'/>"
    "</message>";

  omemo_message * msg_p;
  assert_int_equal(omemo_message_prepare_decryption(msg, &msg_p), 0);

  uint8_t * key_p;
  size_t key_len;
  assert_int_equal(omemo_message_get_encrypted_key(msg_p, 1448265191, &key_p, &key_len), 0);
  assert_int_equal(omemo_message_get_encrypted_key(msg_p, 168348112, &key_p, &key_len), 0);
  assert_int_equal(omemo_message_get_encrypted_key(msg_p, 620603299, &key_p, &key_len), 0);
  assert_int_equal(omemo_message_get_encrypted_key(msg_p, 1239029576, &key_p, &key_len), 0);
  assert_int_equal(omemo_message_get_encrypted_key(msg_p, 323657168, &key_p, &key_len), 0);
  assert_int_equal(omemo_message_get_encrypted_key(msg_p, 1985038800, &key_p, &key_len), 0);
  // assert_int_equal(key_len, 181);
  // assert_memory_equal(key_p, data, key_len);

  omemo_message_destroy(msg_p);
}

would you be willing to paste that into lib/libomemo/test/test_libomemo,c? you will also habe to add it to the array in the main()function in the bottom of that file like so: cmocka_unit_test(test_message_get_encrypted_key_with_rid),. then, you can run it from lib/libomemo/ by calling make test.

could you also tell me which version of the mxml library you have installed?

selurvedu commented 3 years ago

@gkdr yeah, go check it out!

iv4nhoe commented 3 years ago

would you be willing to paste that into lib/libomemo/test/test_libomemo,c? you will also habe to add it to the array in the main()function in the bottom of that file like so: cmocka_unit_test(test_message_get_encrypted_key_with_rid),. then, you can run it from lib/libomemo/ by calling make test.

could you also tell me which version of the mxml library you have installed?

Test also passes for me:

[ RUN      ] test_message_get_encrypted_key_with_rid
[       OK ] test_message_get_encrypted_key_with_rid

mxml is version 3.1

iv4nhoe commented 3 years ago

@gkdr I have good news and bad news. Good news, it's working now. Bad news, I don't know why. I wanted to investigate what's going on in omemo_message_get_encrypted_key but I couldn't get debug information so I changed -g in libomemo Makefile to -ggdb (although -g should have been fine) and recompiled everything (using make -B install-home in lurch folder). Then I ran pidgin in the debugger with a break on omemo_message_get_encrypted_key, which I stepped through when I received a new message. Everything seemed fine (ret_val was 0 and key_pp was set) then I removed the break and continued execution and noticed that I got the proper message.

It may be also of note that to test this I created a new account which I logged in to with Dino and my old account was using Pidgin. But after this the communication with the friend who uses Dino works as well.

It's also possible that I didn't fully rebuild the plugin after I switched to the dev branches. IIRC I did make clean && make install-home and not make -B install-home which also rebuilds libsignal-protocol-c.

gkdr commented 3 years ago

well, i'm glad it works for you now :slightly_smiling_face: thanks for trying to run it through a debugger, i appreciate the effort. and it would have been the best and maybe only way to know what's up. can't really think of what else could go wrong in the code.

i think a related major issue here is that lurch does not send the prekey attribute, so the session cannot be established in the other direction either. there is already an issue tracking this, so i'm going to close this one. if you happen to come across this problem again, please open another issue. maybe we'll manage to hunt it down then :grimacing: