Newer
Older
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
} else if (!strcasecmp(key, "nonce")) {
ast_string_field_set(d, nonce, val);
} else if (!strcasecmp(key, "uri")) {
ast_string_field_set(d, uri, val);
} else if (!strcasecmp(key, "domain")) {
ast_string_field_set(d, domain, val);
} else if (!strcasecmp(key, "response")) {
ast_string_field_set(d, response, val);
} else if (!strcasecmp(key, "algorithm")) {
if (strcasecmp(val, "MD5")) {
ast_log(LOG_WARNING, "Digest algorithm: \"%s\" not supported.\n", val);
return -1;
}
} else if (!strcasecmp(key, "cnonce")) {
ast_string_field_set(d, cnonce, val);
} else if (!strcasecmp(key, "opaque")) {
ast_string_field_set(d, opaque, val);
} else if (!strcasecmp(key, "qop") && !strcasecmp(val, "auth")) {
d->qop = 1;
} else if (!strcasecmp(key, "nc")) {
unsigned long u;
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
ast_log(LOG_WARNING, "Incorrect Digest nc value: \"%s\".\n", val);
return -1;
}
ast_string_field_set(d, nc, val);
}
}
ast_free(str);
/* Digest checkout */
if (ast_strlen_zero(d->realm) || ast_strlen_zero(d->nonce)) {
/* "realm" and "nonce" MUST be always exist */
return -1;
}
if (!request) {
/* Additional check for Digest response */
if (ast_strlen_zero(d->username) || ast_strlen_zero(d->uri) || ast_strlen_zero(d->response)) {
return -1;
}
if (pedantic && d->qop && (ast_strlen_zero(d->cnonce) || ast_strlen_zero(d->nc))) {
return -1;
}
}
return 0;
}
#ifndef __AST_DEBUG_MALLOC
int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...)
{
int res;
va_list ap;
va_start(ap, fmt);
if ((res = vasprintf(ret, fmt, ap)) == -1) {
MALLOC_FAILURE_MSG;
}
va_end(ap);
return res;
}
#endif