MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / parse_digest_cred

Function parse_digest_cred

parser/digest/digest_parser.c:402–440  ·  view source on GitHub ↗

* We support Digest authentication only * * Returns: * 0 - if everything is OK * -1 - Error while parsing * 1 - Unknown scheme */

Source from the content-addressed store, hash-verified

400 * 1 - Unknown scheme
401 */
402int parse_digest_cred(str* _s, dig_cred_t* _c)
403{
404 str tmp;
405
406 /* Make a temporary copy, we are
407 * going to modify it
408 */
409 tmp.s = _s->s;
410 tmp.len = _s->len;
411
412 /* Remove any leading spaces, tabs, \r and \n */
413 trim_leading(&tmp);
414
415 /* Check the string length */
416 if (tmp.len < (DIG_LEN + 1)) return 1; /* Too short, unknown scheme */
417
418 /* Now test, if it is digest scheme, since it is the only
419 * scheme we are able to parse here
420 */
421 if (turbo_casematch(tmp.s, DIGEST_SCHEME, DIG_LEN) &&
422 /* Test for one of LWS chars + ',' */
423 (is_ws(tmp.s[DIG_LEN]) || (tmp.s[DIG_LEN] == ','))) {
424 /* Scheme is Digest */
425 tmp.s += DIG_LEN + 1;
426 tmp.len -= DIG_LEN + 1;
427
428 /* Again, skip all white-spaces */
429 trim_leading(&tmp);
430
431 /* And parse digest parameters */
432 if (parse_digest_params(&tmp, _c) < 0) {
433 return -2; /* We must not return -1 in this function ! */
434 } else {
435 return 0;
436 }
437 } else {
438 return 1; /* Unknown scheme */
439 }
440}
441
442
443/*

Callers 1

parse_credentialsFunction · 0.85

Calls 4

trim_leadingFunction · 0.85
turbo_casematchFunction · 0.85
is_wsFunction · 0.85
parse_digest_paramsFunction · 0.85

Tested by

no test coverage detected