chap-new.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  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. #define RCSID "$Id: chap-new.c,v 1.9 2007/06/19 02:08:35 carlsonj Exp $"
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include "pppd.h"
  34. #include "session.h"
  35. #include "chap-new.h"
  36. #include "chap-md5.h"
  37. #ifdef CHAPMS
  38. #include "chap_ms.h"
  39. #define MDTYPE_ALL (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5)
  40. #else
  41. #define MDTYPE_ALL (MDTYPE_MD5)
  42. #endif
  43. int chap_mdtype_all = MDTYPE_ALL;
  44. /* Hook for a plugin to validate CHAP challenge */
  45. int (*chap_verify_hook)(char *name, char *ourname, int id,
  46. struct chap_digest_type *digest,
  47. unsigned char *challenge, unsigned char *response,
  48. char *message, int message_space) = NULL;
  49. /*
  50. * Option variables.
  51. */
  52. int chap_timeout_time = 3;
  53. int chap_max_transmits = 10;
  54. int chap_rechallenge_time = 0;
  55. /*
  56. * Command-line options.
  57. */
  58. static option_t chap_option_list[] = {
  59. { "chap-restart", o_int, &chap_timeout_time,
  60. "Set timeout for CHAP", OPT_PRIO },
  61. { "chap-max-challenge", o_int, &chap_max_transmits,
  62. "Set max #xmits for challenge", OPT_PRIO },
  63. { "chap-interval", o_int, &chap_rechallenge_time,
  64. "Set interval for rechallenge", OPT_PRIO },
  65. { NULL }
  66. };
  67. /*
  68. * Internal state.
  69. */
  70. static struct chap_client_state {
  71. int flags;
  72. char *name;
  73. struct chap_digest_type *digest;
  74. unsigned char priv[64]; /* private area for digest's use */
  75. } client;
  76. /*
  77. * These limits apply to challenge and response packets we send.
  78. * The +4 is the +1 that we actually need rounded up.
  79. */
  80. #define CHAL_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_CHALLENGE_LEN + MAXNAMELEN)
  81. #define RESP_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_RESPONSE_LEN + MAXNAMELEN)
  82. static struct chap_server_state {
  83. int flags;
  84. int id;
  85. char *name;
  86. struct chap_digest_type *digest;
  87. int challenge_xmits;
  88. int challenge_pktlen;
  89. unsigned char challenge[CHAL_MAX_PKTLEN];
  90. char message[256];
  91. } server;
  92. /* Values for flags in chap_client_state and chap_server_state */
  93. #define LOWERUP 1
  94. #define AUTH_STARTED 2
  95. #define AUTH_DONE 4
  96. #define AUTH_FAILED 8
  97. #define TIMEOUT_PENDING 0x10
  98. #define CHALLENGE_VALID 0x20
  99. /*
  100. * Prototypes.
  101. */
  102. static void chap_init(int unit);
  103. static void chap_lowerup(int unit);
  104. static void chap_lowerdown(int unit);
  105. static void chap_timeout(void *arg);
  106. static void chap_generate_challenge(struct chap_server_state *ss);
  107. static void chap_handle_response(struct chap_server_state *ss, int code,
  108. unsigned char *pkt, int len);
  109. static int chap_verify_response(char *name, char *ourname, int id,
  110. struct chap_digest_type *digest,
  111. unsigned char *challenge, unsigned char *response,
  112. char *message, int message_space);
  113. static void chap_respond(struct chap_client_state *cs, int id,
  114. unsigned char *pkt, int len);
  115. static void chap_handle_status(struct chap_client_state *cs, int code, int id,
  116. unsigned char *pkt, int len);
  117. static void chap_protrej(int unit);
  118. static void chap_input(int unit, unsigned char *pkt, int pktlen);
  119. static int chap_print_pkt(unsigned char *p, int plen,
  120. void (*printer) __P((void *, char *, ...)), void *arg);
  121. /* List of digest types that we know about */
  122. static struct chap_digest_type *chap_digests;
  123. /*
  124. * chap_init - reset to initial state.
  125. */
  126. static void
  127. chap_init(int unit)
  128. {
  129. memset(&client, 0, sizeof(client));
  130. memset(&server, 0, sizeof(server));
  131. chap_md5_init();
  132. #ifdef CHAPMS
  133. chapms_init();
  134. #endif
  135. }
  136. /*
  137. * Add a new digest type to the list.
  138. */
  139. void
  140. chap_register_digest(struct chap_digest_type *dp)
  141. {
  142. dp->next = chap_digests;
  143. chap_digests = dp;
  144. }
  145. /*
  146. * chap_lowerup - we can start doing stuff now.
  147. */
  148. static void
  149. chap_lowerup(int unit)
  150. {
  151. struct chap_client_state *cs = &client;
  152. struct chap_server_state *ss = &server;
  153. cs->flags |= LOWERUP;
  154. ss->flags |= LOWERUP;
  155. if (ss->flags & AUTH_STARTED)
  156. chap_timeout(ss);
  157. }
  158. static void
  159. chap_lowerdown(int unit)
  160. {
  161. struct chap_client_state *cs = &client;
  162. struct chap_server_state *ss = &server;
  163. cs->flags = 0;
  164. if (ss->flags & TIMEOUT_PENDING)
  165. UNTIMEOUT(chap_timeout, ss);
  166. ss->flags = 0;
  167. }
  168. /*
  169. * chap_auth_peer - Start authenticating the peer.
  170. * If the lower layer is already up, we start sending challenges,
  171. * otherwise we wait for the lower layer to come up.
  172. */
  173. void
  174. chap_auth_peer(int unit, char *our_name, int digest_code)
  175. {
  176. struct chap_server_state *ss = &server;
  177. struct chap_digest_type *dp;
  178. if (ss->flags & AUTH_STARTED) {
  179. error("CHAP: peer authentication already started!");
  180. return;
  181. }
  182. for (dp = chap_digests; dp != NULL; dp = dp->next)
  183. if (dp->code == digest_code)
  184. break;
  185. if (dp == NULL)
  186. fatal("CHAP digest 0x%x requested but not available",
  187. digest_code);
  188. ss->digest = dp;
  189. ss->name = our_name;
  190. /* Start with a random ID value */
  191. ss->id = (unsigned char)(drand48() * 256);
  192. ss->flags |= AUTH_STARTED;
  193. if (ss->flags & LOWERUP)
  194. chap_timeout(ss);
  195. }
  196. /*
  197. * chap_auth_with_peer - Prepare to authenticate ourselves to the peer.
  198. * There isn't much to do until we receive a challenge.
  199. */
  200. void
  201. chap_auth_with_peer(int unit, char *our_name, int digest_code)
  202. {
  203. struct chap_client_state *cs = &client;
  204. struct chap_digest_type *dp;
  205. if (cs->flags & AUTH_STARTED) {
  206. error("CHAP: authentication with peer already started!");
  207. return;
  208. }
  209. for (dp = chap_digests; dp != NULL; dp = dp->next)
  210. if (dp->code == digest_code)
  211. break;
  212. if (dp == NULL)
  213. fatal("CHAP digest 0x%x requested but not available",
  214. digest_code);
  215. cs->digest = dp;
  216. cs->name = our_name;
  217. cs->flags |= AUTH_STARTED;
  218. }
  219. /*
  220. * chap_timeout - It's time to send another challenge to the peer.
  221. * This could be either a retransmission of a previous challenge,
  222. * or a new challenge to start re-authentication.
  223. */
  224. static void
  225. chap_timeout(void *arg)
  226. {
  227. struct chap_server_state *ss = arg;
  228. ss->flags &= ~TIMEOUT_PENDING;
  229. if ((ss->flags & CHALLENGE_VALID) == 0) {
  230. ss->challenge_xmits = 0;
  231. chap_generate_challenge(ss);
  232. ss->flags |= CHALLENGE_VALID;
  233. } else if (ss->challenge_xmits >= chap_max_transmits) {
  234. ss->flags &= ~CHALLENGE_VALID;
  235. ss->flags |= AUTH_DONE | AUTH_FAILED;
  236. auth_peer_fail(0, PPP_CHAP);
  237. return;
  238. }
  239. output(0, ss->challenge, ss->challenge_pktlen);
  240. ++ss->challenge_xmits;
  241. ss->flags |= TIMEOUT_PENDING;
  242. TIMEOUT(chap_timeout, arg, chap_timeout_time);
  243. }
  244. /*
  245. * chap_generate_challenge - generate a challenge string and format
  246. * the challenge packet in ss->challenge_pkt.
  247. */
  248. static void
  249. chap_generate_challenge(struct chap_server_state *ss)
  250. {
  251. int clen = 1, nlen, len;
  252. unsigned char *p;
  253. p = ss->challenge;
  254. MAKEHEADER(p, PPP_CHAP);
  255. p += CHAP_HDRLEN;
  256. ss->digest->generate_challenge(p);
  257. clen = *p;
  258. nlen = strlen(ss->name);
  259. memcpy(p + 1 + clen, ss->name, nlen);
  260. len = CHAP_HDRLEN + 1 + clen + nlen;
  261. ss->challenge_pktlen = PPP_HDRLEN + len;
  262. p = ss->challenge + PPP_HDRLEN;
  263. p[0] = CHAP_CHALLENGE;
  264. p[1] = ++ss->id;
  265. p[2] = len >> 8;
  266. p[3] = len;
  267. }
  268. /*
  269. * chap_handle_response - check the response to our challenge.
  270. */
  271. static void
  272. chap_handle_response(struct chap_server_state *ss, int id,
  273. unsigned char *pkt, int len)
  274. {
  275. int response_len, ok, mlen;
  276. unsigned char *response, *p;
  277. char *name = NULL; /* initialized to shut gcc up */
  278. int (*verifier)(char *, char *, int, struct chap_digest_type *,
  279. unsigned char *, unsigned char *, char *, int);
  280. char rname[MAXNAMELEN+1];
  281. if ((ss->flags & LOWERUP) == 0)
  282. return;
  283. if (id != ss->challenge[PPP_HDRLEN+1] || len < 2)
  284. return;
  285. if (ss->flags & CHALLENGE_VALID) {
  286. response = pkt;
  287. GETCHAR(response_len, pkt);
  288. len -= response_len + 1; /* length of name */
  289. name = (char *)pkt + response_len;
  290. if (len < 0)
  291. return;
  292. if (ss->flags & TIMEOUT_PENDING) {
  293. ss->flags &= ~TIMEOUT_PENDING;
  294. UNTIMEOUT(chap_timeout, ss);
  295. }
  296. if (explicit_remote) {
  297. name = remote_name;
  298. } else {
  299. /* Null terminate and clean remote name. */
  300. slprintf(rname, sizeof(rname), "%.*v", len, name);
  301. name = rname;
  302. }
  303. if (chap_verify_hook)
  304. verifier = chap_verify_hook;
  305. else
  306. verifier = chap_verify_response;
  307. ok = (*verifier)(name, ss->name, id, ss->digest,
  308. ss->challenge + PPP_HDRLEN + CHAP_HDRLEN,
  309. response, ss->message, sizeof(ss->message));
  310. if (!ok || !auth_number()) {
  311. ss->flags |= AUTH_FAILED;
  312. warn("Peer %q failed CHAP authentication", name);
  313. }
  314. } else if ((ss->flags & AUTH_DONE) == 0)
  315. return;
  316. /* send the response */
  317. p = outpacket_buf;
  318. MAKEHEADER(p, PPP_CHAP);
  319. mlen = strlen(ss->message);
  320. len = CHAP_HDRLEN + mlen;
  321. p[0] = (ss->flags & AUTH_FAILED)? CHAP_FAILURE: CHAP_SUCCESS;
  322. p[1] = id;
  323. p[2] = len >> 8;
  324. p[3] = len;
  325. if (mlen > 0)
  326. memcpy(p + CHAP_HDRLEN, ss->message, mlen);
  327. output(0, outpacket_buf, PPP_HDRLEN + len);
  328. if (ss->flags & CHALLENGE_VALID) {
  329. ss->flags &= ~CHALLENGE_VALID;
  330. if (!(ss->flags & AUTH_DONE) && !(ss->flags & AUTH_FAILED)) {
  331. /*
  332. * Auth is OK, so now we need to check session restrictions
  333. * to ensure everything is OK, but only if we used a
  334. * plugin, and only if we're configured to check. This
  335. * allows us to do PAM checks on PPP servers that
  336. * authenticate against ActiveDirectory, and use AD for
  337. * account info (like when using Winbind integrated with
  338. * PAM).
  339. */
  340. if (session_mgmt &&
  341. session_check(name, NULL, devnam, NULL) == 0) {
  342. ss->flags |= AUTH_FAILED;
  343. warn("Peer %q failed CHAP Session verification", name);
  344. }
  345. }
  346. if (ss->flags & AUTH_FAILED) {
  347. auth_peer_fail(0, PPP_CHAP);
  348. } else {
  349. if ((ss->flags & AUTH_DONE) == 0)
  350. auth_peer_success(0, PPP_CHAP,
  351. ss->digest->code,
  352. name, strlen(name));
  353. if (chap_rechallenge_time) {
  354. ss->flags |= TIMEOUT_PENDING;
  355. TIMEOUT(chap_timeout, ss,
  356. chap_rechallenge_time);
  357. }
  358. }
  359. ss->flags |= AUTH_DONE;
  360. }
  361. }
  362. /*
  363. * chap_verify_response - check whether the peer's response matches
  364. * what we think it should be. Returns 1 if it does (authentication
  365. * succeeded), or 0 if it doesn't.
  366. */
  367. static int
  368. chap_verify_response(char *name, char *ourname, int id,
  369. struct chap_digest_type *digest,
  370. unsigned char *challenge, unsigned char *response,
  371. char *message, int message_space)
  372. {
  373. int ok;
  374. unsigned char secret[MAXSECRETLEN];
  375. int secret_len;
  376. /* Get the secret that the peer is supposed to know */
  377. if (!get_secret(0, name, ourname, (char *)secret, &secret_len, 1)) {
  378. error("No CHAP secret found for authenticating %q", name);
  379. return 0;
  380. }
  381. ok = digest->verify_response(id, name, secret, secret_len, challenge,
  382. response, message, message_space);
  383. memset(secret, 0, sizeof(secret));
  384. return ok;
  385. }
  386. /*
  387. * chap_respond - Generate and send a response to a challenge.
  388. */
  389. static void
  390. chap_respond(struct chap_client_state *cs, int id,
  391. unsigned char *pkt, int len)
  392. {
  393. int clen, nlen;
  394. int secret_len;
  395. unsigned char *p;
  396. unsigned char response[RESP_MAX_PKTLEN];
  397. char rname[MAXNAMELEN+1];
  398. char secret[MAXSECRETLEN+1];
  399. if ((cs->flags & (LOWERUP | AUTH_STARTED)) != (LOWERUP | AUTH_STARTED))
  400. return; /* not ready */
  401. if (len < 2 || len < pkt[0] + 1)
  402. return; /* too short */
  403. clen = pkt[0];
  404. nlen = len - (clen + 1);
  405. /* Null terminate and clean remote name. */
  406. slprintf(rname, sizeof(rname), "%.*v", nlen, pkt + clen + 1);
  407. /* Microsoft doesn't send their name back in the PPP packet */
  408. if (explicit_remote || (remote_name[0] != 0 && rname[0] == 0))
  409. strlcpy(rname, remote_name, sizeof(rname));
  410. /* get secret for authenticating ourselves with the specified host */
  411. if (!get_secret(0, cs->name, rname, secret, &secret_len, 0)) {
  412. secret_len = 0; /* assume null secret if can't find one */
  413. warn("No CHAP secret found for authenticating us to %q", rname);
  414. }
  415. p = response;
  416. MAKEHEADER(p, PPP_CHAP);
  417. p += CHAP_HDRLEN;
  418. cs->digest->make_response(p, id, cs->name, pkt,
  419. secret, secret_len, cs->priv);
  420. memset(secret, 0, secret_len);
  421. clen = *p;
  422. nlen = strlen(cs->name);
  423. memcpy(p + clen + 1, cs->name, nlen);
  424. p = response + PPP_HDRLEN;
  425. len = CHAP_HDRLEN + clen + 1 + nlen;
  426. p[0] = CHAP_RESPONSE;
  427. p[1] = id;
  428. p[2] = len >> 8;
  429. p[3] = len;
  430. output(0, response, PPP_HDRLEN + len);
  431. }
  432. static void
  433. chap_handle_status(struct chap_client_state *cs, int code, int id,
  434. unsigned char *pkt, int len)
  435. {
  436. const char *msg = NULL;
  437. if ((cs->flags & (AUTH_DONE|AUTH_STARTED|LOWERUP))
  438. != (AUTH_STARTED|LOWERUP))
  439. return;
  440. cs->flags |= AUTH_DONE;
  441. if (code == CHAP_SUCCESS) {
  442. /* used for MS-CHAP v2 mutual auth, yuck */
  443. if (cs->digest->check_success != NULL) {
  444. if (!(*cs->digest->check_success)(id, pkt, len))
  445. code = CHAP_FAILURE;
  446. } else
  447. msg = "CHAP authentication succeeded";
  448. } else {
  449. if (cs->digest->handle_failure != NULL)
  450. (*cs->digest->handle_failure)(pkt, len);
  451. else
  452. msg = "CHAP authentication failed";
  453. }
  454. if (msg) {
  455. if (len > 0)
  456. info("%s: %.*v", msg, len, pkt);
  457. else
  458. info("%s", msg);
  459. }
  460. if (code == CHAP_SUCCESS)
  461. auth_withpeer_success(0, PPP_CHAP, cs->digest->code);
  462. else {
  463. cs->flags |= AUTH_FAILED;
  464. error("CHAP authentication failed");
  465. auth_withpeer_fail(0, PPP_CHAP);
  466. }
  467. }
  468. static void
  469. chap_input(int unit, unsigned char *pkt, int pktlen)
  470. {
  471. struct chap_client_state *cs = &client;
  472. struct chap_server_state *ss = &server;
  473. unsigned char code, id;
  474. int len;
  475. if (pktlen < CHAP_HDRLEN)
  476. return;
  477. GETCHAR(code, pkt);
  478. GETCHAR(id, pkt);
  479. GETSHORT(len, pkt);
  480. if (len < CHAP_HDRLEN || len > pktlen)
  481. return;
  482. len -= CHAP_HDRLEN;
  483. switch (code) {
  484. case CHAP_CHALLENGE:
  485. chap_respond(cs, id, pkt, len);
  486. break;
  487. case CHAP_RESPONSE:
  488. chap_handle_response(ss, id, pkt, len);
  489. break;
  490. case CHAP_FAILURE:
  491. case CHAP_SUCCESS:
  492. chap_handle_status(cs, code, id, pkt, len);
  493. break;
  494. }
  495. }
  496. static void
  497. chap_protrej(int unit)
  498. {
  499. struct chap_client_state *cs = &client;
  500. struct chap_server_state *ss = &server;
  501. if (ss->flags & TIMEOUT_PENDING) {
  502. ss->flags &= ~TIMEOUT_PENDING;
  503. UNTIMEOUT(chap_timeout, ss);
  504. }
  505. if (ss->flags & AUTH_STARTED) {
  506. ss->flags = 0;
  507. auth_peer_fail(0, PPP_CHAP);
  508. }
  509. if ((cs->flags & (AUTH_STARTED|AUTH_DONE)) == AUTH_STARTED) {
  510. cs->flags &= ~AUTH_STARTED;
  511. error("CHAP authentication failed due to protocol-reject");
  512. auth_withpeer_fail(0, PPP_CHAP);
  513. }
  514. }
  515. /*
  516. * chap_print_pkt - print the contents of a CHAP packet.
  517. */
  518. static char *chap_code_names[] = {
  519. "Challenge", "Response", "Success", "Failure"
  520. };
  521. static int
  522. chap_print_pkt(unsigned char *p, int plen,
  523. void (*printer) __P((void *, char *, ...)), void *arg)
  524. {
  525. int code, id, len;
  526. int clen, nlen;
  527. unsigned char x;
  528. if (plen < CHAP_HDRLEN)
  529. return 0;
  530. GETCHAR(code, p);
  531. GETCHAR(id, p);
  532. GETSHORT(len, p);
  533. if (len < CHAP_HDRLEN || len > plen)
  534. return 0;
  535. if (code >= 1 && code <= sizeof(chap_code_names) / sizeof(char *))
  536. printer(arg, " %s", chap_code_names[code-1]);
  537. else
  538. printer(arg, " code=0x%x", code);
  539. printer(arg, " id=0x%x", id);
  540. len -= CHAP_HDRLEN;
  541. switch (code) {
  542. case CHAP_CHALLENGE:
  543. case CHAP_RESPONSE:
  544. if (len < 1)
  545. break;
  546. clen = p[0];
  547. if (len < clen + 1)
  548. break;
  549. ++p;
  550. nlen = len - clen - 1;
  551. printer(arg, " <");
  552. for (; clen > 0; --clen) {
  553. GETCHAR(x, p);
  554. printer(arg, "%.2x", x);
  555. }
  556. printer(arg, ">, name = ");
  557. print_string((char *)p, nlen, printer, arg);
  558. break;
  559. case CHAP_FAILURE:
  560. case CHAP_SUCCESS:
  561. printer(arg, " ");
  562. print_string((char *)p, len, printer, arg);
  563. break;
  564. default:
  565. for (clen = len; clen > 0; --clen) {
  566. GETCHAR(x, p);
  567. printer(arg, " %.2x", x);
  568. }
  569. }
  570. return len + CHAP_HDRLEN;
  571. }
  572. struct protent chap_protent = {
  573. PPP_CHAP,
  574. chap_init,
  575. chap_input,
  576. chap_protrej,
  577. chap_lowerup,
  578. chap_lowerdown,
  579. NULL, /* open */
  580. NULL, /* close */
  581. chap_print_pkt,
  582. NULL, /* datainput */
  583. 1, /* enabled_flag */
  584. "CHAP", /* name */
  585. NULL, /* data_name */
  586. chap_option_list,
  587. NULL, /* check_options */
  588. };