rfc2617.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * $Id$
  3. *
  4. * Digest response calculation as per RFC2617
  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  28. */
  29. #ifndef RFC2617_H
  30. #define RFC2617_H
  31. #include "../../str.h"
  32. #define HASHLEN 16
  33. typedef char HASH[HASHLEN];
  34. #define HASHHEXLEN 32
  35. typedef char HASHHEX[HASHHEXLEN+1];
  36. /*
  37. * Type of algorithm used
  38. */
  39. typedef enum {
  40. HA_MD5, /* Plain MD5 */
  41. HA_MD5_SESS /* MD5-Session */
  42. } ha_alg_t;
  43. /*
  44. * Convert to hex form
  45. */
  46. void cvt_hex(HASH Bin, HASHHEX Hex);
  47. /*
  48. * calculate H(A1) as per HTTP Digest spec
  49. */
  50. typedef void (*calc_HA1_t)(ha_alg_t _alg, /* Type of algorithm */
  51. str* _username, /* username */
  52. str* _realm, /* realm */
  53. str* _password, /* password */
  54. str* _nonce, /* nonce string */
  55. str* _cnonce, /* cnonce */
  56. HASHHEX _sess_key); /* Result will be stored here */
  57. void calc_HA1(ha_alg_t _alg, /* Type of algorithm */
  58. str* _username, /* username */
  59. str* _realm, /* realm */
  60. str* _password, /* password */
  61. str* _nonce, /* nonce string */
  62. str* _cnonce, /* cnonce */
  63. HASHHEX _sess_key); /* Result will be stored here */
  64. /* calculate request-digest/response-digest as per HTTP Digest spec */
  65. typedef void (*calc_response_t)(HASHHEX _ha1, /* H(A1) */
  66. str* _nonce, /* nonce from server */
  67. str* _nc, /* 8 hex digits */
  68. str* _cnonce, /* client nonce */
  69. str* _qop, /* qop-value: "", "auth", "auth-int" */
  70. int _auth_int, /* 1 if auth-int is used */
  71. str* _method, /* method from the request */
  72. str* _uri, /* requested URL */
  73. HASHHEX _hentity, /* H(entity body) if qop="auth-int" */
  74. HASHHEX _response); /* request-digest or response-digest */
  75. void calc_response(HASHHEX _ha1, /* H(A1) */
  76. str* _nonce, /* nonce from server */
  77. str* _nc, /* 8 hex digits */
  78. str* _cnonce, /* client nonce */
  79. str* _qop, /* qop-value: "", "auth", "auth-int" */
  80. int _auth_int, /* 1 if auth-int is used */
  81. str* _method, /* method from the request */
  82. str* _uri, /* requested URL */
  83. HASHHEX _hentity, /* H(entity body) if qop="auth-int" */
  84. HASHHEX _response); /* request-digest or response-digest */
  85. #endif /* RFC2617_H */