xref: /titanic_44/usr/src/cmd/cmd-inet/usr.bin/pppd/chap.h (revision f53eecf557986dac6ededb388fedd6ca63be0350)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * chap.h - Challenge Handshake Authentication Protocol definitions.
37c478bd9Sstevel@tonic-gate  *
4*f53eecf5SJames Carlson  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
5*f53eecf5SJames Carlson  * Use is subject to license terms.
67c478bd9Sstevel@tonic-gate  *
77c478bd9Sstevel@tonic-gate  * Copyright (c) 1993 The Australian National University.
87c478bd9Sstevel@tonic-gate  * All rights reserved.
97c478bd9Sstevel@tonic-gate  *
107c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms are permitted
117c478bd9Sstevel@tonic-gate  * provided that the above copyright notice and this paragraph are
127c478bd9Sstevel@tonic-gate  * duplicated in all such forms and that any documentation,
137c478bd9Sstevel@tonic-gate  * advertising materials, and other materials related to such
147c478bd9Sstevel@tonic-gate  * distribution and use acknowledge that the software was developed
157c478bd9Sstevel@tonic-gate  * by the Australian National University.  The name of the University
167c478bd9Sstevel@tonic-gate  * may not be used to endorse or promote products derived from this
177c478bd9Sstevel@tonic-gate  * software without specific prior written permission.
187c478bd9Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
197c478bd9Sstevel@tonic-gate  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
207c478bd9Sstevel@tonic-gate  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
217c478bd9Sstevel@tonic-gate  *
227c478bd9Sstevel@tonic-gate  * Copyright (c) 1991 Gregory M. Christy
237c478bd9Sstevel@tonic-gate  * All rights reserved.
247c478bd9Sstevel@tonic-gate  *
257c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms are permitted
267c478bd9Sstevel@tonic-gate  * provided that the above copyright notice and this paragraph are
277c478bd9Sstevel@tonic-gate  * duplicated in all such forms and that any documentation,
287c478bd9Sstevel@tonic-gate  * advertising materials, and other materials related to such
297c478bd9Sstevel@tonic-gate  * distribution and use acknowledge that the software was developed
307c478bd9Sstevel@tonic-gate  * by the author.
317c478bd9Sstevel@tonic-gate  *
327c478bd9Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
337c478bd9Sstevel@tonic-gate  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
347c478bd9Sstevel@tonic-gate  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
357c478bd9Sstevel@tonic-gate  *
367c478bd9Sstevel@tonic-gate  * $Id: chap.h,v 1.8 1999/11/15 01:44:41 paulus Exp $
377c478bd9Sstevel@tonic-gate  */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifndef __CHAP_INCLUDE__
407c478bd9Sstevel@tonic-gate #define __CHAP_INCLUDE__
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /* Code + ID + length */
437c478bd9Sstevel@tonic-gate #define CHAP_HEADERLEN		4
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate #define CHAP_DIGEST_MD5		5	/* use MD5 algorithm */
467c478bd9Sstevel@tonic-gate #define MD5_SIGNATURE_SIZE	16	/* 16 bytes in a MD5 message digest */
477c478bd9Sstevel@tonic-gate #define CHAP_MICROSOFT		0x80	/* use Microsoft-compatible alg. */
487c478bd9Sstevel@tonic-gate #define CHAP_MICROSOFT_V2	0x81	/* use MS-CHAPv2 */
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate #define	CHECK_CHALLENGE_LENGTH	8	/* Minimum acceptable challenge */
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * CHAP message code numbers.
547c478bd9Sstevel@tonic-gate  */
557c478bd9Sstevel@tonic-gate #define CHAP_CHALLENGE		1
567c478bd9Sstevel@tonic-gate #define CHAP_RESPONSE		2
577c478bd9Sstevel@tonic-gate #define CHAP_SUCCESS		3
587c478bd9Sstevel@tonic-gate #define CHAP_FAILURE    	4
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate /*
617c478bd9Sstevel@tonic-gate  *  Challenge lengths (for challenges we send) and other limits.
627c478bd9Sstevel@tonic-gate  */
637c478bd9Sstevel@tonic-gate #define MIN_CHALLENGE_LENGTH	16
647c478bd9Sstevel@tonic-gate #define MAX_CHALLENGE_LENGTH	24
657c478bd9Sstevel@tonic-gate #define MAX_RESPONSE_LENGTH	64	/* sufficient for MD5 or MS-CHAP */
667c478bd9Sstevel@tonic-gate /* These are here to remind people of the buffer limits */
677c478bd9Sstevel@tonic-gate #define	MS_CHAP_RESPONSE_LEN	49	/* Response length for MS-CHAP */
687c478bd9Sstevel@tonic-gate #define MS_CHAPV2_RESPONSE_LEN	49	/* Response length for MS-CHAPv2 */
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * Each interface is described by a chap structure.
727c478bd9Sstevel@tonic-gate  */
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate typedef struct chap_state {
757c478bd9Sstevel@tonic-gate     int unit;			/* Interface unit number */
767c478bd9Sstevel@tonic-gate     int clientstate;		/* Client state */
777c478bd9Sstevel@tonic-gate     int serverstate;		/* Server state */
787c478bd9Sstevel@tonic-gate     char peercname[MAXNAMELEN];	/* unauthenticated peer name in challenge */
797c478bd9Sstevel@tonic-gate     u_char challenge[MAX_CHALLENGE_LENGTH]; /* last challenge string sent */
807c478bd9Sstevel@tonic-gate     u_char chal_len;		/* challenge length */
817c478bd9Sstevel@tonic-gate     u_char chal_id;		/* ID of last challenge */
827c478bd9Sstevel@tonic-gate     u_char chal_type;		/* hash algorithm for challenges */
837c478bd9Sstevel@tonic-gate     u_char id;			/* Current id */
847c478bd9Sstevel@tonic-gate     char *chal_name;		/* Our name to use with challenge */
857c478bd9Sstevel@tonic-gate     int chal_interval;		/* Time until we challenge peer again */
867c478bd9Sstevel@tonic-gate     int timeouttime;		/* Timeout time in seconds */
877c478bd9Sstevel@tonic-gate     int max_transmits;		/* Maximum # of challenge transmissions */
887c478bd9Sstevel@tonic-gate     int chal_transmits;		/* Number of transmissions of challenge */
897c478bd9Sstevel@tonic-gate     int resp_transmits;		/* Number of transmissions of response */
907c478bd9Sstevel@tonic-gate     u_char response[MAX_RESPONSE_LENGTH];	/* Response to send */
917c478bd9Sstevel@tonic-gate     u_char resp_length;		/* length of response */
927c478bd9Sstevel@tonic-gate     u_char resp_id;		/* ID for response messages */
937c478bd9Sstevel@tonic-gate     u_char resp_type;		/* hash algorithm for responses */
947c478bd9Sstevel@tonic-gate     u_char stat_length;		/* Length of status message (MS-CHAP) */
957c478bd9Sstevel@tonic-gate     char *resp_name;		/* Our name to send with response */
967c478bd9Sstevel@tonic-gate     char *stat_message;		/* per-algorithm status message (MS-CHAP) */
97*f53eecf5SJames Carlson     int rename_count;		/* number of peer renames seen */
987c478bd9Sstevel@tonic-gate } chap_state;
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate /*
1027c478bd9Sstevel@tonic-gate  * Client (authenticatee) states.
1037c478bd9Sstevel@tonic-gate  */
1047c478bd9Sstevel@tonic-gate #define CHAPCS_INITIAL		0	/* Lower layer down, not opened */
1057c478bd9Sstevel@tonic-gate #define CHAPCS_CLOSED		1	/* Lower layer up, not opened */
1067c478bd9Sstevel@tonic-gate #define CHAPCS_PENDING		2	/* Auth us to peer when lower up */
1077c478bd9Sstevel@tonic-gate #define CHAPCS_LISTEN		3	/* Listening for a challenge */
1087c478bd9Sstevel@tonic-gate #define CHAPCS_RESPONSE		4	/* Sent response, waiting for status */
1097c478bd9Sstevel@tonic-gate #define CHAPCS_OPEN		5	/* We've received Success */
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate #define	CHAPCS__LIST	\
1127c478bd9Sstevel@tonic-gate 	"Initial", "Closed", "Pending", "Listen", \
1137c478bd9Sstevel@tonic-gate 	"Response", "Open"
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate /*
1167c478bd9Sstevel@tonic-gate  * Server (authenticator) states.
1177c478bd9Sstevel@tonic-gate  */
1187c478bd9Sstevel@tonic-gate #define CHAPSS_INITIAL		0	/* Lower layer down, not opened */
1197c478bd9Sstevel@tonic-gate #define CHAPSS_CLOSED		1	/* Lower layer up, not opened */
1207c478bd9Sstevel@tonic-gate #define CHAPSS_PENDING		2	/* Auth peer when lower up */
1217c478bd9Sstevel@tonic-gate #define CHAPSS_INITIAL_CHAL	3	/* We've sent the first challenge */
1227c478bd9Sstevel@tonic-gate #define CHAPSS_OPEN		4	/* We've sent a Success msg */
1237c478bd9Sstevel@tonic-gate #define CHAPSS_RECHALLENGE	5	/* We've sent another challenge */
1247c478bd9Sstevel@tonic-gate #define CHAPSS_BADAUTH		6	/* We've sent a Failure msg */
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate #define	CHAPSS__LIST	\
1277c478bd9Sstevel@tonic-gate 	"Initial", "Closed", "Pending", "InitialChal", \
1287c478bd9Sstevel@tonic-gate 	"Open", "Rechallenge", "BadAuth"
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate /*
1317c478bd9Sstevel@tonic-gate  * Timeouts.
1327c478bd9Sstevel@tonic-gate  */
1337c478bd9Sstevel@tonic-gate #define CHAP_DEFTIMEOUT		3	/* Timeout time in seconds */
1347c478bd9Sstevel@tonic-gate #define CHAP_DEFTRANSMITS	10	/* max # times to send challenge */
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate extern chap_state chap[];
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate void ChapAuthWithPeer __P((int, char *, int));
1397c478bd9Sstevel@tonic-gate void ChapAuthPeer __P((int, char *, int));
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate extern struct protent chap_protent;
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate #endif /* __CHAP_INCLUDE__ */
144