"SfR Fresh" - the SfR Freeware/Shareware Archive 
Member "slirp-1.0.16/src/ppp/chap.h" of archive slirp-1.0.16.tar.gz:
As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting with prefixed line numbers.
Alternatively you can here view or download the uninterpreted source code file.
That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
1 /*
2 * chap.h - Cryptographic Handshake Authentication Protocol definitions.
3 *
4 * Copyright (c) 1991 Gregory M. Christy
5 * All rights reserved.
6 *
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
12 * by the author.
13 *
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.
17 *
18 * $Id: chap.h,v 1.3 1994/09/21 06:47:37 paulus Exp $
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
33 #define CHAP_CHALLENGE 1
34 #define CHAP_RESPONSE 2
35 #define CHAP_SUCCESS 3
36 #define CHAP_FAILURE 4
37
38 /*
39 * Challenge lengths (for challenges we send) and other limits.
40 */
41 #define MIN_CHALLENGE_LENGTH 32
42 #define MAX_CHALLENGE_LENGTH 64
43 #define MAX_RESPONSE_LENGTH 16 /* sufficient for MD5 */
44
45 /*
46 * Each interface is described by a chap structure.
47 */
48
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 */
69 } chap_state;
70
71
72 /*
73 * Client (peer) states.
74 */
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 */
81
82 /*
83 * Server (authenticator) states.
84 */
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 */
92
93 /*
94 * Timeouts.
95 */
96 #define CHAP_DEFTIMEOUT 3 /* Timeout time in seconds */
97 #define CHAP_DEFTRANSMITS 10 /* max # times to send challenge */
98
99 extern chap_state chap[];
100
101 void ChapInit __P((int));
102 void ChapAuthWithPeer __P((int, char *, int));
103 void ChapAuthPeer __P((int, char *, int));
104 void ChapLowerUp __P((int));
105 void ChapLowerDown __P((int));
106 void ChapInput __P((int, u_char *, int));
107 void ChapProtocolReject __P((int));
108 int ChapPrintPkt __P((u_char *, int,
109 void (*) __P((void *, char *, ...)), void *));
110
111 #define __CHAP_INCLUDE__
112 #endif /* __CHAP_INCLUDE__ */