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