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