xref: /openbsd/usr.sbin/pppd/chap.h (revision bb688669)
1 /*	$OpenBSD: chap.h,v 1.4 1996/07/20 12:02:06 joshd Exp $	*/
2 
3 /*
4  * chap.h - Challenge-Handshake Authentication Protocol definitions.
5  *
6  * Copyright (c) 1991 Gregory M. Christy
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms are permitted
10  * provided that the above copyright notice and this paragraph are
11  * duplicated in all such forms and that any documentation,
12  * advertising materials, and other materials related to such
13  * distribution and use acknowledge that the software was developed
14  * by the author.
15  *
16  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  */
20 
21 #ifndef __CHAP_INCLUDE__
22 
23 /* Code + ID + length */
24 #define CHAP_HEADERLEN		4
25 
26 /*
27  * CHAP codes.
28  */
29 
30 #define CHAP_DIGEST_MD5		5	/* use MD5 algorithm */
31 #define MD5_SIGNATURE_SIZE	16	/* 16 bytes in a MD5 message digest */
32 #define CHAP_MICROSOFT          0x80    /* use Microsoft-compatible alg. */
33 #define MS_CHAP_RESPONSE_LEN    49      /* Response length for MS-CHAP */
34 
35 #define CHAP_CHALLENGE		1
36 #define CHAP_RESPONSE		2
37 #define CHAP_SUCCESS		3
38 #define CHAP_FAILURE    	4
39 
40 /*
41  *  Challenge lengths (for challenges we send) and other limits.
42  */
43 #define MIN_CHALLENGE_LENGTH	32
44 #define MAX_CHALLENGE_LENGTH	64
45 #define MAX_RESPONSE_LENGTH	16	/* sufficient for MD5 */
46 
47 /*
48  * Each interface is described by a chap structure.
49  */
50 
51 typedef struct chap_state {
52     int unit;			/* Interface unit number */
53     int clientstate;		/* Client state */
54     int serverstate;		/* Server state */
55     u_char challenge[MAX_CHALLENGE_LENGTH]; /* last challenge string sent */
56     u_char chal_len;		/* challenge length */
57     u_char chal_id;		/* ID of last challenge */
58     u_char chal_type;		/* hash algorithm for challenges */
59     u_char id;			/* Current id */
60     char *chal_name;		/* Our name to use with challenge */
61     int chal_interval;		/* Time until we challenge peer again */
62     int timeouttime;		/* Timeout time in seconds */
63     int max_transmits;		/* Maximum # of challenge transmissions */
64     int chal_transmits;		/* Number of transmissions of challenge */
65     int resp_transmits;		/* Number of transmissions of response */
66     u_char response[MAX_RESPONSE_LENGTH];	/* Response to send */
67     u_char resp_length;		/* length of response */
68     u_char resp_id;		/* ID for response messages */
69     u_char resp_type;		/* hash algorithm for responses */
70     char *resp_name;		/* Our name to send with response */
71 } chap_state;
72 
73 
74 /*
75  * Client (peer) states.
76  */
77 #define CHAPCS_INITIAL		0	/* Lower layer down, not opened */
78 #define CHAPCS_CLOSED		1	/* Lower layer up, not opened */
79 #define CHAPCS_PENDING		2	/* Auth us to peer when lower up */
80 #define CHAPCS_LISTEN		3	/* Listening for a challenge */
81 #define CHAPCS_RESPONSE		4	/* Sent response, waiting for status */
82 #define CHAPCS_OPEN		5	/* We've received Success */
83 
84 /*
85  * Server (authenticator) states.
86  */
87 #define CHAPSS_INITIAL		0	/* Lower layer down, not opened */
88 #define CHAPSS_CLOSED		1	/* Lower layer up, not opened */
89 #define CHAPSS_PENDING		2	/* Auth peer when lower up */
90 #define CHAPSS_INITIAL_CHAL	3	/* We've sent the first challenge */
91 #define CHAPSS_OPEN		4	/* We've sent a Success msg */
92 #define CHAPSS_RECHALLENGE	5	/* We've sent another challenge */
93 #define CHAPSS_BADAUTH		6	/* We've sent a Failure msg */
94 
95 /*
96  * Timeouts.
97  */
98 #define CHAP_DEFTIMEOUT		3	/* Timeout time in seconds */
99 #define CHAP_DEFTRANSMITS	10	/* max # times to send challenge */
100 
101 extern chap_state chap[];
102 
103 void ChapAuthWithPeer __P((int, char *, int));
104 void ChapAuthPeer __P((int, char *, int));
105 
106 extern struct protent chap_protent;
107 
108 #define __CHAP_INCLUDE__
109 #endif /* __CHAP_INCLUDE__ */
110