[FFmpeg-devel] [PATCH] Add support for digest auth in the http and rtsp protocols

Martin Storsjö martin
Wed Mar 24 23:51:02 CET 2010


On Wed, 24 Mar 2010, Ronald S. Bultje wrote:

> On Wed, Mar 24, 2010 at 5:57 PM, Martin Storsj? <martin at martin.st> wrote:
> > +static void choose_qop(char *qop, int size)
> > +{
> > +    char chosen_qop[10] = "";
> > +    int chosen_qop_value = 0;
> > +    char *ptr = qop;
> > +    while (*ptr) {
> > +        char *token;
> > +        struct qop_type* type;
> > +
> > +        /* Skip whitespace and potential commas. */
> > +        while (*ptr && (isspace(*ptr) || *ptr == ','))
> > +            ptr++;
> > +        if (!*ptr)
> > +            break;
> > +        token = ptr;
> > +        /* Skip until whitespace or comma or end of string. */
> > +        while (*ptr && (!isspace(*ptr) && *ptr != ','))
> > +            ptr++;
> > +        if (*ptr) {
> > +            *ptr = '\0';
> > +            ptr++;
> > +        }
> > +        /* Use this qop type if it's better than the currently chosen one. */
> > +        for (type = supported_qop_types; type->name; type++) {
> > +            if (!strcmp(type->name, token) && type->value > chosen_qop_value) {
> > +                av_strlcpy(chosen_qop, token, sizeof(chosen_qop));
> > +                chosen_qop_value = type->value;
> > +            }
> > +        }
> > +    }
> > +    av_strlcpy(qop, chosen_qop, size);
> > +}
> > +
> 
> Maybe I'm looking at this in a too complex way, but this seems very
> much targeted at supporting, one day, other qop-types. For now, for
> simplicity-sake, I'd just say if ((res = strstr(qop_value,
> "wanted_qop_type")) && res+strlen(wanted_qop_type)==',' or 0 then OK
> else fail.
> 
> when we support other qop types, we can do this difficult function.

Ok, skipped this one, for now.

> > +/* Format a hexadecimal string. This absolutely must return lowercase
> > + * hex digits, since the returned strings are included in hash calculations.
> > + */
> > +static void format_hash(char *str, int len, const uint8_t *hash, int size)
> > +{
> > +    int i;
> > +    for (i = 0; i < size && 2*i < len; i++)
> > +        snprintf(&str[2*i], len - 2*i, "%02x", hash[i]);
> > +}
> 
> Can you add a int lowercase argument to ff_data_to_hex()? I think
> that'd remove two lines from rdt.c also.

Sure. Example of such a patch attached, together with the digest patch.

// Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-a-lowercase-parameter-to-ff_data_to_hex.patch
Type: text/x-diff
Size: 3191 bytes
Desc: 
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100325/f7020b14/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Add-support-for-http-digest-authentication.patch
Type: text/x-diff
Size: 10000 bytes
Desc: 
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100325/f7020b14/attachment-0001.patch>



More information about the ffmpeg-devel mailing list