* We support Digest authentication only * * Returns: * 0 - if everything is OK * -1 - Error while parsing * 1 - Unknown scheme */
| 400 | * 1 - Unknown scheme |
| 401 | */ |
| 402 | int 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 | /* |
no test coverage detected