2 * chap.h - Cryptographic Handshake Authentication Protocol definitions.
3 * based on November 1991 draft of PPP Authentication RFC
5 * Copyright (c) 1991 Gregory M. Christy
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 * $Id: chap.h,v 1.1 1993/11/11 03:54:25 paulus Exp $
22 #ifndef __CHAP_INCLUDE__
24 /* Code + ID + length */
25 #define CHAP_HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short))
31 #define CHAP_DIGEST_MD5 5 /* use MD5 algorithm */
32 #define MD5_SIGNATURE_SIZE 16 /* 16 bytes in a MD5 message digest */
34 #define CHAP_CHALLENGE 1
35 #define CHAP_RESPONSE 2
36 #define CHAP_SUCCESS 3
37 #define CHAP_FAILURE 4
40 * Challenge lengths (for challenges we send) and other limits.
42 #define MIN_CHALLENGE_LENGTH 32
43 #define MAX_CHALLENGE_LENGTH 64
44 #define MAX_RESPONSE_LENGTH 16 /* sufficient for MD5 */
47 * Each interface is described by a chap structure.
50 typedef struct chap_state {
51 int unit; /* Interface unit number */
52 int clientstate; /* Client state */
53 int serverstate; /* Server state */
54 u_char challenge[MAX_CHALLENGE_LENGTH]; /* last challenge string sent */
55 u_char chal_len; /* challenge length */
56 u_char chal_id; /* ID of last challenge */
57 u_char chal_type; /* hash algorithm for challenges */
58 u_char id; /* Current id */
59 char *chal_name; /* Our name to use with challenge */
60 int chal_interval; /* Time until we challenge peer again */
61 int timeouttime; /* Timeout time in seconds */
62 int max_transmits; /* Maximum # of challenge transmissions */
63 int chal_transmits; /* Number of transmissions of challenge */
64 int resp_transmits; /* Number of transmissions of response */
65 u_char response[MAX_RESPONSE_LENGTH]; /* Response to send */
66 u_char resp_length; /* length of response */
67 u_char resp_id; /* ID for response messages */
68 u_char resp_type; /* hash algorithm for responses */
69 char *resp_name; /* Our name to send with response */
74 * Client (peer) states.
76 #define CHAPCS_INITIAL 0 /* Lower layer down, not opened */
77 #define CHAPCS_CLOSED 1 /* Lower layer up, not opened */
78 #define CHAPCS_PENDING 2 /* Auth us to peer when lower up */
79 #define CHAPCS_LISTEN 3 /* Listening for a challenge */
80 #define CHAPCS_RESPONSE 4 /* Sent response, waiting for status */
81 #define CHAPCS_OPEN 5 /* We've received Success */
84 * Server (authenticator) states.
86 #define CHAPSS_INITIAL 0 /* Lower layer down, not opened */
87 #define CHAPSS_CLOSED 1 /* Lower layer up, not opened */
88 #define CHAPSS_PENDING 2 /* Auth peer when lower up */
89 #define CHAPSS_INITIAL_CHAL 3 /* We've sent the first challenge */
90 #define CHAPSS_OPEN 4 /* We've sent a Success msg */
91 #define CHAPSS_RECHALLENGE 5 /* We've sent another challenge */
92 #define CHAPSS_BADAUTH 6 /* We've sent a Failure msg */
97 #define CHAP_DEFTIMEOUT 3 /* Timeout time in seconds */
98 #define CHAP_DEFTRANSMITS 10 /* max # times to send challenge */
100 extern chap_state chap[];
102 void ChapInit __ARGS((int));
103 void ChapAuthWithPeer __ARGS((int, char *, int));
104 void ChapAuthPeer __ARGS((int, char *, int));
105 void ChapLowerUp __ARGS((int));
106 void ChapLowerDown __ARGS((int));
107 void ChapInput __ARGS((int, u_char *, int));
108 void ChapProtocolReject __ARGS((int));
110 #define __CHAP_INCLUDE__
111 #endif /* __CHAP_INCLUDE__ */