[OTR-dev] Active fingerprint context pointer possible issue

David Goulet dgoulet at ev0ke.net
Wed Nov 28 13:41:19 EST 2012


Ian Goldberg:
> On Thu, Nov 22, 2012 at 09:29:26AM -0500, David Goulet wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA512
>>
>> Hi Ian,
>>
>> Yes I figured after sending the last email that it might be confusing
>> on what I'm trying to do :). Here goes.
>>
>> I'm currently working on the Irssi OTR module and I added a command to
>> forget a given fingerprint. So either the user does the command within
>> the chat window where for this case I have access to the OTR context
>> so no need to pass a fingerprint to the command or the user specifies
>> the human readable form of the fingerprint. (available fingerprints
>> can be listed using an other command.)
>>
>> With the later, the only thing I have is the string fingerprint (fp)
>> so, for now, the only solution I came up with is to iterate over all
>> OTR contexts of the user state for which I iterate over all fps and
>> try to match the fp using the otrl_privkey_hash_to_human() and, on
>> match, using otrl_context_find_fingerprint() for the fp object pointer.
>>
>> Once getting this pointer, I have to check to see if this fp is NOT in
>> an ENCRYPTED context before forgetting it.
>>
>> Here lies my problem, the fp->context always point to the m_context
>> which does not indicates me the right message state. For now, I've
>> fixed my problem by returning back the context of the fp previously
>> found with otrl_context_find_fingerprint() but I guess I should be
>> able to access all associated context(s) of the fp and make sure it's
>> safe to forget it? I guess, iterating on them starting with
>> m_context->next ?
>>
>> TBH, I'm just confused on how to proceed safely.
>>
>> Hope this is clearer :)
> 
> OK, I think I understand.  What do you *want* to do if multiple children
> of a single master context are using the same fp, and some are in
> ENCRYPTED and some are not?

Yes there you go! I'm sorry, my English can be bad sometimes to explain
such issues... :)

So, what I do now is once I've found the right Fingerprint object (from
the human representation), I iterate over all contexts of the
fingerprint and check for an encrypted msgstate. Basically:

    for (context = fp->context; context != NULL; context = context->next) {
        if (context->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
		return 1;
        }
    }

It's working well at the moment.

Thanks a lot!
David

> 
>    - Ian
> _______________________________________________
> OTR-dev mailing list
> OTR-dev at lists.cypherpunks.ca
> http://lists.cypherpunks.ca/mailman/listinfo/otr-dev



More information about the OTR-dev mailing list