On Thu 26/Jan/2017 12:28:41 +0100 Sam Varshavchik wrote:
>>>>>>  [edited context]
>>>>>> The main difficulty is to get the sources for the include files:
>>>>>>
>>>>>> I include courierauth.h and courierauthsasl.h from authlib-devel.  But
>>>>>> I also need:
>>>>>>
>>>>>> #include    "cramlib.h" // for auth_cram_callback
>>>>>>
>>>>>> In addition, I also need auth.h, because cramlib.h includes it (it
>>>>>> would suffice to declare "struct authinfo;" to avoid the inclusion).
>>>>>> All file names in include_HEADER start with "courier", so renaming
>>>>>> cramlib.h would be in order if this issue is ever addressed.
>>>
>>> These exported functions are meant to be used for developing authentication
>>> clients, not servers.
>>>
>>> Looks like all you need are the functions in cramlib.h
>>
>> Yes, and the structure defined in hmac.h.  I trimmed the text above so as to
>> make it more likely to fit on a sticky note, for the next release of authlib,
>> whenever it comes.
>
> I don't follow – what's still left in hmac.h that needs to be visible, when
> using only the exported functions from cramlib.h?

My bad.  I was reasoning in terms of my existing authProg, where the caller is 
greedy for tokenizing, like so:

if ((service = strtok(buf, "\n")) != NULL &&
        strcmp(service, "esmtp") == 0 &&
        (authtype = strtok(NULL, "\n")) != NULL &&
        (p1 = strtok(NULL, "\n")) != NULL &&
        (p2 = strtok(NULL, "\n")) != NULL)
{
        if (strcmp(authtype, "login") == 0)
                rtc = do_login(p1, p2);

        else if (strncmp(authtype, "cram-", 5) == 0)
                rtc = do_cram(authtype + 5, p1, p2);
// [...]

That extra tokenization can be easily removed.  Even if the authtype token is 
needed, e.g. to learn what type of cram the user chose, it can be examined upon 
return from auth_get_cram().

> The definition of hmac_hashinfo doesn't appear to need to be visible. The
> pointer to it will be initialized by auth_get_cram().

Correct.  In fact, my do_cram() becomes much shorter that way.

Ale

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
courier-users mailing list
courier-users@lists.sourceforge.net
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to