Library for Bert van Dam's book "ARM MICROCONTROLLERS" For all chapters with internet.

Dependencies:   mbed

Committer:
ICTFBI
Date:
Fri Oct 16 14:28:26 2015 +0000
Revision:
0:4edb816d21e1
Pre-update 16-10-15

Who changed what in which revision?

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