Brandon Fictorie / Mbed 2 deprecated BF_Websocket

Dependencies:   mbed

Committer:
bfictorie
Date:
Sun Mar 25 17:26:30 2012 +0000
Revision:
0:8cdad1c73e8e

        

Who changed what in which revision?

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