00001 /* 00002 * $Id: rfc2617.h 2 2005-06-13 16:47:24Z bogdan_iancu $ 00003 * 00004 * Copyright (C) 2001-2003 FhG Fokus 00005 * 00006 * This file is part of Kamailio, a free SIP server. 00007 * 00008 * Kamailio is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version 00012 * 00013 * Kamailio is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 /*! 00024 * \file 00025 * \brief Digest response calculation as per RFC2617 00026 * \ingroup auth 00027 * - Module: \ref auth 00028 */ 00029 00030 #ifndef RFC2617_H 00031 #define RFC2617_H 00032 00033 #include "../../str.h" 00034 00035 00036 #define HASHLEN 16 00037 typedef char HASH[HASHLEN]; 00038 00039 00040 #define HASHHEXLEN 32 00041 typedef char HASHHEX[HASHHEXLEN+1]; 00042 00043 00044 /*! Type of algorithm used */ 00045 typedef enum { 00046 HA_MD5, /*!< Plain MD5 */ 00047 HA_MD5_SESS, /*!< MD5-Session */ 00048 } ha_alg_t; 00049 00050 00051 /*! 00052 * \brief Convert to hex form 00053 * \param _b hash value 00054 * \param _h hex value 00055 */ 00056 void cvt_hex(HASH _b, HASHHEX _h); 00057 00058 00059 /*! 00060 * \brief Calculate H(A1) as per HTTP Digest spec 00061 * \param _alg type of hash algorithm 00062 * \param _username username 00063 * \param _realm authentification realm 00064 * \param _password password 00065 * \param _nonce nonce value 00066 * \param _cnonce cnonce value 00067 * \param _sess_key session key, result will be stored there 00068 */ 00069 void calc_HA1(ha_alg_t _alg, str* _username, str* _realm, 00070 str* _password, str* _nonce, str* _cnonce, 00071 HASHHEX _sess_key); 00072 00073 00074 /*! 00075 * \brief Calculate request-digest/response-digest as per HTTP Digest spec 00076 * \param _ha1 H(A1) 00077 * \param _nonce nonce from server 00078 * \param _nc 8 hex digits 00079 * \param _cnonce 00080 * \param _qop qop-value: "", "auth", "auth-int 00081 * \param _auth_int 1 if auth-int is used 00082 * \param _method method from the request 00083 * \param _uri requested URL/ URI 00084 * \param _hentity H(entity body) if qop="auth-int" 00085 * \param _response request-digest or response-digest 00086 */ 00087 void calc_response(HASHHEX _ha1, str* _nonce, str* _nc, str* _cnonce, 00088 str* _qop, int _auth_int, str* _method, str* _uri, 00089 HASHHEX _hentity, HASHHEX _response); 00090 00091 00092 #endif
1.5.6