rfc2617.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2012 Smile Communications, [email protected]
  5. * Copyright (C) 2012 Smile Communications, [email protected]
  6. *
  7. * The initial version of this code was written by Dragos Vingarzan
  8. * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  9. * Fruanhofer Institute. It was and still is maintained in a separate
  10. * branch of the original SER. We are therefore migrating it to
  11. * Kamailio/SR and look forward to maintaining it from here on out.
  12. * 2011/2012 Smile Communications, Pty. Ltd.
  13. * ported/maintained/improved by
  14. * Jason Penton (jason(dot)penton(at)smilecoms.com and
  15. * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  16. * effort to add full IMS support to Kamailio/SR using a new and
  17. * improved architecture
  18. *
  19. * NB: Alot of this code was originally part of OpenIMSCore,
  20. * FhG Fokus.
  21. * Copyright (C) 2004-2006 FhG Fokus
  22. * Thanks for great work! This is an effort to
  23. * break apart the various CSCF functions into logically separate
  24. * components. We hope this will drive wider use. We also feel
  25. * that in this way the architecture is more complete and thereby easier
  26. * to manage in the Kamailio/SR environment
  27. *
  28. * This file is part of Kamailio, a free SIP server.
  29. *
  30. * Kamailio is free software; you can redistribute it and/or modify
  31. * it under the terms of the GNU General Public License as published by
  32. * the Free Software Foundation; either version 2 of the License, or
  33. * (at your option) any later version
  34. *
  35. * Kamailio is distributed in the hope that it will be useful,
  36. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  37. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  38. * GNU General Public License for more details.
  39. *
  40. * You should have received a copy of the GNU General Public License
  41. * along with this program; if not, write to the Free Software
  42. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  43. *
  44. */
  45. #ifndef RFC2617_H
  46. #define RFC2617_H
  47. #include "../../str.h"
  48. #define HASHLEN 16
  49. typedef char HASH[HASHLEN];
  50. #define HASHHEXLEN 32
  51. typedef char HASHHEX[HASHHEXLEN+1];
  52. /*
  53. * Type of algorithm used
  54. */
  55. typedef enum {
  56. HA_MD5, /* Plain MD5 */
  57. HA_MD5_SESS, /* MD5-Session */
  58. } ha_alg_t;
  59. /*
  60. * Convert to hex form
  61. */
  62. void cvt_hex(HASH Bin, HASHHEX Hex);
  63. /*
  64. * calculate H(A1) as per HTTP Digest spec
  65. */
  66. typedef void (*calc_HA1_t)(ha_alg_t _alg, /* Type of algorithm */
  67. str* _username, /* username */
  68. str* _realm, /* realm */
  69. str* _password, /* password */
  70. str* _nonce, /* nonce string */
  71. str* _cnonce, /* cnonce */
  72. HASHHEX _sess_key); /* Result will be stored here */
  73. void calc_HA1(ha_alg_t _alg, /* Type of algorithm */
  74. str* _username, /* username */
  75. str* _realm, /* realm */
  76. str* _password, /* password */
  77. str* _nonce, /* nonce string */
  78. str* _cnonce, /* cnonce */
  79. HASHHEX _sess_key); /* Result will be stored here */
  80. void calc_H(str *ent, HASHHEX hash);
  81. /* calculate request-digest/response-digest as per HTTP Digest spec */
  82. typedef void (*calc_response_t)(HASHHEX _ha1, /* H(A1) */
  83. str* _nonce, /* nonce from server */
  84. str* _nc, /* 8 hex digits */
  85. str* _cnonce, /* client nonce */
  86. str* _qop, /* qop-value: "", "auth", "auth-int" */
  87. int _auth_int, /* 1 if auth-int is used */
  88. str* _method, /* method from the request */
  89. str* _uri, /* requested URL */
  90. HASHHEX _hentity, /* H(entity body) if qop="auth-int" */
  91. HASHHEX _response); /* request-digest or response-digest */
  92. void calc_response(HASHHEX _ha1, /* H(A1) */
  93. str* _nonce, /* nonce from server */
  94. str* _nc, /* 8 hex digits */
  95. str* _cnonce, /* client nonce */
  96. str* _qop, /* qop-value: "", "auth", "auth-int" */
  97. int _auth_int, /* 1 if auth-int is used */
  98. str* _method, /* method from the request */
  99. str* _uri, /* requested URL */
  100. HASHHEX _hentity, /* H(entity body) if qop="auth-int" */
  101. HASHHEX _response); /* request-digest or response-digest */
  102. #endif /* RFC2617_H */