<div dir="ltr"><div>Hello again,<br><br><br>So I have been doing some digging, and I can see:<br><br>when gone_secure is called, I have context->msgstate equal to OTRL_MSGSTATE_ENCRYPTED<br><br><br>Just before, "otrl_message_sending", msgstate is still equal to OTRL_MSGSTATE_ENCRYPTED for the appropriate contact.<br><br>However, during the call, I have a message event triggered, and I can see the message "OTRL_MSGEVENT_ENCRYPTION_REQUIRED".<br>And the value of context->msgstate changed to OTRL_MSGSTATE_PLAINTEXT<br><br>After the end of the call of "otrl_message_sending" the msgstate is equal to OTRL_MSGSTATE_PLAINTEXT. </div><div><br></div><div>Maybe that would help to identify my mistake? </div><div><br></div><div>Thanks</div><div><br></div><div><br></div><div>Kind regards</div><div>Pierre<br> </div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-06-28 20:05 GMT+02:00 Pierre Lebreton <span dir="ltr"><<a href="mailto:dev.amonchakai@gmail.com" target="_blank">dev.amonchakai@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks a lot for the quick reply! <div><br></div><div>I think I am in the second case: indeed I set the policy to  <span style="font-size:13px">OTRL_POLICY_REQUIRE_ENCRYPTION:</span></div><span class=""><div><br></div><div><p style="margin:0px;font-size:11px;font-family:Monaco"><span style="text-decoration:underline;color:rgb(141,32,142)">static</span><span style="text-decoration:underline"> OtrlPolicy </span><span style="text-decoration:underline;color:rgb(0,135,151)">myotr_policy</span><span style="text-decoration:underline">(</span><span style="text-decoration:underline;color:rgb(141,32,142)">void</span><span style="text-decoration:underline"> *opdata, ConnContext *context)</span></p>
<p style="margin:0px;font-size:11px;font-family:Monaco">{</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    <span style="color:rgb(141,32,142)">return</span> OTRL_POLICY_ALLOW_V2</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">        | OTRL_POLICY_REQUIRE_ENCRYPTION;</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">}</p></div><div><br></div><div><br></div></span><div>If I let Adium start the OTR protocol, I can see it sends a <span style="font-family:Monaco;font-size:11px">?OTRv2? request. I give that message to my function '</span><span style="color:rgb(0,135,151);font-family:Monaco;font-size:11px">message_received</span><span style="font-family:Monaco;font-size:11px">':</span></div><span class=""><div><span style="font-family:Monaco;font-size:11px"><br></span></div><div><p style="margin:0px;font-size:11px;font-family:Monaco"><span style="color:rgb(141,32,142)">void</span> <span style="color:rgb(0,135,151)">message_received</span>(<span style="color:rgb(141,32,142)">const</span> <span style="color:rgb(0,135,151)">QString</span>& ourAccount, <span style="color:rgb(141,32,142)">const</span> <span style="color:rgb(0,135,151)">QString</span>& account, <span style="color:rgb(141,32,142)">const</span> <span style="color:rgb(0,135,151)">QString</span>& protocol, <span style="color:rgb(141,32,142)">const</span> <span style="color:rgb(0,135,151)">QString</span>& message) {</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    uint32_t ignore = 0;</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    <span style="color:rgb(141,32,142)">char</span> *new_message = <span style="color:rgb(90,131,32)">NULL</span>;</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    OtrlTLV *tlvs = <span style="color:rgb(90,131,32)">NULL</span>;</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;min-height:15px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Monaco;min-height:15px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    ignore = otrl_message_receiving(<span style="color:rgb(0,83,94)">us</span>, &<span style="color:rgb(0,83,94)">ui_ops</span>, <span style="color:rgb(90,131,32)">NULL</span>, ourAccount.<span style="color:rgb(90,131,32)">toAscii</span>(), protocol.<span style="color:rgb(90,131,32)">toAscii</span>(), account.<span style="color:rgb(90,131,32)">toAscii</span>(), message.<span style="color:rgb(90,131,32)">toAscii</span>(), &new_message, &tlvs, <span style="color:rgb(90,131,32)">NULL</span>, <span style="color:rgb(90,131,32)">NULL</span>, <span style="color:rgb(90,131,32)">NULL</span>);</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;min-height:15px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(145,145,145)"><span style="color:rgb(0,0,0)">    </span>// if ignore == 1, then it is a core message from OTR. We don't want to display that.</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    <span style="color:rgb(141,32,142)">if</span>(ignore == 0) {</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;min-height:15px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Monaco">        <span style="color:rgb(141,32,142)">if</span> (new_message) {</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">          <span style="color:rgb(0,135,151)">QString</span> ourm(new_message);</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">          otrl_message_free(new_message);</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;min-height:15px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Monaco">          <span style="color:rgb(90,131,32)">qDebug</span>() << <span style="color:rgb(142,61,8)">"encrypted message: "</span> <<  ourm;</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">        } <span style="color:rgb(141,32,142)">else</span> {</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;min-height:15px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Monaco">          <span style="color:rgb(90,131,32)">qDebug</span>() << <span style="color:rgb(142,61,8)">"message not encrypted: "</span> <<  message;</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">        }</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    }</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;min-height:15px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    <span style="color:rgb(141,32,142)">if</span>(tlvs) {</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(142,61,8)"><span style="color:rgb(0,0,0)">        </span><span style="color:rgb(90,131,32)">qDebug</span><span style="color:rgb(0,0,0)">() << </span>"there are side info!"<span style="color:rgb(0,0,0)">;</span></p>
<p style="margin:0px;font-size:11px;font-family:Monaco">        otrl_tlv_free(tlvs);</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    }</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">}</p></div><div> </div><div><br></div></span><div>My inject_message, only forward everything to XMPP:</div><div><br></div><div><p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(0,135,151)"><span style="color:rgb(141,32,142)">static</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(141,32,142)">void</span><span style="color:rgb(0,0,0)"> </span>myotr_inject_message<span style="color:rgb(0,0,0)">(</span><span style="color:rgb(141,32,142)">void</span><span style="color:rgb(0,0,0)"> *opdata,</span></p>
<p style="margin:0px;font-size:11px;font-family:Monaco">                                 <span style="color:rgb(141,32,142)">const</span> <span style="color:rgb(141,32,142)">char</span> *accountname, <span style="color:rgb(141,32,142)">const</span> <span style="color:rgb(141,32,142)">char</span> *protocol, <span style="color:rgb(141,32,142)">const</span> <span style="color:rgb(141,32,142)">char</span> *recipient,</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">                                 <span style="color:rgb(141,32,142)">const</span> <span style="color:rgb(141,32,142)">char</span> *message)</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">{</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    <span style="color:rgb(0,135,151)">XMPP</span>::<span style="color:rgb(90,131,32)">get</span>()-><span style="color:rgb(90,131,32)">sendXMPPMessageTo</span>(recipient, message);</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">}</p></div><div><br></div><div><br></div><div><br></div><div>And, then I can see that there are some encrypted messages exchanged, and in the logs I can see that gone_secured is called, and otr_new_fingerprint is called as well. </div><div>But currently, the body of these functions are empty in my code. I only have debug information in it. </div><div>And Adium report that the encryption is enabled.</div><div><br></div><div><br></div><div>Then, when I want to send a message, I just call:</div><div><p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(142,61,8)"><span style="color:rgb(0,135,151)">send_message</span><span style="color:rgb(0,0,0)">(</span>"<a href="mailto:amonchakai2@jabber.de" target="_blank">amonchakai2@jabber.de</a>"<span style="color:rgb(0,0,0)">, </span>"<span style="text-decoration:underline">amonchakai</span>@<a href="http://jabber.de" target="_blank">jabber.de</a>"<span style="color:rgb(0,0,0)">, </span>"<span style="text-decoration:underline">xmpp</span>"<span style="color:rgb(0,0,0)">, message);</span></p></div><div><br></div><div><br></div><div>Which correspond to:</div><div><span class=""><p style="margin:0px;font-size:11px;font-family:Monaco"><span style="color:rgb(141,32,142)">void</span> <span style="color:rgb(0,135,151)">send_message</span> (<span style="color:rgb(141,32,142)">const</span> <span style="color:rgb(0,135,151)">QString</span>& ourAccount, <span style="color:rgb(141,32,142)">const</span> <span style="color:rgb(0,135,151)">QString</span>& account, <span style="color:rgb(141,32,142)">const</span> <span style="color:rgb(0,135,151)">QString</span>& protocol, <span style="color:rgb(141,32,142)">const</span> <span style="color:rgb(0,135,151)">QString</span>& message) {</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    <span style="color:rgb(141,32,142)">char</span> *new_message = <span style="color:rgb(90,131,32)">NULL</span>;</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    gcry_error_t err;</p>
</span><p style="margin:0px;font-size:11px;font-family:Monaco">    OtrlTLV* tlvs = 0;</p><span class="">
<p style="margin:0px;font-size:11px;font-family:Monaco;min-height:15px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    err = otrl_message_sending(<span style="color:rgb(0,83,94)">us</span>, &<span style="color:rgb(0,83,94)">ui_ops</span>, <span style="color:rgb(90,131,32)">NULL</span>, ourAccount.<span style="color:rgb(90,131,32)">toAscii</span>(), protocol.<span style="color:rgb(90,131,32)">toAscii</span>(), account.<span style="color:rgb(90,131,32)">toAscii</span>(), OTRL_INSTAG_BEST, message.<span style="color:rgb(90,131,32)">toAscii</span>(), <span style="color:rgb(90,131,32)">NULL</span>, &new_message,</p>
</span><p style="margin:0px;font-size:11px;font-family:Monaco">        OTRL_FRAGMENT_SEND_ALL_BUT_LAST, <span style="color:rgb(90,131,32)">NULL</span>, <span style="color:rgb(90,131,32)">NULL</span>, <span style="color:rgb(90,131,32)">NULL</span>);</p><span class="">
<p style="margin:0px;font-size:11px;font-family:Monaco;min-height:15px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    <span style="color:rgb(90,131,32)">qDebug</span>() << <span style="color:rgb(142,61,8)">"error code: "</span> << err;</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;min-height:15px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    <span style="color:rgb(141,32,142)">if</span> (new_message) {</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">        <span style="color:rgb(0,135,151)">QString</span> ourm(new_message);</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">        otrl_message_free(new_message);</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">        <span style="color:rgb(90,131,32)">qDebug</span>() << <span style="color:rgb(142,61,8)">"encrypted message: "</span> <<  ourm;</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;min-height:15px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Monaco">        <span style="color:rgb(0,135,151)">XMPP</span>::<span style="color:rgb(90,131,32)">get</span>()-><span style="color:rgb(90,131,32)">sendXMPPMessageTo</span>(account, ourm);</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    }</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;min-height:15px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    <span style="color:rgb(141,32,142)">if</span> (err) {</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">        <span style="color:rgb(90,131,32)">qDebug</span>() << <span style="color:rgb(142,61,8)">"</span><span style="text-decoration:underline;color:rgb(142,61,8)">plouf</span><span style="color:rgb(142,61,8)">!"</span>;</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">    }</p>
<p style="margin:0px;font-size:11px;font-family:Monaco">}</p></span></div><div><br></div><div>I get the default message as explained previously.</div><div><br></div><div><br></div><div><br></div><div><br></div><div>And I did checked, the order of the parameters :-) </div><div>In Adium I am connected as amonchakai, and amonchakai2 in my BB10 client. </div><div>The protocol is also consistent: I am always using "xmpp"</div><div><br></div><div><br></div><div><br></div><div>Thanks for the help ! </div><div><br></div><div>Kind regards,</div><div>Pierre</div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2015-06-28 19:14 GMT+02:00 Ian Goldberg <span dir="ltr"><<a href="mailto:ian@cypherpunks.ca" target="_blank">ian@cypherpunks.ca</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Sun, Jun 28, 2015 at 04:28:39PM +0200, Pierre Lebreton wrote:<br>
> Hello,<br>
><br>
> I have been working on integrating OTR to my XMPP client for BlackBerry 10.<br>
<br>
</span>Great!<br>
<span><br>
> I managed to get many things work, but I still have some trouble to send<br>
> encrypted messages. So I was wondering if someone could help me to locate<br>
> what I am missing.<br>
><br>
> What I am able to do is to:<br>
> - initiate the OTR protocol, and got up to the point where "gone_secure" is<br>
> called, and I have the fingerprint of the recipient.<br>
> - If the other client (Adium) is sending me encrypted messages, I am able<br>
> to decrypt them.<br>
><br>
> But when I try to send messages, "otrl_message_sending" replace my message<br>
> by a new OTR request:<br>
><br>
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>
><br>
> "?OTRv2?<br>
><br>
> <b><a href="mailto:amonchakai2@jabber.de" target="_blank">amonchakai2@jabber.de</a></b> has requested an <a href="<br>
> <a href="https://otr.cypherpunks.ca/" rel="noreferrer" target="_blank">https://otr.cypherpunks.ca/</a>">Off-the-Record private conversation</a>.<br>
> However, you do not have a plugin to support that.<br>
><br>
> See <a href="<a href="https://otr.cypherpunks.ca/" rel="noreferrer" target="_blank">https://otr.cypherpunks.ca/</a>"><a href="https://otr.cypherpunks.ca/" rel="noreferrer" target="_blank">https://otr.cypherpunks.ca/</a></a><br>
> for more information."<br>
><br>
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>
<br>
</span>Hmm, interesting.  I think there are three times otrl_message_sending<br>
would output the default query message:<br>
<br>
- If you pass the string "?OTR?" or similar *into* otrl_message_sending.<br>
<br>
- If your policy has OTRL_POLICY_REQUIRE_ENCRYPTION set, but the context<br>
  msgstate is still at OTRL_MESSAGE_PLAINTEXT.<br>
<br>
- If you receive an OTR Error messaage, and your policy has<br>
  OTRL_POLICY_ERROR_START_AKE set.<br>
<br>
Could you possibly step through otrl_message_sending and see which it<br>
thinks is happening?<br>
<br>
Thanks,<br>
<br>
   - Ian<br>
_______________________________________________<br>
OTR-dev mailing list<br>
<a href="mailto:OTR-dev@lists.cypherpunks.ca" target="_blank">OTR-dev@lists.cypherpunks.ca</a><br>
<a href="http://lists.cypherpunks.ca/mailman/listinfo/otr-dev" rel="noreferrer" target="_blank">http://lists.cypherpunks.ca/mailman/listinfo/otr-dev</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>