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

Martin Storsjö martin
Wed Mar 24 20:34:48 CET 2010


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

> On Tue, Mar 23, 2010 at 12:36 PM, Martin Storsj? <martin at martin.st> wrote:
> [..]
> 
> > +        char *username = av_strdup(auth);
> > +        char *password = NULL;
> > +        char *ptr;
> > +
> > +        if (!username)
> > +            return NULL;
> > +
> > +        ptr = strchr(username, ':');
> > +        if (ptr) {
> > +            *ptr = '\0';
> > +            password = ptr + 1;
> > +        }
> 
> char *username = av_strdup(), *password;
> if ((password = strchr(username, ':')))
>     *password++ = 0;

Nice simplification, done.

> > +typedef struct {
> > +    char realm[200];
> > +    char nonce[300];
> > +    char algorithm[10];
> > +    char qop[10];
> > +    char opaque[300];
> > +    int nc;
> > +} DigestParams;
> 
> realm is not digest-specific, as said in #1-review. Rest should be documented.

Documented the rest, will move the realm.

> > +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]);
> > +}
> 
> Is this ff_data_to_hex()?

Almost, but not exactly. ff_data_to_hex writes hex in uppercase, this in 
lower case, and the output from these are used in later hashes, so the 
case does matter. Nevertheless, it's quite a generic routine that perhaps 
belongs in some common file.

// Martin



More information about the ffmpeg-devel mailing list