digest_parser.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * $Id$
  3. *
  4. * Digest credentials parser
  5. *
  6. * Copyright (C) 2001-2003 Fhg Fokus
  7. *
  8. * This file is part of ser, a free SIP server.
  9. *
  10. * ser is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version
  14. *
  15. * For a license to use the ser software under conditions
  16. * other than those described here, or to purchase support for this
  17. * software, please contact iptel.org by e-mail at the following addresses:
  18. * [email protected]
  19. *
  20. * ser is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  28. */
  29. #ifndef DIGEST_PARSER_H
  30. #define DIGEST_PARSER_H
  31. #include "../../str.h"
  32. /* Type of algorithm used */
  33. typedef enum alg {
  34. ALG_UNSPEC = 0, /* Algorithm parameter not specified */
  35. ALG_MD5 = 1, /* MD5 - default value*/
  36. ALG_MD5SESS = 2, /* MD5-Session */
  37. ALG_OTHER = 4 /* Unknown */
  38. } alg_t;
  39. /* Quality Of Protection used */
  40. typedef enum qop_type {
  41. QOP_UNSPEC = 0, /* QOP parameter not present in response */
  42. QOP_AUTH = 1, /* Authentication only */
  43. QOP_AUTHINT = 2, /* Authentication with integrity checks */
  44. QOP_OTHER = 4 /* Unknown */
  45. } qop_type_t;
  46. /* Algorithm structure */
  47. struct algorithm {
  48. str alg_str; /* The original string representation */
  49. alg_t alg_parsed; /* Parsed value */
  50. };
  51. /* QOP structure */
  52. struct qp {
  53. str qop_str; /* The original string representation */
  54. qop_type_t qop_parsed; /* Parsed value */
  55. };
  56. /*
  57. * Parsed digest credentials
  58. */
  59. typedef struct dig_cred {
  60. str username; /* Username */
  61. str realm; /* Realm */
  62. str nonce; /* Nonce value */
  63. str uri; /* URI */
  64. str response; /* Response string */
  65. str algorithm; /* Algorithm in string representation */
  66. struct algorithm alg; /* Type of algorithm used */
  67. str cnonce; /* Cnonce value */
  68. str opaque; /* Opaque data string */
  69. struct qp qop; /* Quality Of Protection */
  70. str nc; /* Nonce count parameter */
  71. } dig_cred_t;
  72. /*
  73. * Initialize a digest credentials structure
  74. */
  75. void init_dig_cred(dig_cred_t* _c);
  76. /*
  77. * We support Digest authentication only
  78. *
  79. * Returns:
  80. * 0 - if everything is OK
  81. * -1 - Error while parsing
  82. * 1 - Unknown scheme
  83. */
  84. int parse_digest_cred(str* _s, dig_cred_t* _c);
  85. #endif /* DIGEST_PARSER_H */