Committer:
mbed714
Date:
Sat Sep 18 23:05:49 2010 +0000
Revision:
0:d616ece2d859

        

Who changed what in which revision?

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