Jonathan Caes / InetTest-8d87bc453349

Dependencies:   DS1307 TextLCD mbed

Committer:
JonathanCaes
Date:
Mon Dec 29 13:37:45 2014 +0000
Revision:
2:63849bb30db0
Parent:
0:a16f60a71395
Project

Who changed what in which revision?

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