Forked from the DieterGraef Library

Fork of F7_Ethernet by Dieter Graef

Committer:
EmbeddedSam
Date:
Fri Nov 18 12:48:10 2016 +0000
Revision:
2:fdef48f830c0
Parent:
0:d26c1b55cfca
Linking MQTT together, starting with mbed-cli

Who changed what in which revision?

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