Go to the documentation of this file.
31 int key_len,
char **dest,
int *dest_len)
33 if (!strncmp(
key,
"realm=", key_len)) {
35 *dest_len =
sizeof(
state->realm);
40 int key_len,
char **dest,
int *dest_len)
44 if (!strncmp(
key,
"realm=", key_len)) {
46 *dest_len =
sizeof(
state->realm);
47 }
else if (!strncmp(
key,
"nonce=", key_len)) {
48 *dest = digest->
nonce;
49 *dest_len =
sizeof(digest->
nonce);
50 }
else if (!strncmp(
key,
"opaque=", key_len)) {
52 *dest_len =
sizeof(digest->
opaque);
53 }
else if (!strncmp(
key,
"algorithm=", key_len)) {
56 }
else if (!strncmp(
key,
"qop=", key_len)) {
58 *dest_len =
sizeof(digest->
qop);
59 }
else if (!strncmp(
key,
"stale=", key_len)) {
60 *dest = digest->
stale;
61 *dest_len =
sizeof(digest->
stale);
66 int key_len,
char **dest,
int *dest_len)
70 if (!strncmp(
key,
"nextnonce=", key_len)) {
71 *dest = digest->
nonce;
72 *dest_len =
sizeof(digest->
nonce);
78 char *ptr = strstr(qop,
"auth");
79 char *end = ptr + strlen(
"auth");
81 if (ptr && (!*end ||
av_isspace(*end) || *end ==
',') &&
82 (ptr == qop ||
av_isspace(ptr[-1]) || ptr[-1] ==
',')) {
110 sizeof(
state->digest_params.qop));
125 va_start(vl, md5ctx);
127 const char* str = va_arg(vl,
const char*);
137 const char *password,
const char *uri,
142 uint32_t cnonce_buf[2];
146 char A1hash[33], A2hash[33], response[33];
147 struct AVMD5 *md5ctx;
155 for (
i = 0;
i < 2;
i++)
157 ff_data_to_hex(cnonce, (
const uint8_t*) cnonce_buf,
sizeof(cnonce_buf), 1);
169 }
else if (!strcmp(digest->
algorithm,
"MD5-sess")) {
187 if (!strcmp(digest->
qop,
"auth") || !strcmp(digest->
qop,
"auth-int")) {
196 if (!strcmp(digest->
qop,
"") || !strcmp(digest->
qop,
"auth")) {
197 }
else if (!strcmp(digest->
qop,
"auth-int")) {
205 len = strlen(username) + strlen(
state->realm) + strlen(digest->
nonce) +
206 strlen(uri) + strlen(response) + strlen(digest->
algorithm) +
207 strlen(digest->
opaque) + strlen(digest->
qop) + strlen(cnonce) +
228 if (digest->
qop[0]) {
240 const char *path,
const char *method)
242 char *authstr =
NULL;
247 if (!auth || !strchr(auth,
':'))
251 int auth_b64_len,
len;
258 len = auth_b64_len + 30;
267 ptr = authstr + strlen(authstr);
277 if ((password = strchr(username,
':'))) {
@ HTTP_AUTH_BASIC
HTTP 1.0 Basic auth from RFC 1945 (also in RFC 2617)
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
static char * make_digest_auth(HTTPAuthState *state, const char *username, const char *password, const char *uri, const char *method)
static void update_md5_strings(struct AVMD5 *md5ctx,...)
char * ff_http_auth_create_response(HTTPAuthState *state, const char *auth, const char *path, const char *method)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
char * ff_urldecode(const char *url, int decode_plus_sign)
Decodes an URL from its percent-encoded form back into normal representation.
char qop[30]
Quality of protection, containing the one that we've chosen to use, from the alternatives that the se...
@ HTTP_AUTH_DIGEST
HTTP 1.1 Digest auth from RFC 2617.
int av_stristart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str independent of case.
void ff_http_auth_handle_header(HTTPAuthState *state, const char *key, const char *value)
static void handle_digest_params(HTTPAuthState *state, const char *key, int key_len, char **dest, int *dest_len)
char nonce[300]
Server specified nonce.
static void choose_qop(char *qop, int size)
HTTP Authentication state structure.
char stale[10]
The server indicated that the auth was ok, but needs to be redone with a new, non-stale nonce.
static void handle_digest_update(HTTPAuthState *state, const char *key, int key_len, char **dest, int *dest_len)
void av_md5_init(AVMD5 *ctx)
Initialize MD5 hashing.
#define AV_BASE64_SIZE(x)
Calculate the output size needed to base64-encode x bytes to a null-terminated string.
#define i(width, name, range_min, range_max)
static void handle_basic_params(HTTPAuthState *state, const char *key, int key_len, char **dest, int *dest_len)
char opaque[300]
A server-specified string that should be included in authentication responses, not included in the ac...
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
void av_md5_final(AVMD5 *ctx, uint8_t *dst)
Finish hashing and output digest value.
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes,...
int nc
Nonce count, the number of earlier replies where this particular nonce has been used.
struct AVMD5 * av_md5_alloc(void)
Allocate an AVMD5 context.
char * av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size)
Encode data to base64 and null-terminate.
void av_md5_update(AVMD5 *ctx, const uint8_t *src, size_t len)
Update hash value.
char algorithm[10]
Server specified digest algorithm.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.