[OTR-dev] Sending encrypted messages

Pierre Lebreton dev.amonchakai at gmail.com
Sun Jun 28 14:05:46 EDT 2015


Thanks a lot for the quick reply!

I think I am in the second case: indeed I set the policy to
OTRL_POLICY_REQUIRE_ENCRYPTION:

static OtrlPolicy myotr_policy(void *opdata, ConnContext *context)

{

    return OTRL_POLICY_ALLOW_V2

        | OTRL_POLICY_REQUIRE_ENCRYPTION;

}


If I let Adium start the OTR protocol, I can see it sends a ?OTRv2?
request. I give that message to my function 'message_received':

void message_received(const QString& ourAccount, const QString& account,
const QString& protocol, const QString& message) {

    uint32_t ignore = 0;

    char *new_message = NULL;

    OtrlTLV *tlvs = NULL;



    ignore = otrl_message_receiving(us, &ui_ops, NULL, ourAccount.toAscii(),
protocol.toAscii(), account.toAscii(), message.toAscii(), &new_message,
&tlvs, NULL, NULL, NULL);


    // if ignore == 1, then it is a core message from OTR. We don't want to
display that.

    if(ignore == 0) {


        if (new_message) {

          QString ourm(new_message);

          otrl_message_free(new_message);


          qDebug() << "encrypted message: " <<  ourm;

        } else {


          qDebug() << "message not encrypted: " <<  message;

        }

    }


    if(tlvs) {

        qDebug() << "there are side info!";

        otrl_tlv_free(tlvs);

    }

}


My inject_message, only forward everything to XMPP:

static void myotr_inject_message(void *opdata,

                                 const char *accountname, const char
*protocol, const char *recipient,

                                 const char *message)

{

    XMPP::get()->sendXMPPMessageTo(recipient, message);

}



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.
But currently, the body of these functions are empty in my code. I only
have debug information in it.
And Adium report that the encryption is enabled.


Then, when I want to send a message, I just call:

send_message("amonchakai2 at jabber.de", "amonchakai at jabber.de", "xmpp",
message);


Which correspond to:

void send_message (const QString& ourAccount, const QString& account, const
QString& protocol, const QString& message) {

    char *new_message = NULL;

    gcry_error_t err;

    OtrlTLV* tlvs = 0;


    err = otrl_message_sending(us, &ui_ops, NULL, ourAccount.toAscii(),
protocol.toAscii(), account.toAscii(), OTRL_INSTAG_BEST, message.toAscii(),
NULL, &new_message,

        OTRL_FRAGMENT_SEND_ALL_BUT_LAST, NULL, NULL, NULL);


    qDebug() << "error code: " << err;


    if (new_message) {

        QString ourm(new_message);

        otrl_message_free(new_message);

        qDebug() << "encrypted message: " <<  ourm;


        XMPP::get()->sendXMPPMessageTo(account, ourm);

    }


    if (err) {

        qDebug() << "plouf!";

    }

}

I get the default message as explained previously.




And I did checked, the order of the parameters :-)
In Adium I am connected as amonchakai, and amonchakai2 in my BB10 client.
The protocol is also consistent: I am always using "xmpp"



Thanks for the help !

Kind regards,
Pierre





2015-06-28 19:14 GMT+02:00 Ian Goldberg <ian at cypherpunks.ca>:

> On Sun, Jun 28, 2015 at 04:28:39PM +0200, Pierre Lebreton wrote:
> > Hello,
> >
> > I have been working on integrating OTR to my XMPP client for BlackBerry
> 10.
>
> Great!
>
> > I managed to get many things work, but I still have some trouble to send
> > encrypted messages. So I was wondering if someone could help me to locate
> > what I am missing.
> >
> > What I am able to do is to:
> > - initiate the OTR protocol, and got up to the point where "gone_secure"
> is
> > called, and I have the fingerprint of the recipient.
> > - If the other client (Adium) is sending me encrypted messages, I am able
> > to decrypt them.
> >
> > But when I try to send messages, "otrl_message_sending" replace my
> message
> > by a new OTR request:
> >
> >
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >
> > "?OTRv2?
> >
> > <b>amonchakai2 at jabber.de</b> has requested an <a href="
> > https://otr.cypherpunks.ca/">Off-the-Record private conversation</a>.
> > However, you do not have a plugin to support that.
> >
> > See <a href="https://otr.cypherpunks.ca/">https://otr.cypherpunks.ca/
> </a>
> > for more information."
> >
> >
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Hmm, interesting.  I think there are three times otrl_message_sending
> would output the default query message:
>
> - If you pass the string "?OTR?" or similar *into* otrl_message_sending.
>
> - If your policy has OTRL_POLICY_REQUIRE_ENCRYPTION set, but the context
>   msgstate is still at OTRL_MESSAGE_PLAINTEXT.
>
> - If you receive an OTR Error messaage, and your policy has
>   OTRL_POLICY_ERROR_START_AKE set.
>
> Could you possibly step through otrl_message_sending and see which it
> thinks is happening?
>
> Thanks,
>
>    - Ian
> _______________________________________________
> OTR-dev mailing list
> OTR-dev at lists.cypherpunks.ca
> http://lists.cypherpunks.ca/mailman/listinfo/otr-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cypherpunks.ca/pipermail/otr-dev/attachments/20150628/db2d458d/attachment-0001.html>


More information about the OTR-dev mailing list