00001 /* 00002 * $Id: rfc2617.h 570 2008-06-25 13:21:32Z vingarzan $ 00003 * 00004 * Digest response calculation as per RFC2617 00005 * 00006 * Copyright (C) 2001-2003 FhG Fokus 00007 * 00008 * This file is part of ser, a free SIP server. 00009 * 00010 * ser is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version 00014 * 00015 * For a license to use the ser software under conditions 00016 * other than those described here, or to purchase support for this 00017 * software, please contact iptel.org by e-mail at the following addresses: 00018 * info@iptel.org 00019 * 00020 * ser is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * You should have received a copy of the GNU General Public License 00026 * along with this program; if not, write to the Free Software 00027 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00028 */ 00029 00039 #ifndef RFC2617_H 00040 #define RFC2617_H 00041 00042 #include "../../str.h" 00043 00044 00045 #define HASHLEN 16 00046 typedef char HASH[HASHLEN]; 00047 00048 00049 #define HASHHEXLEN 32 00050 typedef char HASHHEX[HASHHEXLEN+1]; 00051 00052 00053 /* 00054 * Type of algorithm used 00055 */ 00056 typedef enum { 00057 HA_MD5, /* Plain MD5 */ 00058 HA_MD5_SESS, /* MD5-Session */ 00059 } ha_alg_t; 00060 00061 00062 /* 00063 * Convert to hex form 00064 */ 00065 void cvt_hex(HASH Bin, HASHHEX Hex); 00066 00067 00068 /* 00069 * calculate H(A1) as per HTTP Digest spec 00070 */ 00071 void calc_HA1(ha_alg_t _alg, /* Type of algorithm */ 00072 str* _username, /* username */ 00073 str* _realm, /* realm */ 00074 str* _password, /* password */ 00075 str* _nonce, /* nonce string */ 00076 str* _cnonce, /* cnonce */ 00077 HASHHEX _sess_key); /* Result will be stored here */ 00078 00079 void calc_H(str *ent, HASHHEX hash); 00080 00081 /* calculate request-digest/response-digest as per HTTP Digest spec */ 00082 void calc_response(HASHHEX _ha1, /* H(A1) */ 00083 str* _nonce, /* nonce from server */ 00084 str* _nc, /* 8 hex digits */ 00085 str* _cnonce, /* client nonce */ 00086 str* _qop, /* qop-value: "", "auth", "auth-int" */ 00087 int _auth_int, /* 1 if auth-int is used */ 00088 str* _method, /* method from the request */ 00089 str* _uri, /* requested URL */ 00090 HASHHEX _hentity, /* H(entity body) if qop="auth-int" */ 00091 HASHHEX _response); /* request-digest or response-digest */ 00092 00093 00094 #endif /* RFC2617_H */
1.5.2