Dependents:   SNMPAgent HTTPServer think_speak_a cyassl-client ... more

Committer:
mamezu
Date:
Thu Dec 09 01:33:56 2010 +0000
Revision:
0:0f6c82fcde82

        

Who changed what in which revision?

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