Michael Fischler / Mbed 2 deprecated Contest_Winner

Dependencies:   mbed

Committer:
mafischl
Date:
Thu Oct 13 17:02:29 2011 +0000
Revision:
0:d9266031f832

        

Who changed what in which revision?

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