]> git.ozlabs.org Git - ppp.git/blob - pppd/chap-new.c
Makefile.am: Add explicit openssl directory to pppd include path
[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
226         dp = chap_find_digest(digest_code);
227         if (dp == NULL)
228                 fatal("CHAP digest 0x%x requested but not available",
229                       digest_code);
230
231         ss->digest = dp;
232         ss->name = our_name;
233         /* Start with a random ID value */
234         ss->id = (unsigned char)(drand48() * 256);
235         ss->flags |= AUTH_STARTED;
236         if (ss->flags & LOWERUP)
237                 chap_server_timeout(ss);
238 }
239
240 /*
241  * chap_auth_with_peer - Prepare to authenticate ourselves to the peer.
242  * There isn't much to do until we receive a challenge.
243  */
244 void
245 chap_auth_with_peer(int unit, char *our_name, int digest_code)
246 {
247         struct chap_client_state *cs = &client;
248         struct chap_digest_type *dp;
249
250         if (cs->flags & AUTH_STARTED) {
251                 error("CHAP: authentication with peer already started!");
252                 return;
253         }
254         for (dp = chap_digests; dp != NULL; dp = dp->next)
255                 if (dp->code == digest_code)
256                         break;
257         if (dp == NULL)
258                 fatal("CHAP digest 0x%x requested but not available",
259                       digest_code);
260
261         cs->digest = dp;
262         cs->name = our_name;
263         cs->flags |= AUTH_STARTED | TIMEOUT_PENDING;
264         TIMEOUT(chap_client_timeout, cs, chap_client_timeout_time);
265 }
266
267 /*
268  * chap_server_timeout - It's time to send another challenge to the peer.
269  * This could be either a retransmission of a previous challenge,
270  * or a new challenge to start re-authentication.
271  */
272 static void
273 chap_server_timeout(void *arg)
274 {
275         struct chap_server_state *ss = arg;
276
277         ss->flags &= ~TIMEOUT_PENDING;
278         if ((ss->flags & CHALLENGE_VALID) == 0) {
279                 ss->challenge_xmits = 0;
280                 chap_generate_challenge(ss);
281                 ss->flags |= CHALLENGE_VALID;
282         } else if (ss->challenge_xmits >= chap_max_transmits) {
283                 ss->flags &= ~CHALLENGE_VALID;
284                 ss->flags |= AUTH_DONE | AUTH_FAILED;
285                 auth_peer_fail(0, PPP_CHAP);
286                 return;
287         }
288
289         output(0, ss->challenge, ss->challenge_pktlen);
290         ++ss->challenge_xmits;
291         ss->flags |= TIMEOUT_PENDING;
292         TIMEOUT(chap_server_timeout, arg, chap_server_timeout_time);
293 }
294
295 /* chap_client_timeout - Authentication with peer timed out. */
296 static void
297 chap_client_timeout(void *arg)
298 {
299         struct chap_client_state *cs = arg;
300
301         cs->flags &= ~TIMEOUT_PENDING;
302         cs->flags |= AUTH_DONE | AUTH_FAILED;
303         error("CHAP authentication timed out");
304         auth_withpeer_fail(0, PPP_CHAP);
305 }
306
307 /*
308  * chap_generate_challenge - generate a challenge string and format
309  * the challenge packet in ss->challenge_pkt.
310  */
311 static void
312 chap_generate_challenge(struct chap_server_state *ss)
313 {
314         int clen = 1, nlen, len;
315         unsigned char *p;
316
317         p = ss->challenge;
318         MAKEHEADER(p, PPP_CHAP);
319         p += CHAP_HDRLEN;
320         ss->digest->generate_challenge(p);
321         clen = *p;
322         nlen = strlen(ss->name);
323         memcpy(p + 1 + clen, ss->name, nlen);
324
325         len = CHAP_HDRLEN + 1 + clen + nlen;
326         ss->challenge_pktlen = PPP_HDRLEN + len;
327
328         p = ss->challenge + PPP_HDRLEN;
329         p[0] = CHAP_CHALLENGE;
330         p[1] = ++ss->id;
331         p[2] = len >> 8;
332         p[3] = len;
333 }
334
335 /*
336  * chap_handle_response - check the response to our challenge.
337  */
338 static void
339 chap_handle_response(struct chap_server_state *ss, int id,
340                      unsigned char *pkt, int len)
341 {
342         int response_len, ok, mlen;
343         unsigned char *response, *p;
344         char *name = NULL;      /* initialized to shut gcc up */
345         int (*verifier)(char *, char *, int, struct chap_digest_type *,
346                 unsigned char *, unsigned char *, char *, int);
347         char rname[MAXNAMELEN+1];
348
349         if ((ss->flags & LOWERUP) == 0)
350                 return;
351         if (id != ss->challenge[PPP_HDRLEN+1] || len < 2)
352                 return;
353         if (ss->flags & CHALLENGE_VALID) {
354                 response = pkt;
355                 GETCHAR(response_len, pkt);
356                 len -= response_len + 1;        /* length of name */
357                 name = (char *)pkt + response_len;
358                 if (len < 0)
359                         return;
360
361                 if (ss->flags & TIMEOUT_PENDING) {
362                         ss->flags &= ~TIMEOUT_PENDING;
363                         UNTIMEOUT(chap_server_timeout, ss);
364                 }
365
366                 if (explicit_remote) {
367                         name = remote_name;
368                 } else {
369                         /* Null terminate and clean remote name. */
370                         slprintf(rname, sizeof(rname), "%.*v", len, name);
371                         name = rname;
372
373                         /* strip the MS domain name */
374                         if (chapms_strip_domain && strrchr(rname, '\\')) {
375                                 char tmp[MAXNAMELEN+1];
376
377                                 strcpy(tmp, strrchr(rname, '\\') + 1);
378                                 strcpy(rname, tmp);
379                         }
380                 }
381
382                 if (chap_verify_hook)
383                         verifier = chap_verify_hook;
384                 else
385                         verifier = chap_verify_response;
386                 ok = (*verifier)(name, ss->name, id, ss->digest,
387                                  ss->challenge + PPP_HDRLEN + CHAP_HDRLEN,
388                                  response, ss->message, sizeof(ss->message));
389                 if (!ok || !auth_number()) {
390                         ss->flags |= AUTH_FAILED;
391                         warn("Peer %q failed CHAP authentication", name);
392                 }
393         } else if ((ss->flags & AUTH_DONE) == 0)
394                 return;
395
396         /* send the response */
397         p = outpacket_buf;
398         MAKEHEADER(p, PPP_CHAP);
399         mlen = strlen(ss->message);
400         len = CHAP_HDRLEN + mlen;
401         p[0] = (ss->flags & AUTH_FAILED)? CHAP_FAILURE: CHAP_SUCCESS;
402         p[1] = id;
403         p[2] = len >> 8;
404         p[3] = len;
405         if (mlen > 0)
406                 memcpy(p + CHAP_HDRLEN, ss->message, mlen);
407         output(0, outpacket_buf, PPP_HDRLEN + len);
408
409         if (ss->flags & CHALLENGE_VALID) {
410                 ss->flags &= ~CHALLENGE_VALID;
411                 if (!(ss->flags & AUTH_DONE) && !(ss->flags & AUTH_FAILED)) {
412                     /*
413                      * Auth is OK, so now we need to check session restrictions
414                      * to ensure everything is OK, but only if we used a
415                      * plugin, and only if we're configured to check.  This
416                      * allows us to do PAM checks on PPP servers that
417                      * authenticate against ActiveDirectory, and use AD for
418                      * account info (like when using Winbind integrated with
419                      * PAM).
420                      */
421                     if (session_mgmt &&
422                         session_check(name, NULL, devnam, NULL) == 0) {
423                         ss->flags |= AUTH_FAILED;
424                         warn("Peer %q failed CHAP Session verification", name);
425                     }
426                 }
427                 if (ss->flags & AUTH_FAILED) {
428                         auth_peer_fail(0, PPP_CHAP);
429                 } else {
430                         if ((ss->flags & AUTH_DONE) == 0)
431                                 auth_peer_success(0, PPP_CHAP,
432                                                   ss->digest->code,
433                                                   name, strlen(name));
434                         if (chap_rechallenge_time) {
435                                 ss->flags |= TIMEOUT_PENDING;
436                                 TIMEOUT(chap_server_timeout, ss,
437                                         chap_rechallenge_time);
438                         }
439                 }
440                 ss->flags |= AUTH_DONE;
441         }
442 }
443
444 /*
445  * chap_verify_response - check whether the peer's response matches
446  * what we think it should be.  Returns 1 if it does (authentication
447  * succeeded), or 0 if it doesn't.
448  */
449 static int
450 chap_verify_response(char *name, char *ourname, int id,
451                      struct chap_digest_type *digest,
452                      unsigned char *challenge, unsigned char *response,
453                      char *message, int message_space)
454 {
455         int ok;
456         unsigned char secret[MAXSECRETLEN];
457         int secret_len;
458
459         /* Get the secret that the peer is supposed to know */
460         if (!get_secret(0, name, ourname, (char *)secret, &secret_len, 1)) {
461                 error("No CHAP secret found for authenticating %q", name);
462                 return 0;
463         }
464
465         ok = digest->verify_response(id, name, secret, secret_len, challenge,
466                                      response, message, message_space);
467         memset(secret, 0, sizeof(secret));
468
469         return ok;
470 }
471
472 /*
473  * chap_respond - Generate and send a response to a challenge.
474  */
475 static void
476 chap_respond(struct chap_client_state *cs, int id,
477              unsigned char *pkt, int len)
478 {
479         int clen, nlen;
480         int secret_len;
481         unsigned char *p;
482         unsigned char response[RESP_MAX_PKTLEN];
483         char rname[MAXNAMELEN+1];
484         char secret[MAXSECRETLEN+1];
485
486         if ((cs->flags & (LOWERUP | AUTH_STARTED)) != (LOWERUP | AUTH_STARTED))
487                 return;         /* not ready */
488         if (len < 2 || len < pkt[0] + 1)
489                 return;         /* too short */
490         clen = pkt[0];
491         nlen = len - (clen + 1);
492
493         /* Null terminate and clean remote name. */
494         slprintf(rname, sizeof(rname), "%.*v", nlen, pkt + clen + 1);
495
496         /* Microsoft doesn't send their name back in the PPP packet */
497         if (explicit_remote || (remote_name[0] != 0 && rname[0] == 0))
498                 strlcpy(rname, remote_name, sizeof(rname));
499
500         /* get secret for authenticating ourselves with the specified host */
501         if (!get_secret(0, cs->name, rname, secret, &secret_len, 0)) {
502                 secret_len = 0; /* assume null secret if can't find one */
503                 warn("No CHAP secret found for authenticating us to %q", rname);
504         }
505
506         p = response;
507         MAKEHEADER(p, PPP_CHAP);
508         p += CHAP_HDRLEN;
509
510         cs->digest->make_response(p, id, cs->name, pkt,
511                                   secret, secret_len, cs->priv);
512         memset(secret, 0, secret_len);
513
514         clen = *p;
515         nlen = strlen(cs->name);
516         memcpy(p + clen + 1, cs->name, nlen);
517
518         p = response + PPP_HDRLEN;
519         len = CHAP_HDRLEN + clen + 1 + nlen;
520         p[0] = CHAP_RESPONSE;
521         p[1] = id;
522         p[2] = len >> 8;
523         p[3] = len;
524
525         output(0, response, PPP_HDRLEN + len);
526 }
527
528 static void
529 chap_handle_status(struct chap_client_state *cs, int code, int id,
530                    unsigned char *pkt, int len)
531 {
532         const char *msg = NULL;
533
534         if ((cs->flags & (AUTH_DONE|AUTH_STARTED|LOWERUP))
535             != (AUTH_STARTED|LOWERUP))
536                 return;
537         cs->flags |= AUTH_DONE;
538
539         UNTIMEOUT(chap_client_timeout, cs);
540         cs->flags &= ~TIMEOUT_PENDING;
541
542         if (code == CHAP_SUCCESS) {
543                 /* used for MS-CHAP v2 mutual auth, yuck */
544                 if (cs->digest->check_success != NULL) {
545                         if (!(*cs->digest->check_success)(id, pkt, len))
546                                 code = CHAP_FAILURE;
547                 } else
548                         msg = "CHAP authentication succeeded";
549         } else {
550                 if (cs->digest->handle_failure != NULL)
551                         (*cs->digest->handle_failure)(pkt, len);
552                 else
553                         msg = "CHAP authentication failed";
554         }
555         if (msg) {
556                 if (len > 0)
557                         info("%s: %.*v", msg, len, pkt);
558                 else
559                         info("%s", msg);
560         }
561         if (code == CHAP_SUCCESS)
562                 auth_withpeer_success(0, PPP_CHAP, cs->digest->code);
563         else {
564                 cs->flags |= AUTH_FAILED;
565                 error("CHAP authentication failed");
566                 auth_withpeer_fail(0, PPP_CHAP);
567         }
568 }
569
570 static void
571 chap_input(int unit, unsigned char *pkt, int pktlen)
572 {
573         struct chap_client_state *cs = &client;
574         struct chap_server_state *ss = &server;
575         unsigned char code, id;
576         int len;
577
578         if (pktlen < CHAP_HDRLEN)
579                 return;
580         GETCHAR(code, pkt);
581         GETCHAR(id, pkt);
582         GETSHORT(len, pkt);
583         if (len < CHAP_HDRLEN || len > pktlen)
584                 return;
585         len -= CHAP_HDRLEN;
586
587         switch (code) {
588         case CHAP_CHALLENGE:
589                 chap_respond(cs, id, pkt, len);
590                 break;
591         case CHAP_RESPONSE:
592                 chap_handle_response(ss, id, pkt, len);
593                 break;
594         case CHAP_FAILURE:
595         case CHAP_SUCCESS:
596                 chap_handle_status(cs, code, id, pkt, len);
597                 break;
598         }
599 }
600
601 static void
602 chap_protrej(int unit)
603 {
604         struct chap_client_state *cs = &client;
605         struct chap_server_state *ss = &server;
606
607         if (ss->flags & TIMEOUT_PENDING) {
608                 ss->flags &= ~TIMEOUT_PENDING;
609                 UNTIMEOUT(chap_server_timeout, ss);
610         }
611         if (ss->flags & AUTH_STARTED) {
612                 ss->flags = 0;
613                 auth_peer_fail(0, PPP_CHAP);
614         }
615         if ((cs->flags & (AUTH_STARTED|AUTH_DONE)) == AUTH_STARTED) {
616                 cs->flags &= ~AUTH_STARTED;
617                 error("CHAP authentication failed due to protocol-reject");
618                 auth_withpeer_fail(0, PPP_CHAP);
619         }
620 }
621
622 /*
623  * chap_print_pkt - print the contents of a CHAP packet.
624  */
625 static char *chap_code_names[] = {
626         "Challenge", "Response", "Success", "Failure"
627 };
628
629 static int
630 chap_print_pkt(unsigned char *p, int plen,
631                void (*printer)(void *, char *, ...), void *arg)
632 {
633         int code, id, len;
634         int clen, nlen;
635         unsigned char x;
636
637         if (plen < CHAP_HDRLEN)
638                 return 0;
639         GETCHAR(code, p);
640         GETCHAR(id, p);
641         GETSHORT(len, p);
642         if (len < CHAP_HDRLEN || len > plen)
643                 return 0;
644
645         if (code >= 1 && code <= sizeof(chap_code_names) / sizeof(char *))
646                 printer(arg, " %s", chap_code_names[code-1]);
647         else
648                 printer(arg, " code=0x%x", code);
649         printer(arg, " id=0x%x", id);
650         len -= CHAP_HDRLEN;
651         switch (code) {
652         case CHAP_CHALLENGE:
653         case CHAP_RESPONSE:
654                 if (len < 1)
655                         break;
656                 clen = p[0];
657                 if (len < clen + 1)
658                         break;
659                 ++p;
660                 nlen = len - clen - 1;
661                 printer(arg, " <");
662                 for (; clen > 0; --clen) {
663                         GETCHAR(x, p);
664                         printer(arg, "%.2x", x);
665                 }
666                 printer(arg, ">, name = ");
667                 print_string((char *)p, nlen, printer, arg);
668                 break;
669         case CHAP_FAILURE:
670         case CHAP_SUCCESS:
671                 printer(arg, " ");
672                 print_string((char *)p, len, printer, arg);
673                 break;
674         default:
675                 for (clen = len; clen > 0; --clen) {
676                         GETCHAR(x, p);
677                         printer(arg, " %.2x", x);
678                 }
679         }
680
681         return len + CHAP_HDRLEN;
682 }
683
684 struct protent chap_protent = {
685         PPP_CHAP,
686         chap_init,
687         chap_input,
688         chap_protrej,
689         chap_lowerup,
690         chap_lowerdown,
691         NULL,           /* open */
692         NULL,           /* close */
693         chap_print_pkt,
694         NULL,           /* datainput */
695         1,              /* enabled_flag */
696         "CHAP",         /* name */
697         NULL,           /* data_name */
698         chap_option_list,
699         NULL,           /* check_options */
700 };