NetServices Stack source
Dependents: HelloWorld ServoInterfaceBoardExample1 4180_Lab4
chap.h
00001 /***************************************************************************** 00002 * chap.h - Network Challenge Handshake Authentication Protocol header file. 00003 * 00004 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 00005 * portions Copyright (c) 1998 Global Election Systems Inc. 00006 * 00007 * The authors hereby grant permission to use, copy, modify, distribute, 00008 * and license this software and its documentation for any purpose, provided 00009 * that existing copyright notices are retained in all copies and that this 00010 * notice and the following disclaimer are included verbatim in any 00011 * distributions. No written agreement, license, or royalty fee is required 00012 * for any of the authorized uses. 00013 * 00014 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 00015 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00017 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00019 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00020 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00021 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00023 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 * 00025 ****************************************************************************** 00026 * REVISION HISTORY 00027 * 00028 * 03-01-01 Marc Boucher <marc@mbsi.ca> 00029 * Ported to lwIP. 00030 * 97-12-03 Guy Lancaster <lancasterg@acm.org>, Global Election Systems Inc. 00031 * Original built from BSD network code. 00032 ******************************************************************************/ 00033 /* 00034 * chap.h - Challenge Handshake Authentication Protocol definitions. 00035 * 00036 * Copyright (c) 1993 The Australian National University. 00037 * All rights reserved. 00038 * 00039 * Redistribution and use in source and binary forms are permitted 00040 * provided that the above copyright notice and this paragraph are 00041 * duplicated in all such forms and that any documentation, 00042 * advertising materials, and other materials related to such 00043 * distribution and use acknowledge that the software was developed 00044 * by the Australian National University. The name of the University 00045 * may not be used to endorse or promote products derived from this 00046 * software without specific prior written permission. 00047 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 00048 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 00049 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00050 * 00051 * Copyright (c) 1991 Gregory M. Christy 00052 * All rights reserved. 00053 * 00054 * Redistribution and use in source and binary forms are permitted 00055 * provided that the above copyright notice and this paragraph are 00056 * duplicated in all such forms and that any documentation, 00057 * advertising materials, and other materials related to such 00058 * distribution and use acknowledge that the software was developed 00059 * by the author. 00060 * 00061 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 00062 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 00063 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00064 * 00065 * $Id: chap.h,v 1.6 2010/01/24 13:19:34 goldsimon Exp $ 00066 */ 00067 00068 #ifndef CHAP_H 00069 #define CHAP_H 00070 00071 /* Code + ID + length */ 00072 #define CHAP_HEADERLEN 4 00073 00074 /* 00075 * CHAP codes. 00076 */ 00077 00078 #define CHAP_DIGEST_MD5 5 /* use MD5 algorithm */ 00079 #define MD5_SIGNATURE_SIZE 16 /* 16 bytes in a MD5 message digest */ 00080 #define CHAP_MICROSOFT 0x80 /* use Microsoft-compatible alg. */ 00081 #define MS_CHAP_RESPONSE_LEN 49 /* Response length for MS-CHAP */ 00082 00083 #define CHAP_CHALLENGE 1 00084 #define CHAP_RESPONSE 2 00085 #define CHAP_SUCCESS 3 00086 #define CHAP_FAILURE 4 00087 00088 /* 00089 * Challenge lengths (for challenges we send) and other limits. 00090 */ 00091 #define MIN_CHALLENGE_LENGTH 32 00092 #define MAX_CHALLENGE_LENGTH 64 00093 #define MAX_RESPONSE_LENGTH 64 /* sufficient for MD5 or MS-CHAP */ 00094 00095 /* 00096 * Each interface is described by a chap structure. 00097 */ 00098 00099 typedef struct chap_state { 00100 int unit; /* Interface unit number */ 00101 int clientstate; /* Client state */ 00102 int serverstate; /* Server state */ 00103 u_char challenge[MAX_CHALLENGE_LENGTH]; /* last challenge string sent */ 00104 u_char chal_len; /* challenge length */ 00105 u_char chal_id; /* ID of last challenge */ 00106 u_char chal_type; /* hash algorithm for challenges */ 00107 u_char id; /* Current id */ 00108 char *chal_name; /* Our name to use with challenge */ 00109 int chal_interval; /* Time until we challenge peer again */ 00110 int timeouttime; /* Timeout time in seconds */ 00111 int max_transmits; /* Maximum # of challenge transmissions */ 00112 int chal_transmits; /* Number of transmissions of challenge */ 00113 int resp_transmits; /* Number of transmissions of response */ 00114 u_char response[MAX_RESPONSE_LENGTH]; /* Response to send */ 00115 u_char resp_length; /* length of response */ 00116 u_char resp_id; /* ID for response messages */ 00117 u_char resp_type; /* hash algorithm for responses */ 00118 char *resp_name; /* Our name to send with response */ 00119 } chap_state; 00120 00121 00122 /* 00123 * Client (peer) states. 00124 */ 00125 #define CHAPCS_INITIAL 0 /* Lower layer down, not opened */ 00126 #define CHAPCS_CLOSED 1 /* Lower layer up, not opened */ 00127 #define CHAPCS_PENDING 2 /* Auth us to peer when lower up */ 00128 #define CHAPCS_LISTEN 3 /* Listening for a challenge */ 00129 #define CHAPCS_RESPONSE 4 /* Sent response, waiting for status */ 00130 #define CHAPCS_OPEN 5 /* We've received Success */ 00131 00132 /* 00133 * Server (authenticator) states. 00134 */ 00135 #define CHAPSS_INITIAL 0 /* Lower layer down, not opened */ 00136 #define CHAPSS_CLOSED 1 /* Lower layer up, not opened */ 00137 #define CHAPSS_PENDING 2 /* Auth peer when lower up */ 00138 #define CHAPSS_INITIAL_CHAL 3 /* We've sent the first challenge */ 00139 #define CHAPSS_OPEN 4 /* We've sent a Success msg */ 00140 #define CHAPSS_RECHALLENGE 5 /* We've sent another challenge */ 00141 #define CHAPSS_BADAUTH 6 /* We've sent a Failure msg */ 00142 00143 extern chap_state chap[]; 00144 00145 void ChapAuthWithPeer (int, char *, u_char); 00146 void ChapAuthPeer (int, char *, u_char); 00147 00148 extern struct protent chap_protent; 00149 00150 #endif /* CHAP_H */
Generated on Tue Jul 12 2022 11:52:56 by
![doxygen](doxygen.png)