00001 /* 00002 * $Id: nonce.h 5299 2008-12-04 18:12:33Z henningw $ 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 Nonce related functions 00026 * \ingroup auth 00027 * - Module: \ref auth 00028 */ 00029 00030 #ifndef NONCE_H 00031 #define NONCE_H 00032 00033 #include "../../str.h" 00034 #include <time.h> 00035 00036 00037 /*! Length of nonce string in bytes */ 00038 #define NONCE_LEN (16+32) 00039 00040 00041 /*! 00042 * \brief Calculate nonce value 00043 * 00044 * Calculate nonce value value. The nonce value consists of the 00045 * expires time (in seconds since 1.1 1970) and a secret phrase. 00046 * \param _nonce nonce value 00047 * \param _expires expires value 00048 * \param _index nonce index 00049 * \param _secret secret phrase 00050 */ 00051 void calc_nonce(char* _nonce, int _expires, int _index, str* _secret); 00052 00053 00054 /*! 00055 * \brief Check nonce value received from user agent 00056 * \param _nonce nonce value 00057 * \param _secret secret phrase 00058 * \return 0 when nonce is valid, -1 on errors, positive if nonce not valid 00059 */ 00060 int check_nonce(str* _nonce, str* _secret); 00061 00062 00063 /*! 00064 * \brief Get index from nonce string 00065 * \param _n nonce string 00066 * \return nonce index 00067 */ 00068 int get_nonce_index(str* _nonce); 00069 00070 /*! 00071 * \brief Check if a nonce is stale 00072 * \param _n nonce string 00073 * \return 1 if the nonce is stale, 0 otherwise 00074 */ 00075 int is_nonce_stale(str* _nonce); 00076 00077 #endif
1.5.6