]> git.ozlabs.org Git - ppp.git/blob - pppd/chap-new.c
plugins/radius: Eliminate some potential buffer overruns
[ppp.git] / pppd / chap-new.c
1 /*
2  * chap-new.c - New CHAP implementation.
3  *
4  * Copyright (c) 2003 Paul Mackerras. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  *
13  * 2. The name(s) of the authors of this software must not be used to
14  *    endorse or promote products derived from this software without
15  *    prior written permission.
16  *
17  * 3. Redistributions of any form whatsoever must retain the following
18  *    acknowledgment:
19  *    "This product includes software developed by Paul Mackerras
20  *     <paulus@samba.org>".
21  *
22  * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
23  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24  * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
25  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
26  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
27  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
28  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29  */
30
31 #define RCSID   "$Id: chap-new.c,v 1.9 2007/06/19 02:08:35 carlsonj Exp $"
32
33 #include <stdlib.h>
34 #include <string.h>
35 #include "pppd.h"
36 #include "session.h"
37 #include "chap-new.h"
38 #include "chap-md5.h"
39
40 #ifdef CHAPMS
41 #include "chap_ms.h"
42 #define MDTYPE_ALL (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5)
43 #else
44 #define MDTYPE_ALL (MDTYPE_MD5)
45 #endif
46
47 int chap_mdtype_all = MDTYPE_ALL;
48
49 /* Hook for a plugin to validate CHAP challenge */
50 int (*chap_verify_hook)(char *name, char *ourname, int id,
51                         struct chap_digest_type *digest,
52                         unsigned char *challenge, unsigned char *response,
53                         char *message, int message_space) = NULL;
54
55 /*
56  * Option variables.
57  */
58 int chap_server_timeout_time = 3;
59 int chap_max_transmits = 10;
60 int chap_rechallenge_time = 0;
61 int chap_client_timeout_time = 60;
62 int chapms_strip_domain = 0;
63
64 /*
65  * Command-line options.
66  */
67 static option_t chap_option_list[] = {
68         { "chap-restart", o_int, &chap_server_timeout_time,
69           "Set timeout for CHAP (as server)", OPT_PRIO },
70         { "chap-max-challenge", o_int, &chap_max_transmits,
71           "Set max #xmits for challenge", OPT_PRIO },
72         { "chap-interval", o_int, &chap_rechallenge_time,
73           "Set interval for rechallenge", OPT_PRIO },
74         { "chap-timeout", o_int, &chap_client_timeout_time,
75           "Set timeout for CHAP (as client)", OPT_PRIO },
76         { "chapms-strip-domain", o_bool, &chapms_strip_domain,
77           "Strip the domain prefix before the Username", 1 },
78         { NULL }
79 };
80
81 /*
82  * Internal state.
83  */
84 static struct chap_client_state {
85         int flags;
86         char *name;
87         struct chap_digest_type *digest;
88         unsigned char priv[64];         /* private area for digest's use */
89 } client;
90
91 /*
92  * These limits apply to challenge and response packets we send.
93  * The +4 is the +1 that we actually need rounded up.
94  */
95 #define CHAL_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_CHALLENGE_LEN + MAXNAMELEN)
96 #define RESP_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_RESPONSE_LEN + MAXNAMELEN)
97
98 static struct chap_server_state {
99         int flags;
100         int id;
101         char *name;
102         struct chap_digest_type *digest;
103         int challenge_xmits;
104         int challenge_pktlen;
105         unsigned char challenge[CHAL_MAX_PKTLEN];
106         char message[256];
107 } server;
108
109 /* Values for flags in chap_client_state and chap_server_state */
110 #define LOWERUP                 1
111 #define AUTH_STARTED            2
112 #define AUTH_DONE               4
113 #define AUTH_FAILED             8
114 #define TIMEOUT_PENDING         0x10
115 #define CHALLENGE_VALID         0x20
116
117 /*
118  * Prototypes.
119  */
120 static void chap_init(int unit);
121 static void chap_lowerup(int unit);
122 static void chap_lowerdown(int unit);
123 static void chap_server_timeout(void *arg);
124 static void chap_client_timeout(void *arg);
125 static void chap_generate_challenge(struct chap_server_state *ss);
126 static void chap_handle_response(struct chap_server_state *ss, int code,
127                 unsigned char *pkt, int len);
128 static int chap_verify_response(char *name, char *ourname, int id,
129                 struct chap_digest_type *digest,
130                 unsigned char *challenge, unsigned char *response,
131                 char *message, int message_space);
132 static void chap_respond(struct chap_client_state *cs, int id,
133                 unsigned char *pkt, int len);
134 static void chap_handle_status(struct chap_client_state *cs, int code, int id,
135                 unsigned char *pkt, int len);
136 static void chap_protrej(int unit);
137 static void chap_input(int unit, unsigned char *pkt, int pktlen);
138 static int chap_print_pkt(unsigned char *p, int plen,
139                 void (*printer)(void *, char *, ...), void *arg);
140
141 /* List of digest types that we know about */
142 static struct chap_digest_type *chap_digests;
143
144 /*
145  * chap_init - reset to initial state.
146  */
147 static void
148 chap_init(int unit)
149 {
150         memset(&client, 0, sizeof(client));
151         memset(&server, 0, sizeof(server));
152
153         chap_md5_init();
154 #ifdef CHAPMS
155         chapms_init();
156 #endif
157 }
158
159 /*
160  * Add a new digest type to the list.
161  */
162 void
163 chap_register_digest(struct chap_digest_type *dp)
164 {
165         dp->next = chap_digests;
166         chap_digests = dp;
167 }
168
169 /*
170  * Lookup a digest type by code
171  */
172 struct chap_digest_type *
173 chap_find_digest(int digest_code) {
174     struct chap_digest_type *dp = NULL;
175         for (dp = chap_digests; dp != NULL; dp = dp->next)
176                 if (dp->code == digest_code)
177                         break;
178     return dp;
179 }
180
181 /*
182  * chap_lowerup - we can start doing stuff now.
183  */
184 static void
185 chap_lowerup(int unit)
186 {
187         struct chap_client_state *cs = &client;
188         struct chap_server_state *ss = &server;
189
190         cs->flags |= LOWERUP;
191         ss->flags |= LOWERUP;
192         if (ss->flags & AUTH_STARTED)
193                 chap_server_timeout(ss);
194 }
195
196 static void
197 chap_lowerdown(int unit)
198 {
199         struct chap_client_state *cs = &client;
200         struct chap_server_state *ss = &server;
201
202         if (cs->flags & TIMEOUT_PENDING)
203                 UNTIMEOUT(chap_client_timeout, cs);
204         cs->flags = 0;
205         if (ss->flags & TIMEOUT_PENDING)
206                 UNTIMEOUT(chap_server_timeout, ss);
207         ss->flags = 0;
208 }
209
210 /*
211  * chap_auth_peer - Start authenticating the peer.
212  * If the lower layer is already up, we start sending challenges,
213  * otherwise we wait for the lower layer to come up.
214  */
215 void
216 chap_auth_peer(int unit, char *our_name, int digest_code)
217 {
218         struct chap_server_state *ss = &server;
219         struct chap_digest_type *dp;
220
221         if (ss->flags & AUTH_STARTED) {
222                 error("CHAP: peer authentication already started!");
223                 return;
224         }
225         for (dp = chap_digests; dp != NULL; dp = dp->next)
226                 if (dp->code == digest_code)
227                         break;
228         if (dp == NULL)
229                 fatal("CHAP digest 0x%x requested but not available",
230                       digest_code);
231
232         ss->digest = dp;
233         ss->name = our_name;
234         /* Start with a random ID value */
235         ss->id = (unsigned char)(drand48() * 256);
236         ss->flags |= AUTH_STARTED;
237         if (ss->flags & LOWERUP)
238                 chap_server_timeout(ss);
239 }
240
241 /*
242  * chap_auth_with_peer - Prepare to authenticate ourselves to the peer.
243  * There isn't much to do until we receive a challenge.
244  */
245 void
246 chap_auth_with_peer(int unit, char *our_name, int digest_code)
247 {
248         struct chap_client_state *cs = &client;
249         struct chap_digest_type *dp;
250
251         if (cs->flags & AUTH_STARTED) {
252                 error("CHAP: authentication with peer already started!");
253                 return;
254         }
255         for (dp = chap_digests; dp != NULL; dp = dp->next)
256                 if (dp->code == digest_code)
257                         break;
258         if (dp == NULL)
259                 fatal("CHAP digest 0x%x requested but not available",
260                       digest_code);
261
262         cs->digest = dp;
263         cs->name = our_name;
264         cs->flags |= AUTH_STARTED | TIMEOUT_PENDING;
265         TIMEOUT(chap_client_timeout, cs, chap_client_timeout_time);
266 }
267
268 /*
269  * chap_server_timeout - It's time to send another challenge to the peer.
270  * This could be either a retransmission of a previous challenge,
271  * or a new challenge to start re-authentication.
272  */
273 static void
274 chap_server_timeout(void *arg)
275 {
276         struct chap_server_state *ss = arg;
277
278         ss->flags &= ~TIMEOUT_PENDING;
279         if ((ss->flags & CHALLENGE_VALID) == 0) {
280                 ss->challenge_xmits = 0;
281                 chap_generate_challenge(ss);
282                 ss->flags |= CHALLENGE_VALID;
283         } else if (ss->challenge_xmits >= chap_max_transmits) {
284                 ss->flags &= ~CHALLENGE_VALID;
285                 ss->flags |= AUTH_DONE | AUTH_FAILED;
286                 auth_peer_fail(0, PPP_CHAP);
287                 return;
288         }
289
290         output(0, ss->challenge, ss->challenge_pktlen);
291         ++ss->challenge_xmits;
292         ss->flags |= TIMEOUT_PENDING;
293         TIMEOUT(chap_server_timeout, arg, chap_server_timeout_time);
294 }
295
296 /* chap_client_timeout - Authentication with peer timed out. */
297 static void
298 chap_client_timeout(void *arg)
299 {
300         struct chap_client_state *cs = arg;
301
302         cs->flags &= ~TIMEOUT_PENDING;
303         cs->flags |= AUTH_DONE | AUTH_FAILED;
304         error("CHAP authentication timed out");
305         auth_withpeer_fail(0, PPP_CHAP);
306 }
307
308 /*
309  * chap_generate_challenge - generate a challenge string and format
310  * the challenge packet in ss->challenge_pkt.
311  */
312 static void
313 chap_generate_challenge(struct chap_server_state *ss)
314 {
315         int clen = 1, nlen, len;
316         unsigned char *p;
317
318         p = ss->challenge;
319         MAKEHEADER(p, PPP_CHAP);
320         p += CHAP_HDRLEN;
321         ss->digest->generate_challenge(p);
322         clen = *p;
323         nlen = strlen(ss->name);
324         memcpy(p + 1 + clen, ss->name, nlen);
325
326         len = CHAP_HDRLEN + 1 + clen + nlen;
327         ss->challenge_pktlen = PPP_HDRLEN + len;
328
329         p = ss->challenge + PPP_HDRLEN;
330         p[0] = CHAP_CHALLENGE;
331         p[1] = ++ss->id;
332         p[2] = len >> 8;
333         p[3] = len;
334 }
335
336 /*
337  * chap_handle_response - check the response to our challenge.
338  */
339 static void
340 chap_handle_response(struct chap_server_state *ss, int id,
341                      unsigned char *pkt, int len)
342 {
343         int response_len, ok, mlen;
344         unsigned char *response, *p;
345         char *name = NULL;      /* initialized to shut gcc up */
346         int (*verifier)(char *, char *, int, struct chap_digest_type *,
347                 unsigned char *, unsigned char *, char *, int);
348         char rname[MAXNAMELEN+1];
349
350         if ((ss->flags & LOWERUP) == 0)
351                 return;
352         if (id != ss->challenge[PPP_HDRLEN+1] || len < 2)
353                 return;
354         if (ss->flags & CHALLENGE_VALID) {
355                 response = pkt;
356                 GETCHAR(response_len, pkt);
357                 len -= response_len + 1;        /* length of name */
358                 name = (char *)pkt + response_len;
359                 if (len < 0)
360                         return;
361
362                 if (ss->flags & TIMEOUT_PENDING) {
363                         ss->flags &= ~TIMEOUT_PENDING;
364                         UNTIMEOUT(chap_server_timeout, ss);
365                 }
366
367                 if (explicit_remote) {
368                         name = remote_name;
369                 } else {
370                         /* Null terminate and clean remote name. */
371                         slprintf(rname, sizeof(rname), "%.*v", len, name);
372                         name = rname;
373
374                         /* strip the MS domain name */
375                         if (chapms_strip_domain && strrchr(rname, '\\')) {
376                                 char tmp[MAXNAMELEN+1];
377
378                                 strcpy(tmp, strrchr(rname, '\\') + 1);
379                                 strcpy(rname, tmp);
380                         }
381                 }
382
383                 if (chap_verify_hook)
384                         verifier = chap_verify_hook;
385                 else
386                         verifier = chap_verify_response;
387                 ok = (*verifier)(name, ss->name, id, ss->digest,
388                                  ss->challenge + PPP_HDRLEN + CHAP_HDRLEN,
389                                  response, ss->message, sizeof(ss->message));
390                 if (!ok || !auth_number()) {
391                         ss->flags |= AUTH_FAILED;
392                         warn("Peer %q failed CHAP authentication", name);
393                 }
394         } else if ((ss->flags & AUTH_DONE) == 0)
395                 return;
396
397         /* send the response */
398         p = outpacket_buf;
399         MAKEHEADER(p, PPP_CHAP);
400         mlen = strlen(ss->message);
401         len = CHAP_HDRLEN + mlen;
402         p[0] = (ss->flags & AUTH_FAILED)? CHAP_FAILURE: CHAP_SUCCESS;
403         p[1] = id;
404         p[2] = len >> 8;
405         p[3] = len;
406         if (mlen > 0)
407                 memcpy(p + CHAP_HDRLEN, ss->message, mlen);
408         output(0, outpacket_buf, PPP_HDRLEN + len);
409
410         if (ss->flags & CHALLENGE_VALID) {
411                 ss->flags &= ~CHALLENGE_VALID;
412                 if (!(ss->flags & AUTH_DONE) && !(ss->flags & AUTH_FAILED)) {
413                     /*
414                      * Auth is OK, so now we need to check session restrictions
415                      * to ensure everything is OK, but only if we used a
416                      * plugin, and only if we're configured to check.  This
417                      * allows us to do PAM checks on PPP servers that
418                      * authenticate against ActiveDirectory, and use AD for
419                      * account info (like when using Winbind integrated with
420                      * PAM).
421                      */
422                     if (session_mgmt &&
423                         session_check(name, NULL, devnam, NULL) == 0) {
424                         ss->flags |= AUTH_FAILED;
425                         warn("Peer %q failed CHAP Session verification", name);
426                     }
427                 }
428                 if (ss->flags & AUTH_FAILED) {
429                         auth_peer_fail(0, PPP_CHAP);
430                 } else {
431                         if ((ss->flags & AUTH_DONE) == 0)
432                                 auth_peer_success(0, PPP_CHAP,
433                                                   ss->digest->code,
434                                                   name, strlen(name));
435                         if (chap_rechallenge_time) {
436                                 ss->flags |= TIMEOUT_PENDING;
437                                 TIMEOUT(chap_server_timeout, ss,
438                                         chap_rechallenge_time);
439                         }
440                 }
441                 ss->flags |= AUTH_DONE;
442         }
443 }
444
445 /*
446  * chap_verify_response - check whether the peer's response matches
447  * what we think it should be.  Returns 1 if it does (authentication
448  * succeeded), or 0 if it doesn't.
449  */
450 static int
451 chap_verify_response(char *name, char *ourname, int id,
452                      struct chap_digest_type *digest,
453                      unsigned char *challenge, unsigned char *response,
454                      char *message, int message_space)
455 {
456         int ok;
457         unsigned char secret[MAXSECRETLEN];
458         int secret_len;
459
460         /* Get the secret that the peer is supposed to know */
461         if (!get_secret(0, name, ourname, (char *)secret, &secret_len, 1)) {
462                 error("No CHAP secret found for authenticating %q", name);
463                 return 0;
464         }
465
466         ok = digest->verify_response(id, name, secret, secret_len, challenge,
467                                      response, message, message_space);
468         memset(secret, 0, sizeof(secret));
469
470         return ok;
471 }
472
473 /*
474  * chap_respond - Generate and send a response to a challenge.
475  */
476 static void
477 chap_respond(struct chap_client_state *cs, int id,
478              unsigned char *pkt, int len)
479 {
480         int clen, nlen;
481         int secret_len;
482         unsigned char *p;
483         unsigned char response[RESP_MAX_PKTLEN];
484         char rname[MAXNAMELEN+1];
485         char secret[MAXSECRETLEN+1];
486
487         if ((cs->flags & (LOWERUP | AUTH_STARTED)) != (LOWERUP | AUTH_STARTED))
488                 return;         /* not ready */
489         if (len < 2 || len < pkt[0] + 1)
490                 return;         /* too short */
491         clen = pkt[0];
492         nlen = len - (clen + 1);
493
494         /* Null terminate and clean remote name. */
495         slprintf(rname, sizeof(rname), "%.*v", nlen, pkt + clen + 1);
496
497         /* Microsoft doesn't send their name back in the PPP packet */
498         if (explicit_remote || (remote_name[0] != 0 && rname[0] == 0))
499                 strlcpy(rname, remote_name, sizeof(rname));
500
501         /* get secret for authenticating ourselves with the specified host */
502         if (!get_secret(0, cs->name, rname, secret, &secret_len, 0)) {
503                 secret_len = 0; /* assume null secret if can't find one */
504                 warn("No CHAP secret found for authenticating us to %q", rname);
505         }
506
507         p = response;
508         MAKEHEADER(p, PPP_CHAP);
509         p += CHAP_HDRLEN;
510
511         cs->digest->make_response(p, id, cs->name, pkt,
512                                   secret, secret_len, cs->priv);
513         memset(secret, 0, secret_len);
514
515         clen = *p;
516         nlen = strlen(cs->name);
517         memcpy(p + clen + 1, cs->name, nlen);
518
519         p = response + PPP_HDRLEN;
520         len = CHAP_HDRLEN + clen + 1 + nlen;
521         p[0] = CHAP_RESPONSE;
522         p[1] = id;
523         p[2] = len >> 8;
524         p[3] = len;
525
526         output(0, response, PPP_HDRLEN + len);
527 }
528
529 static void
530 chap_handle_status(struct chap_client_state *cs, int code, int id,
531                    unsigned char *pkt, int len)
532 {
533         const char *msg = NULL;
534
535         if ((cs->flags & (AUTH_DONE|AUTH_STARTED|LOWERUP))
536             != (AUTH_STARTED|LOWERUP))
537                 return;
538         cs->flags |= AUTH_DONE;
539
540         UNTIMEOUT(chap_client_timeout, cs);
541         cs->flags &= ~TIMEOUT_PENDING;
542
543         if (code == CHAP_SUCCESS) {
544                 /* used for MS-CHAP v2 mutual auth, yuck */
545                 if (cs->digest->check_success != NULL) {
546                         if (!(*cs->digest->check_success)(id, pkt, len))
547                                 code = CHAP_FAILURE;
548                 } else
549                         msg = "CHAP authentication succeeded";
550         } else {
551                 if (cs->digest->handle_failure != NULL)
552                         (*cs->digest->handle_failure)(pkt, len);
553                 else
554                         msg = "CHAP authentication failed";
555         }
556         if (msg) {
557                 if (len > 0)
558                         info("%s: %.*v", msg, len, pkt);
559                 else
560                         info("%s", msg);
561         }
562         if (code == CHAP_SUCCESS)
563                 auth_withpeer_success(0, PPP_CHAP, cs->digest->code);
564         else {
565                 cs->flags |= AUTH_FAILED;
566                 error("CHAP authentication failed");
567                 auth_withpeer_fail(0, PPP_CHAP);
568         }
569 }
570
571 static void
572 chap_input(int unit, unsigned char *pkt, int pktlen)
573 {
574         struct chap_client_state *cs = &client;
575         struct chap_server_state *ss = &server;
576         unsigned char code, id;
577         int len;
578
579         if (pktlen < CHAP_HDRLEN)
580                 return;
581         GETCHAR(code, pkt);
582         GETCHAR(id, pkt);
583         GETSHORT(len, pkt);
584         if (len < CHAP_HDRLEN || len > pktlen)
585                 return;
586         len -= CHAP_HDRLEN;
587
588         switch (code) {
589         case CHAP_CHALLENGE:
590                 chap_respond(cs, id, pkt, len);
591                 break;
592         case CHAP_RESPONSE:
593                 chap_handle_response(ss, id, pkt, len);
594                 break;
595         case CHAP_FAILURE:
596         case CHAP_SUCCESS:
597                 chap_handle_status(cs, code, id, pkt, len);
598                 break;
599         }
600 }
601
602 static void
603 chap_protrej(int unit)
604 {
605         struct chap_client_state *cs = &client;
606         struct chap_server_state *ss = &server;
607
608         if (ss->flags & TIMEOUT_PENDING) {
609                 ss->flags &= ~TIMEOUT_PENDING;
610                 UNTIMEOUT(chap_server_timeout, ss);
611         }
612         if (ss->flags & AUTH_STARTED) {
613                 ss->flags = 0;
614                 auth_peer_fail(0, PPP_CHAP);
615         }
616         if ((cs->flags & (AUTH_STARTED|AUTH_DONE)) == AUTH_STARTED) {
617                 cs->flags &= ~AUTH_STARTED;
618                 error("CHAP authentication failed due to protocol-reject");
619                 auth_withpeer_fail(0, PPP_CHAP);
620         }
621 }
622
623 /*
624  * chap_print_pkt - print the contents of a CHAP packet.
625  */
626 static char *chap_code_names[] = {
627         "Challenge", "Response", "Success", "Failure"
628 };
629
630 static int
631 chap_print_pkt(unsigned char *p, int plen,
632                void (*printer)(void *, char *, ...), void *arg)
633 {
634         int code, id, len;
635         int clen, nlen;
636         unsigned char x;
637
638         if (plen < CHAP_HDRLEN)
639                 return 0;
640         GETCHAR(code, p);
641         GETCHAR(id, p);
642         GETSHORT(len, p);
643         if (len < CHAP_HDRLEN || len > plen)
644                 return 0;
645
646         if (code >= 1 && code <= sizeof(chap_code_names) / sizeof(char *))
647                 printer(arg, " %s", chap_code_names[code-1]);
648         else
649                 printer(arg, " code=0x%x", code);
650         printer(arg, " id=0x%x", id);
651         len -= CHAP_HDRLEN;
652         switch (code) {
653         case CHAP_CHALLENGE:
654         case CHAP_RESPONSE:
655                 if (len < 1)
656                         break;
657                 clen = p[0];
658                 if (len < clen + 1)
659                         break;
660                 ++p;
661                 nlen = len - clen - 1;
662                 printer(arg, " <");
663                 for (; clen > 0; --clen) {
664                         GETCHAR(x, p);
665                         printer(arg, "%.2x", x);
666                 }
667                 printer(arg, ">, name = ");
668                 print_string((char *)p, nlen, printer, arg);
669                 break;
670         case CHAP_FAILURE:
671         case CHAP_SUCCESS:
672                 printer(arg, " ");
673                 print_string((char *)p, len, printer, arg);
674                 break;
675         default:
676                 for (clen = len; clen > 0; --clen) {
677                         GETCHAR(x, p);
678                         printer(arg, " %.2x", x);
679                 }
680         }
681
682         return len + CHAP_HDRLEN;
683 }
684
685 struct protent chap_protent = {
686         PPP_CHAP,
687         chap_init,
688         chap_input,
689         chap_protrej,
690         chap_lowerup,
691         chap_lowerdown,
692         NULL,           /* open */
693         NULL,           /* close */
694         chap_print_pkt,
695         NULL,           /* datainput */
696         1,              /* enabled_flag */
697         "CHAP",         /* name */
698         NULL,           /* data_name */
699         chap_option_list,
700         NULL,           /* check_options */
701 };