32 int key_len,
char **dest,
int *dest_len)
34 if (!strncmp(key,
"realm=", key_len)) {
36 *dest_len =
sizeof(state->
realm);
41 int key_len,
char **dest,
int *dest_len)
45 if (!strncmp(key,
"realm=", key_len)) {
47 *dest_len =
sizeof(state->
realm);
48 }
else if (!strncmp(key,
"nonce=", key_len)) {
49 *dest = digest->
nonce;
50 *dest_len =
sizeof(digest->
nonce);
51 }
else if (!strncmp(key,
"opaque=", key_len)) {
53 *dest_len =
sizeof(digest->
opaque);
54 }
else if (!strncmp(key,
"algorithm=", key_len)) {
57 }
else if (!strncmp(key,
"qop=", key_len)) {
59 *dest_len =
sizeof(digest->
qop);
60 }
else if (!strncmp(key,
"stale=", key_len)) {
61 *dest = digest->
stale;
62 *dest_len =
sizeof(digest->
stale);
67 int key_len,
char **dest,
int *dest_len)
71 if (!strncmp(key,
"nextnonce=", key_len)) {
72 *dest = digest->
nonce;
73 *dest_len =
sizeof(digest->
nonce);
79 char *ptr = strstr(qop,
"auth");
80 char *
end = ptr + strlen(
"auth");
82 if (ptr && (!*end ||
av_isspace(*end) || *end ==
',') &&
83 (ptr == qop ||
av_isspace(ptr[-1]) || ptr[-1] ==
',')) {
93 if (!strcmp(key,
"WWW-Authenticate") || !strcmp(key,
"Proxy-Authenticate")) {
115 }
else if (!strcmp(key,
"Authentication-Info")) {
126 va_start(vl, md5ctx);
128 const char* str = va_arg(vl,
const char*);
138 const char *password,
const char *uri,
143 uint32_t cnonce_buf[2];
147 char A1hash[33], A2hash[33], response[33];
148 struct AVMD5 *md5ctx;
156 for (i = 0; i < 2; i++)
159 cnonce[2*
sizeof(cnonce_buf)] = 0;
172 }
else if (!strcmp(digest->
algorithm,
"MD5-sess")) {
192 if (!strcmp(digest->
qop,
"auth") || !strcmp(digest->
qop,
"auth-int")) {
202 if (!strcmp(digest->
qop,
"") || !strcmp(digest->
qop,
"auth")) {
203 }
else if (!strcmp(digest->
qop,
"auth-int")) {
211 len = strlen(username) + strlen(state->
realm) + strlen(digest->
nonce) +
212 strlen(uri) + strlen(response) + strlen(digest->
algorithm) +
213 strlen(digest->
opaque) + strlen(digest->
qop) + strlen(cnonce) +
219 snprintf(authstr, len,
"Authorization: Digest ");
222 av_strlcatf(authstr, len,
"username=\"%s\"", username);
226 av_strlcatf(authstr, len,
",response=\"%s\"", response);
231 if (digest->
qop[0]) {
233 av_strlcatf(authstr, len,
",cnonce=\"%s\"", cnonce);
243 const char *path,
const char *method)
245 char *authstr = NULL;
250 if (!auth || !strchr(auth,
':'))
254 int auth_b64_len,
len;
261 len = auth_b64_len + 30;
269 snprintf(authstr, len,
"Authorization: Basic ");
270 ptr = authstr + strlen(authstr);
272 av_strlcat(ptr,
"\r\n", len - (ptr - authstr));
280 if ((password = strchr(username,
':'))) {