33 int key_len,
char **dest,
int *dest_len)
35 if (!strncmp(key,
"realm=", key_len)) {
37 *dest_len =
sizeof(state->
realm);
42 int key_len,
char **dest,
int *dest_len)
46 if (!strncmp(key,
"realm=", key_len)) {
48 *dest_len =
sizeof(state->
realm);
49 }
else if (!strncmp(key,
"nonce=", key_len)) {
50 *dest = digest->
nonce;
51 *dest_len =
sizeof(digest->
nonce);
52 }
else if (!strncmp(key,
"opaque=", key_len)) {
54 *dest_len =
sizeof(digest->
opaque);
55 }
else if (!strncmp(key,
"algorithm=", key_len)) {
58 }
else if (!strncmp(key,
"qop=", key_len)) {
60 *dest_len =
sizeof(digest->
qop);
61 }
else if (!strncmp(key,
"stale=", key_len)) {
62 *dest = digest->
stale;
63 *dest_len =
sizeof(digest->
stale);
68 int key_len,
char **dest,
int *dest_len)
72 if (!strncmp(key,
"nextnonce=", key_len)) {
73 *dest = digest->
nonce;
74 *dest_len =
sizeof(digest->
nonce);
80 char *ptr = strstr(qop,
"auth");
81 char *
end = ptr + strlen(
"auth");
83 if (ptr && (!*end || isspace(*end) || *end ==
',') &&
84 (ptr == qop || isspace(ptr[-1]) || ptr[-1] ==
',')) {
94 if (!strcmp(key,
"WWW-Authenticate") || !strcmp(key,
"Proxy-Authenticate")) {
116 }
else if (!strcmp(key,
"Authentication-Info")) {
127 va_start(vl, md5ctx);
129 const char* str = va_arg(vl,
const char*);
139 const char *password,
const char *uri,
144 uint32_t cnonce_buf[2];
148 char A1hash[33], A2hash[33], response[33];
149 struct AVMD5 *md5ctx;
157 for (i = 0; i < 2; i++)
160 cnonce[2*
sizeof(cnonce_buf)] = 0;
173 }
else if (!strcmp(digest->
algorithm,
"MD5-sess")) {
193 if (!strcmp(digest->
qop,
"auth") || !strcmp(digest->
qop,
"auth-int")) {
203 if (!strcmp(digest->
qop,
"") || !strcmp(digest->
qop,
"auth")) {
204 }
else if (!strcmp(digest->
qop,
"auth-int")) {
212 len = strlen(username) + strlen(state->
realm) + strlen(digest->
nonce) +
213 strlen(uri) + strlen(response) + strlen(digest->
algorithm) +
214 strlen(digest->
opaque) + strlen(digest->
qop) + strlen(cnonce) +
220 snprintf(authstr, len,
"Authorization: Digest ");
223 av_strlcatf(authstr, len,
"username=\"%s\"", username);
227 av_strlcatf(authstr, len,
",response=\"%s\"", response);
232 if (digest->
qop[0]) {
234 av_strlcatf(authstr, len,
",cnonce=\"%s\"", cnonce);
244 const char *path,
const char *method)
246 char *authstr =
NULL;
251 if (!auth || !strchr(auth,
':'))
255 int auth_b64_len,
len;
262 len = auth_b64_len + 30;
270 snprintf(authstr, len,
"Authorization: Basic ");
271 ptr = authstr + strlen(authstr);
273 av_strlcat(ptr,
"\r\n", len - (ptr - authstr));
281 if ((password = strchr(username,
':'))) {