Dependents:   RTnoV3 RTnoV3_LED RTnoV3_Template RTnoV3_ADC ... more

Committer:
sherckuith
Date:
Sat Dec 31 11:25:27 2011 +0000
Revision:
0:479ce5546098
Ethernet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sherckuith 0:479ce5546098 1 /*****************************************************************************
sherckuith 0:479ce5546098 2 * chap.h - Network Challenge Handshake Authentication Protocol header file.
sherckuith 0:479ce5546098 3 *
sherckuith 0:479ce5546098 4 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
sherckuith 0:479ce5546098 5 * portions Copyright (c) 1998 Global Election Systems Inc.
sherckuith 0:479ce5546098 6 *
sherckuith 0:479ce5546098 7 * The authors hereby grant permission to use, copy, modify, distribute,
sherckuith 0:479ce5546098 8 * and license this software and its documentation for any purpose, provided
sherckuith 0:479ce5546098 9 * that existing copyright notices are retained in all copies and that this
sherckuith 0:479ce5546098 10 * notice and the following disclaimer are included verbatim in any
sherckuith 0:479ce5546098 11 * distributions. No written agreement, license, or royalty fee is required
sherckuith 0:479ce5546098 12 * for any of the authorized uses.
sherckuith 0:479ce5546098 13 *
sherckuith 0:479ce5546098 14 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
sherckuith 0:479ce5546098 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
sherckuith 0:479ce5546098 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
sherckuith 0:479ce5546098 17 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
sherckuith 0:479ce5546098 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
sherckuith 0:479ce5546098 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
sherckuith 0:479ce5546098 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
sherckuith 0:479ce5546098 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
sherckuith 0:479ce5546098 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
sherckuith 0:479ce5546098 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
sherckuith 0:479ce5546098 24 *
sherckuith 0:479ce5546098 25 ******************************************************************************
sherckuith 0:479ce5546098 26 * REVISION HISTORY
sherckuith 0:479ce5546098 27 *
sherckuith 0:479ce5546098 28 * 03-01-01 Marc Boucher <marc@mbsi.ca>
sherckuith 0:479ce5546098 29 * Ported to lwIP.
sherckuith 0:479ce5546098 30 * 97-12-03 Guy Lancaster <lancasterg@acm.org>, Global Election Systems Inc.
sherckuith 0:479ce5546098 31 * Original built from BSD network code.
sherckuith 0:479ce5546098 32 ******************************************************************************/
sherckuith 0:479ce5546098 33 /*
sherckuith 0:479ce5546098 34 * chap.h - Challenge Handshake Authentication Protocol definitions.
sherckuith 0:479ce5546098 35 *
sherckuith 0:479ce5546098 36 * Copyright (c) 1993 The Australian National University.
sherckuith 0:479ce5546098 37 * All rights reserved.
sherckuith 0:479ce5546098 38 *
sherckuith 0:479ce5546098 39 * Redistribution and use in source and binary forms are permitted
sherckuith 0:479ce5546098 40 * provided that the above copyright notice and this paragraph are
sherckuith 0:479ce5546098 41 * duplicated in all such forms and that any documentation,
sherckuith 0:479ce5546098 42 * advertising materials, and other materials related to such
sherckuith 0:479ce5546098 43 * distribution and use acknowledge that the software was developed
sherckuith 0:479ce5546098 44 * by the Australian National University. The name of the University
sherckuith 0:479ce5546098 45 * may not be used to endorse or promote products derived from this
sherckuith 0:479ce5546098 46 * software without specific prior written permission.
sherckuith 0:479ce5546098 47 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
sherckuith 0:479ce5546098 48 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
sherckuith 0:479ce5546098 49 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
sherckuith 0:479ce5546098 50 *
sherckuith 0:479ce5546098 51 * Copyright (c) 1991 Gregory M. Christy
sherckuith 0:479ce5546098 52 * All rights reserved.
sherckuith 0:479ce5546098 53 *
sherckuith 0:479ce5546098 54 * Redistribution and use in source and binary forms are permitted
sherckuith 0:479ce5546098 55 * provided that the above copyright notice and this paragraph are
sherckuith 0:479ce5546098 56 * duplicated in all such forms and that any documentation,
sherckuith 0:479ce5546098 57 * advertising materials, and other materials related to such
sherckuith 0:479ce5546098 58 * distribution and use acknowledge that the software was developed
sherckuith 0:479ce5546098 59 * by the author.
sherckuith 0:479ce5546098 60 *
sherckuith 0:479ce5546098 61 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
sherckuith 0:479ce5546098 62 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
sherckuith 0:479ce5546098 63 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
sherckuith 0:479ce5546098 64 *
sherckuith 0:479ce5546098 65 * $Id: chap.h,v 1.6 2010/01/24 13:19:34 goldsimon Exp $
sherckuith 0:479ce5546098 66 */
sherckuith 0:479ce5546098 67
sherckuith 0:479ce5546098 68 #ifndef CHAP_H
sherckuith 0:479ce5546098 69 #define CHAP_H
sherckuith 0:479ce5546098 70
sherckuith 0:479ce5546098 71 /* Code + ID + length */
sherckuith 0:479ce5546098 72 #define CHAP_HEADERLEN 4
sherckuith 0:479ce5546098 73
sherckuith 0:479ce5546098 74 /*
sherckuith 0:479ce5546098 75 * CHAP codes.
sherckuith 0:479ce5546098 76 */
sherckuith 0:479ce5546098 77
sherckuith 0:479ce5546098 78 #define CHAP_DIGEST_MD5 5 /* use MD5 algorithm */
sherckuith 0:479ce5546098 79 #define MD5_SIGNATURE_SIZE 16 /* 16 bytes in a MD5 message digest */
sherckuith 0:479ce5546098 80 #define CHAP_MICROSOFT 0x80 /* use Microsoft-compatible alg. */
sherckuith 0:479ce5546098 81 #define MS_CHAP_RESPONSE_LEN 49 /* Response length for MS-CHAP */
sherckuith 0:479ce5546098 82
sherckuith 0:479ce5546098 83 #define CHAP_CHALLENGE 1
sherckuith 0:479ce5546098 84 #define CHAP_RESPONSE 2
sherckuith 0:479ce5546098 85 #define CHAP_SUCCESS 3
sherckuith 0:479ce5546098 86 #define CHAP_FAILURE 4
sherckuith 0:479ce5546098 87
sherckuith 0:479ce5546098 88 /*
sherckuith 0:479ce5546098 89 * Challenge lengths (for challenges we send) and other limits.
sherckuith 0:479ce5546098 90 */
sherckuith 0:479ce5546098 91 #define MIN_CHALLENGE_LENGTH 32
sherckuith 0:479ce5546098 92 #define MAX_CHALLENGE_LENGTH 64
sherckuith 0:479ce5546098 93 #define MAX_RESPONSE_LENGTH 64 /* sufficient for MD5 or MS-CHAP */
sherckuith 0:479ce5546098 94
sherckuith 0:479ce5546098 95 /*
sherckuith 0:479ce5546098 96 * Each interface is described by a chap structure.
sherckuith 0:479ce5546098 97 */
sherckuith 0:479ce5546098 98
sherckuith 0:479ce5546098 99 typedef struct chap_state {
sherckuith 0:479ce5546098 100 int unit; /* Interface unit number */
sherckuith 0:479ce5546098 101 int clientstate; /* Client state */
sherckuith 0:479ce5546098 102 int serverstate; /* Server state */
sherckuith 0:479ce5546098 103 u_char challenge[MAX_CHALLENGE_LENGTH]; /* last challenge string sent */
sherckuith 0:479ce5546098 104 u_char chal_len; /* challenge length */
sherckuith 0:479ce5546098 105 u_char chal_id; /* ID of last challenge */
sherckuith 0:479ce5546098 106 u_char chal_type; /* hash algorithm for challenges */
sherckuith 0:479ce5546098 107 u_char id; /* Current id */
sherckuith 0:479ce5546098 108 char *chal_name; /* Our name to use with challenge */
sherckuith 0:479ce5546098 109 int chal_interval; /* Time until we challenge peer again */
sherckuith 0:479ce5546098 110 int timeouttime; /* Timeout time in seconds */
sherckuith 0:479ce5546098 111 int max_transmits; /* Maximum # of challenge transmissions */
sherckuith 0:479ce5546098 112 int chal_transmits; /* Number of transmissions of challenge */
sherckuith 0:479ce5546098 113 int resp_transmits; /* Number of transmissions of response */
sherckuith 0:479ce5546098 114 u_char response[MAX_RESPONSE_LENGTH]; /* Response to send */
sherckuith 0:479ce5546098 115 u_char resp_length; /* length of response */
sherckuith 0:479ce5546098 116 u_char resp_id; /* ID for response messages */
sherckuith 0:479ce5546098 117 u_char resp_type; /* hash algorithm for responses */
sherckuith 0:479ce5546098 118 char *resp_name; /* Our name to send with response */
sherckuith 0:479ce5546098 119 } chap_state;
sherckuith 0:479ce5546098 120
sherckuith 0:479ce5546098 121
sherckuith 0:479ce5546098 122 /*
sherckuith 0:479ce5546098 123 * Client (peer) states.
sherckuith 0:479ce5546098 124 */
sherckuith 0:479ce5546098 125 #define CHAPCS_INITIAL 0 /* Lower layer down, not opened */
sherckuith 0:479ce5546098 126 #define CHAPCS_CLOSED 1 /* Lower layer up, not opened */
sherckuith 0:479ce5546098 127 #define CHAPCS_PENDING 2 /* Auth us to peer when lower up */
sherckuith 0:479ce5546098 128 #define CHAPCS_LISTEN 3 /* Listening for a challenge */
sherckuith 0:479ce5546098 129 #define CHAPCS_RESPONSE 4 /* Sent response, waiting for status */
sherckuith 0:479ce5546098 130 #define CHAPCS_OPEN 5 /* We've received Success */
sherckuith 0:479ce5546098 131
sherckuith 0:479ce5546098 132 /*
sherckuith 0:479ce5546098 133 * Server (authenticator) states.
sherckuith 0:479ce5546098 134 */
sherckuith 0:479ce5546098 135 #define CHAPSS_INITIAL 0 /* Lower layer down, not opened */
sherckuith 0:479ce5546098 136 #define CHAPSS_CLOSED 1 /* Lower layer up, not opened */
sherckuith 0:479ce5546098 137 #define CHAPSS_PENDING 2 /* Auth peer when lower up */
sherckuith 0:479ce5546098 138 #define CHAPSS_INITIAL_CHAL 3 /* We've sent the first challenge */
sherckuith 0:479ce5546098 139 #define CHAPSS_OPEN 4 /* We've sent a Success msg */
sherckuith 0:479ce5546098 140 #define CHAPSS_RECHALLENGE 5 /* We've sent another challenge */
sherckuith 0:479ce5546098 141 #define CHAPSS_BADAUTH 6 /* We've sent a Failure msg */
sherckuith 0:479ce5546098 142
sherckuith 0:479ce5546098 143 extern chap_state chap[];
sherckuith 0:479ce5546098 144
sherckuith 0:479ce5546098 145 void ChapAuthWithPeer (int, char *, u_char);
sherckuith 0:479ce5546098 146 void ChapAuthPeer (int, char *, u_char);
sherckuith 0:479ce5546098 147
sherckuith 0:479ce5546098 148 extern struct protent chap_protent;
sherckuith 0:479ce5546098 149
sherckuith 0:479ce5546098 150 #endif /* CHAP_H */