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

Ronald S. Bultje rsbultje
Wed Mar 24 23:11:25 CET 2010


Hi,

On Wed, Mar 24, 2010 at 5:57 PM, Martin Storsj? <martin at martin.st> wrote:
> New versions of #1 and #2 attached.

I suggested some minor changes to #1 on IRC, OK otherwise.

now for #2:

> +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.

> +/* 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.

Ronald



More information about the ffmpeg-devel mailing list