00001 /* 00002 * $Id$ 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 00030 00031 #ifndef RFC2617_H 00032 #define RFC2617_H 00033 00034 #include "../../str.h" 00035 00036 00037 #define HASHLEN 16 00038 typedef char HASH[HASHLEN]; 00039 00040 00041 #define HASHHEXLEN 32 00042 typedef char HASHHEX[HASHHEXLEN+1]; 00043 00044 00045 /* 00046 * Type of algorithm used 00047 */ 00048 typedef enum { 00049 HA_MD5, /* Plain MD5 */ 00050 HA_MD5_SESS /* MD5-Session */ 00051 } ha_alg_t; 00052 00053 00054 /* 00055 * Convert to hex form 00056 */ 00057 void cvt_hex(HASH Bin, HASHHEX Hex); 00058 00059 00060 /* 00061 * calculate H(A1) as per HTTP Digest spec 00062 */ 00063 typedef void (*calc_HA1_t)(ha_alg_t _alg, /* Type of algorithm */ 00064 str* _username, /* username */ 00065 str* _realm, /* realm */ 00066 str* _password, /* password */ 00067 str* _nonce, /* nonce string */ 00068 str* _cnonce, /* cnonce */ 00069 HASHHEX _sess_key); /* Result will be stored here */ 00070 void calc_HA1(ha_alg_t _alg, /* Type of algorithm */ 00071 str* _username, /* username */ 00072 str* _realm, /* realm */ 00073 str* _password, /* password */ 00074 str* _nonce, /* nonce string */ 00075 str* _cnonce, /* cnonce */ 00076 HASHHEX _sess_key); /* Result will be stored here */ 00077 00078 00079 /* calculate request-digest/response-digest as per HTTP Digest spec */ 00080 typedef void (*calc_response_t)(HASHHEX _ha1, /* H(A1) */ 00081 str* _nonce, /* nonce from server */ 00082 str* _nc, /* 8 hex digits */ 00083 str* _cnonce, /* client nonce */ 00084 str* _qop, /* qop-value: "", "auth", "auth-int" */ 00085 int _auth_int, /* 1 if auth-int is used */ 00086 str* _method, /* method from the request */ 00087 str* _uri, /* requested URL */ 00088 HASHHEX _hentity, /* H(entity body) if qop="auth-int" */ 00089 HASHHEX _response); /* request-digest or response-digest */ 00090 void calc_response(HASHHEX _ha1, /* H(A1) */ 00091 str* _nonce, /* nonce from server */ 00092 str* _nc, /* 8 hex digits */ 00093 str* _cnonce, /* client nonce */ 00094 str* _qop, /* qop-value: "", "auth", "auth-int" */ 00095 int _auth_int, /* 1 if auth-int is used */ 00096 str* _method, /* method from the request */ 00097 str* _uri, /* requested URL */ 00098 HASHHEX _hentity, /* H(entity body) if qop="auth-int" */ 00099 HASHHEX _response); /* request-digest or response-digest */ 00100 00101 00102 #endif /* RFC2617_H */
1.7.1