1 pppd: add support for MPPE and MPPC encryption and compression protocols
3 This is a forward ported version of ppp-2.4.3-mppe-mppc-1.1.patch.gz found on
4 http://mppe-mppc.alphacron.de/ .
6 Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
8 --- a/include/linux/ppp-comp.h
9 +++ b/include/linux/ppp-comp.h
14 - * ==FILEVERSION 20020319==
15 + * ==FILEVERSION 20020715==
17 * NOTE TO MAINTAINERS:
18 * If you modify this file at all, please set the above date.
19 @@ -201,6 +201,33 @@ struct compressor {
20 #define CI_MPPE 18 /* config option for MPPE */
21 #define CILEN_MPPE 6 /* length of config option */
23 +/* MPPE/MPPC definitions by J.D.*/
24 +#define MPPE_STATELESS MPPE_H_BIT /* configuration bit H */
25 +#define MPPE_40BIT MPPE_L_BIT /* configuration bit L */
26 +#define MPPE_56BIT MPPE_M_BIT /* configuration bit M */
27 +#define MPPE_128BIT MPPE_S_BIT /* configuration bit S */
28 +#define MPPE_MPPC MPPE_C_BIT /* configuration bit C */
31 + * Definitions for Stac LZS.
34 +#define CI_LZS 17 /* config option for Stac LZS */
35 +#define CILEN_LZS 5 /* length of config option */
37 +#define LZS_OVHD 4 /* max. LZS overhead */
38 +#define LZS_HIST_LEN 2048 /* LZS history size */
39 +#define LZS_MAX_CCOUNT 0x0FFF /* max. coherency counter value */
41 +#define LZS_MODE_NONE 0
42 +#define LZS_MODE_LCB 1
43 +#define LZS_MODE_CRC 2
44 +#define LZS_MODE_SEQ 3
45 +#define LZS_MODE_EXT 4
47 +#define LZS_EXT_BIT_FLUSHED 0x80 /* bit A */
48 +#define LZS_EXT_BIT_COMP 0x20 /* bit C */
51 * Definitions for other, as yet unsupported, compression methods.
53 --- a/include/net/ppp-comp.h
54 +++ b/include/net/ppp-comp.h
55 @@ -168,6 +168,33 @@ struct compressor {
56 #define CI_MPPE 18 /* config option for MPPE */
57 #define CILEN_MPPE 6 /* length of config option */
59 +/* MPPE/MPPC definitions by J.D.*/
60 +#define MPPE_STATELESS MPPE_H_BIT /* configuration bit H */
61 +#define MPPE_40BIT MPPE_L_BIT /* configuration bit L */
62 +#define MPPE_56BIT MPPE_M_BIT /* configuration bit M */
63 +#define MPPE_128BIT MPPE_S_BIT /* configuration bit S */
64 +#define MPPE_MPPC MPPE_C_BIT /* configuration bit C */
67 + * Definitions for Stac LZS.
70 +#define CI_LZS 17 /* config option for Stac LZS */
71 +#define CILEN_LZS 5 /* length of config option */
73 +#define LZS_OVHD 4 /* max. LZS overhead */
74 +#define LZS_HIST_LEN 2048 /* LZS history size */
75 +#define LZS_MAX_CCOUNT 0x0FFF /* max. coherency counter value */
77 +#define LZS_MODE_NONE 0
78 +#define LZS_MODE_LCB 1
79 +#define LZS_MODE_CRC 2
80 +#define LZS_MODE_SEQ 3
81 +#define LZS_MODE_EXT 4
83 +#define LZS_EXT_BIT_FLUSHED 0x80 /* bit A */
84 +#define LZS_EXT_BIT_COMP 0x20 /* bit C */
87 * Definitions for other, as yet unsupported, compression methods.
91 @@ -62,12 +62,10 @@ static int setdeflate __P((char **));
92 static char bsd_value[8];
93 static char deflate_value[8];
99 -bool refuse_mppe_stateful = 1; /* Allow stateful mode? */
101 +static int setmppe(char **);
102 +static int setnomppe(void);
105 static option_t ccp_option_list[] = {
106 { "noccp", o_bool, &ccp_protent.enabled_flag,
107 @@ -108,54 +106,36 @@ static option_t ccp_option_list[] = {
108 "don't allow Predictor-1", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
109 &ccp_allowoptions[0].predictor_1 },
111 + { "lzs", o_bool, &ccp_wantoptions[0].lzs,
112 + "request Stac LZS", 1, &ccp_allowoptions[0].lzs, OPT_PRIO },
113 + { "+lzs", o_bool, &ccp_wantoptions[0].lzs,
114 + "request Stac LZS", 1, &ccp_allowoptions[0].lzs, OPT_ALIAS | OPT_PRIO },
115 + { "nolzs", o_bool, &ccp_wantoptions[0].lzs,
116 + "don't allow Stac LZS", OPT_PRIOSUB | OPT_A2CLR,
117 + &ccp_allowoptions[0].lzs },
118 + { "-lzs", o_bool, &ccp_wantoptions[0].lzs,
119 + "don't allow Stac LZS", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
120 + &ccp_allowoptions[0].lzs },
123 - /* MPPE options are symmetrical ... we only set wantoptions here */
124 - { "require-mppe", o_bool, &ccp_wantoptions[0].mppe,
125 - "require MPPE encryption",
126 - OPT_PRIO | MPPE_OPT_40 | MPPE_OPT_128 },
127 - { "+mppe", o_bool, &ccp_wantoptions[0].mppe,
128 - "require MPPE encryption",
129 - OPT_ALIAS | OPT_PRIO | MPPE_OPT_40 | MPPE_OPT_128 },
130 - { "nomppe", o_bool, &ccp_wantoptions[0].mppe,
131 - "don't allow MPPE encryption", OPT_PRIO },
132 - { "-mppe", o_bool, &ccp_wantoptions[0].mppe,
133 - "don't allow MPPE encryption", OPT_ALIAS | OPT_PRIO },
135 - /* We use ccp_allowoptions[0].mppe as a junk var ... it is reset later */
136 - { "require-mppe-40", o_bool, &ccp_allowoptions[0].mppe,
137 - "require MPPE 40-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_40,
138 - &ccp_wantoptions[0].mppe },
139 - { "+mppe-40", o_bool, &ccp_allowoptions[0].mppe,
140 - "require MPPE 40-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_40,
141 - &ccp_wantoptions[0].mppe },
142 - { "nomppe-40", o_bool, &ccp_allowoptions[0].mppe,
143 - "don't allow MPPE 40-bit encryption",
144 - OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_40, &ccp_wantoptions[0].mppe },
145 - { "-mppe-40", o_bool, &ccp_allowoptions[0].mppe,
146 - "don't allow MPPE 40-bit encryption",
147 - OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_40,
148 - &ccp_wantoptions[0].mppe },
150 - { "require-mppe-128", o_bool, &ccp_allowoptions[0].mppe,
151 - "require MPPE 128-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_128,
152 - &ccp_wantoptions[0].mppe },
153 - { "+mppe-128", o_bool, &ccp_allowoptions[0].mppe,
154 - "require MPPE 128-bit encryption",
155 - OPT_ALIAS | OPT_PRIO | OPT_A2OR | MPPE_OPT_128,
156 - &ccp_wantoptions[0].mppe },
157 - { "nomppe-128", o_bool, &ccp_allowoptions[0].mppe,
158 - "don't allow MPPE 128-bit encryption",
159 - OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_128, &ccp_wantoptions[0].mppe },
160 - { "-mppe-128", o_bool, &ccp_allowoptions[0].mppe,
161 - "don't allow MPPE 128-bit encryption",
162 - OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_128,
163 - &ccp_wantoptions[0].mppe },
165 - /* strange one; we always request stateless, but will we allow stateful? */
166 - { "mppe-stateful", o_bool, &refuse_mppe_stateful,
167 - "allow MPPE stateful mode", OPT_PRIO },
168 - { "nomppe-stateful", o_bool, &refuse_mppe_stateful,
169 - "disallow MPPE stateful mode", OPT_PRIO | 1 },
170 + { "mppc", o_bool, &ccp_wantoptions[0].mppc,
171 + "request MPPC compression", 1, &ccp_allowoptions[0].mppc },
172 + { "+mppc", o_bool, &ccp_wantoptions[0].mppc,
173 + "request MPPC compression", 1, &ccp_allowoptions[0].mppc, OPT_ALIAS },
174 + { "nomppc", o_bool, &ccp_wantoptions[0].mppc,
175 + "don't allow MPPC compression", OPT_PRIOSUB | OPT_A2CLR,
176 + &ccp_allowoptions[0].mppc },
177 + { "-mppc", o_bool, &ccp_wantoptions[0].mppc,
178 + "don't allow MPPC compression", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
179 + &ccp_allowoptions[0].mppc },
180 + { "mppe", o_special, (void *)setmppe,
181 + "request MPPE encryption" },
182 + { "+mppe", o_special, (void *)setmppe,
183 + "request MPPE encryption" },
184 + { "nomppe", o_special_noarg, (void *)setnomppe,
185 + "don't allow MPPE encryption" },
186 + { "-mppe", o_special_noarg, (void *)setnomppe,
187 + "don't allow MPPE encryption" },
191 @@ -241,7 +221,7 @@ static fsm_callbacks ccp_callbacks = {
193 #define ANY_COMPRESS(opt) ((opt).deflate || (opt).bsd_compress \
194 || (opt).predictor_1 || (opt).predictor_2 \
196 + || (opt).lzs || (opt).mppc || (opt).mppe)
199 * Local state (mainly for handling reset-reqs and reset-acks).
200 @@ -344,6 +324,100 @@ setdeflate(argv)
206 + * Functions called from config options
210 + required - require MPPE; disconnect if peer doesn't support it
211 + stateless - use stateless mode
212 + no40 - disable 40 bit keys
213 + no56 - disable 56 bit keys
214 + no128 - disable 128 bit keys
216 +int setmppe(char **argv)
219 + char *str, cmdbuf[16];
221 + ccp_allowoptions[0].mppe = 1;
222 + ccp_allowoptions[0].mppe_40 = 1;
223 + ccp_allowoptions[0].mppe_56 = 1;
224 + ccp_allowoptions[0].mppe_128 = 1;
225 + ccp_allowoptions[0].mppe_stateless = 0;
226 + ccp_wantoptions[0].mppe = 0;
232 + memset(cmdbuf, '\0', 16);
233 + while ((i < 16) && (*str != ',') && (*str != '\0'))
234 + cmdbuf[i++] = *str++;
236 + if (!strncasecmp(cmdbuf, "no40", strlen("no40"))) {
237 + ccp_allowoptions[0].mppe_40 = 0;
239 + } else if (!strncasecmp(cmdbuf, "no56", strlen("no56"))) {
240 + ccp_allowoptions[0].mppe_56 = 0;
242 + } else if (!strncasecmp(cmdbuf, "no128", strlen("no128"))) {
243 + ccp_allowoptions[0].mppe_128 = 0;
245 + } else if (!strncasecmp(cmdbuf, "stateless", strlen("stateless"))) {
246 + ccp_allowoptions[0].mppe_stateless = 1;
248 + } else if (!strncasecmp(cmdbuf, "required", strlen("required"))) {
249 + ccp_wantoptions[0].mppe = 1;
252 + option_error("invalid parameter '%s' for mppe option", cmdbuf);
261 + if (*str == '\0') {
262 + if (!(ccp_allowoptions[0].mppe_40 || ccp_allowoptions[0].mppe_56 ||
263 + ccp_allowoptions[0].mppe_128)) {
264 + if (ccp_wantoptions[0].mppe == 1) {
265 + option_error("You require MPPE but you have switched off "
266 + "all encryption key lengths.");
269 + ccp_wantoptions[0].mppe = ccp_allowoptions[0].mppe = 0;
270 + ccp_wantoptions[0].mppe_stateless =
271 + ccp_allowoptions[0].mppe_stateless = 0;
273 + ccp_allowoptions[0].mppe = 1;
274 + ccp_wantoptions[0].mppe_stateless =
275 + ccp_allowoptions[0].mppe_stateless;
276 + if (ccp_wantoptions[0].mppe == 1) {
277 + ccp_wantoptions[0].mppe_40 = ccp_allowoptions[0].mppe_40;
278 + ccp_wantoptions[0].mppe_56 = ccp_allowoptions[0].mppe_56;
279 + ccp_wantoptions[0].mppe_128 = ccp_allowoptions[0].mppe_128;
289 + ccp_wantoptions[0].mppe = ccp_allowoptions[0].mppe = 0;
290 + ccp_wantoptions[0].mppe_40 = ccp_allowoptions[0].mppe_40 = 0;
291 + ccp_wantoptions[0].mppe_56 = ccp_allowoptions[0].mppe_56 = 0;
292 + ccp_wantoptions[0].mppe_128 = ccp_allowoptions[0].mppe_128 = 0;
293 + ccp_wantoptions[0].mppe_stateless = ccp_allowoptions[0].mppe_stateless = 0;
299 * ccp_init - initialize CCP.
301 @@ -378,6 +452,30 @@ ccp_init(unit)
302 ccp_allowoptions[0].bsd_bits = BSD_MAX_BITS;
304 ccp_allowoptions[0].predictor_1 = 1;
306 + ccp_wantoptions[0].lzs = 0; /* Stac LZS - will be enabled in the future */
307 + ccp_wantoptions[0].lzs_mode = LZS_MODE_SEQ;
308 + ccp_wantoptions[0].lzs_hists = 1;
309 + ccp_allowoptions[0].lzs = 0; /* Stac LZS - will be enabled in the future */
310 + ccp_allowoptions[0].lzs_mode = LZS_MODE_SEQ;
311 + ccp_allowoptions[0].lzs_hists = 1;
314 + /* by default allow and request MPPC... */
315 + ccp_wantoptions[0].mppc = ccp_allowoptions[0].mppc = 1;
317 + /* ... and allow but don't request MPPE */
318 + ccp_allowoptions[0].mppe = 1;
319 + ccp_allowoptions[0].mppe_40 = 1;
320 + ccp_allowoptions[0].mppe_56 = 1;
321 + ccp_allowoptions[0].mppe_128 = 1;
322 + ccp_allowoptions[0].mppe_stateless = 1;
323 + ccp_wantoptions[0].mppe = 0;
324 + ccp_wantoptions[0].mppe_40 = 0;
325 + ccp_wantoptions[0].mppe_56 = 0;
326 + ccp_wantoptions[0].mppe_128 = 0;
327 + ccp_wantoptions[0].mppe_stateless = 0;
332 @@ -455,11 +553,11 @@ ccp_input(unit, p, len)
333 if (oldstate == OPENED && p[0] == TERMREQ && f->state != OPENED) {
334 notice("Compression disabled by peer.");
336 - if (ccp_gotoptions[unit].mppe) {
337 + if (ccp_wantoptions[unit].mppe) {
338 error("MPPE disabled, closing LCP");
339 lcp_close(unit, "MPPE disabled by peer");
346 @@ -487,6 +585,15 @@ ccp_extcode(f, code, id, p, len)
348 /* send a reset-ack, which the transmitter will see and
349 reset its compression state. */
351 + /* In case of MPPE/MPPC or LZS we shouldn't send CCP_RESETACK,
352 + but we do it in order to reset compressor; CCP_RESETACK is
353 + then silently discarded. See functions ppp_send_frame and
354 + ppp_ccp_peek in ppp_generic.c (Linux only !!!). All the
355 + confusion is caused by the fact that CCP code is splited
356 + into two parts - one part is handled by pppd, the other one
357 + is handled by kernel. */
359 fsm_sdata(f, CCP_RESETACK, id, NULL, 0);
362 @@ -515,12 +622,11 @@ ccp_protrej(unit)
363 fsm_lowerdown(&ccp_fsm[unit]);
366 - if (ccp_gotoptions[unit].mppe) {
367 + if (ccp_wantoptions[unit].mppe) {
368 error("MPPE required but peer negotiation failed");
369 lcp_close(unit, "MPPE required but peer negotiation failed");
377 @@ -537,7 +643,7 @@ ccp_resetci(f)
378 all_rejected[f->unit] = 0;
382 + if (go->mppe || go->mppc) {
383 ccp_options *ao = &ccp_allowoptions[f->unit];
384 int auth_mschap_bits = auth_done[f->unit];
386 @@ -551,80 +657,109 @@ ccp_resetci(f)
387 * NB: If MPPE is required, all other compression opts are invalid.
388 * So, we return right away if we can't do it.
390 + if (ccp_wantoptions[f->unit].mppe) {
391 + /* Leave only the mschap auth bits set */
392 + auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER |
393 + CHAP_MS2_WITHPEER | CHAP_MS2_PEER);
394 + /* Count the mschap auths */
395 + auth_mschap_bits >>= CHAP_MS_SHIFT;
398 + numbits += auth_mschap_bits & 1;
399 + auth_mschap_bits >>= 1;
400 + } while (auth_mschap_bits);
402 + error("MPPE required, but auth done in both directions.");
403 + lcp_close(f->unit, "MPPE required but not available");
407 + error("MPPE required, but MS-CHAP[v2] auth not performed.");
408 + lcp_close(f->unit, "MPPE required but not available");
412 - /* Leave only the mschap auth bits set */
413 - auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER |
414 - CHAP_MS2_WITHPEER | CHAP_MS2_PEER);
415 - /* Count the mschap auths */
416 - auth_mschap_bits >>= CHAP_MS_SHIFT;
419 - numbits += auth_mschap_bits & 1;
420 - auth_mschap_bits >>= 1;
421 - } while (auth_mschap_bits);
423 - error("MPPE required, but auth done in both directions.");
424 - lcp_close(f->unit, "MPPE required but not available");
428 - error("MPPE required, but MS-CHAP[v2] auth not performed.");
429 - lcp_close(f->unit, "MPPE required but not available");
433 - /* A plugin (eg radius) may not have obtained key material. */
434 - if (!mppe_keys_set) {
435 - error("MPPE required, but keys are not available. "
436 - "Possible plugin problem?");
437 - lcp_close(f->unit, "MPPE required but not available");
441 - /* LM auth not supported for MPPE */
442 - if (auth_done[f->unit] & (CHAP_MS_WITHPEER | CHAP_MS_PEER)) {
443 - /* This might be noise */
444 - if (go->mppe & MPPE_OPT_40) {
445 - notice("Disabling 40-bit MPPE; MS-CHAP LM not supported");
446 - go->mppe &= ~MPPE_OPT_40;
447 - ccp_wantoptions[f->unit].mppe &= ~MPPE_OPT_40;
448 + /* A plugin (eg radius) may not have obtained key material. */
449 + if (!mppe_keys_set) {
450 + error("MPPE required, but keys are not available. "
451 + "Possible plugin problem?");
452 + lcp_close(f->unit, "MPPE required but not available");
457 - /* Last check: can we actually negotiate something? */
458 - if (!(go->mppe & (MPPE_OPT_40 | MPPE_OPT_128))) {
459 - /* Could be misconfig, could be 40-bit disabled above. */
460 - error("MPPE required, but both 40-bit and 128-bit disabled.");
461 - lcp_close(f->unit, "MPPE required but not available");
464 + * Check whether the kernel knows about the various
465 + * compression methods we might request. Key material
466 + * unimportant here.
469 + opt_buf[0] = CI_MPPE;
470 + opt_buf[1] = CILEN_MPPE;
474 + opt_buf[5] = MPPE_MPPC;
475 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE, 0) <= 0)
479 + opt_buf[0] = CI_MPPE;
480 + opt_buf[1] = CILEN_MPPE;
481 + opt_buf[2] = MPPE_STATELESS;
484 + opt_buf[5] = MPPE_40BIT;
485 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
489 + opt_buf[0] = CI_MPPE;
490 + opt_buf[1] = CILEN_MPPE;
491 + opt_buf[2] = MPPE_STATELESS;
494 + opt_buf[5] = MPPE_56BIT;
495 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
498 + if (go->mppe_128) {
499 + opt_buf[0] = CI_MPPE;
500 + opt_buf[1] = CILEN_MPPE;
501 + opt_buf[2] = MPPE_STATELESS;
504 + opt_buf[5] = MPPE_128BIT;
505 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
508 + if (!go->mppe_40 && !go->mppe_56 && !go->mppe_128) {
509 + if (ccp_wantoptions[f->unit].mppe) {
510 + error("MPPE required, but kernel has no support.");
511 + lcp_close(f->unit, "MPPE required but not available");
513 + go->mppe = go->mppe_stateless = 0;
515 + /* MPPE is not compatible with other compression types */
516 + if (ccp_wantoptions[f->unit].mppe) {
517 + ao->bsd_compress = go->bsd_compress = 0;
518 + ao->predictor_1 = go->predictor_1 = 0;
519 + ao->predictor_2 = go->predictor_2 = 0;
520 + ao->deflate = go->deflate = 0;
521 + ao->lzs = go->lzs = 0;
526 - ao->mppe = go->mppe;
527 - /* MPPE is not compatible with other compression types */
528 - ao->bsd_compress = go->bsd_compress = 0;
529 - ao->predictor_1 = go->predictor_1 = 0;
530 - ao->predictor_2 = go->predictor_2 = 0;
531 - ao->deflate = go->deflate = 0;
536 - * Check whether the kernel knows about the various
537 - * compression methods we might request.
541 - opt_buf[0] = CI_MPPE;
542 - opt_buf[1] = CILEN_MPPE;
543 - MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
544 - /* Key material unimportant here. */
545 - if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0) {
546 - error("MPPE required, but kernel has no support.");
547 - lcp_close(f->unit, "MPPE required but not available");
550 + opt_buf[0] = CI_LZS;
551 + opt_buf[1] = CILEN_LZS;
552 + opt_buf[2] = go->lzs_hists >> 8;
553 + opt_buf[3] = go->lzs_hists & 0xff;
554 + opt_buf[4] = LZS_MODE_SEQ;
555 + if (ccp_test(f->unit, opt_buf, CILEN_LZS, 0) <= 0)
559 if (go->bsd_compress) {
560 opt_buf[0] = CI_BSD_COMPRESS;
561 opt_buf[1] = CILEN_BSD_COMPRESS;
562 @@ -679,7 +814,8 @@ ccp_cilen(f)
563 + (go->deflate? CILEN_DEFLATE: 0)
564 + (go->predictor_1? CILEN_PREDICTOR_1: 0)
565 + (go->predictor_2? CILEN_PREDICTOR_2: 0)
566 - + (go->mppe? CILEN_MPPE: 0);
567 + + (go->lzs? CILEN_LZS: 0)
568 + + ((go->mppe || go->mppc)? CILEN_MPPE: 0);
572 @@ -693,6 +829,8 @@ ccp_addci(f, p, lenp)
575 ccp_options *go = &ccp_gotoptions[f->unit];
576 + ccp_options *ao = &ccp_allowoptions[f->unit];
577 + ccp_options *wo = &ccp_wantoptions[f->unit];
581 @@ -701,22 +839,43 @@ ccp_addci(f, p, lenp)
582 * in case it gets Acked.
586 + if (go->mppe || go->mppc || (!wo->mppe && ao->mppe)) {
587 u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
589 - p[0] = opt_buf[0] = CI_MPPE;
590 - p[1] = opt_buf[1] = CILEN_MPPE;
591 - MPPE_OPTS_TO_CI(go->mppe, &p[2]);
592 - MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
595 + p[2] = (go->mppe_stateless ? MPPE_STATELESS : 0);
598 + p[5] = (go->mppe_40 ? MPPE_40BIT : 0) | (go->mppe_56 ? MPPE_56BIT : 0) |
599 + (go->mppe_128 ? MPPE_128BIT : 0) | (go->mppc ? MPPE_MPPC : 0);
601 + BCOPY(p, opt_buf, CILEN_MPPE);
602 BCOPY(mppe_recv_key, &opt_buf[CILEN_MPPE], MPPE_MAX_KEY_LEN);
603 res = ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0);
609 /* This shouldn't happen, we've already tested it! */
610 - lcp_close(f->unit, "MPPE required but not available in kernel");
611 + go->mppe = go->mppe_40 = go->mppe_56 = go->mppe_128 =
612 + go->mppe_stateless = go->mppc = 0;
613 + if (ccp_wantoptions[f->unit].mppe)
614 + lcp_close(f->unit, "MPPE required but not available in kernel");
621 + p[2] = go->lzs_hists >> 8;
622 + p[3] = go->lzs_hists & 0xff;
623 + p[4] = LZS_MODE_SEQ;
624 + res = ccp_test(f->unit, p, CILEN_LZS, 0);
632 p[0] = go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT;
633 p[1] = CILEN_DEFLATE;
634 @@ -802,7 +961,7 @@ ccp_addci(f, p, lenp)
637 * ccp_ackci - process a received configure-ack, and return
638 - * 1 iff the packet was OK.
639 + * 1 if the packet was OK.
643 @@ -811,24 +970,44 @@ ccp_ackci(f, p, len)
646 ccp_options *go = &ccp_gotoptions[f->unit];
647 + ccp_options *ao = &ccp_allowoptions[f->unit];
648 + ccp_options *wo = &ccp_wantoptions[f->unit];
653 - u_char opt_buf[CILEN_MPPE];
655 - opt_buf[0] = CI_MPPE;
656 - opt_buf[1] = CILEN_MPPE;
657 - MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
658 - if (len < CILEN_MPPE || memcmp(opt_buf, p, CILEN_MPPE))
659 + if (go->mppe || go->mppc || (!wo->mppe && ao->mppe)) {
660 + if (len < CILEN_MPPE
661 + || p[1] != CILEN_MPPE || p[0] != CI_MPPE
662 + || p[2] != (go->mppe_stateless ? MPPE_STATELESS : 0)
665 + || (p[5] != ((go->mppe_40 ? MPPE_40BIT : 0) |
666 + (go->mppc ? MPPE_MPPC : 0))
667 + && p[5] != ((go->mppe_56 ? MPPE_56BIT : 0) |
668 + (go->mppc ? MPPE_MPPC : 0))
669 + && p[5] != ((go->mppe_128 ? MPPE_128BIT : 0) |
670 + (go->mppc ? MPPE_MPPC : 0))))
672 + if (go->mppe_40 || go->mppe_56 || go->mppe_128)
676 + /* Cope with first/fast ack */
677 + if (p == p0 && len == 0)
682 + if (len < CILEN_LZS || p[0] != CI_LZS || p[1] != CILEN_LZS
683 + || p[2] != go->lzs_hists>>8 || p[3] != (go->lzs_hists&0xff)
684 + || p[4] != LZS_MODE_SEQ)
688 /* XXX Cope with first/fast ack */
690 + if (p == p0 && len == 0)
695 if (len < CILEN_DEFLATE
696 || p[0] != (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
697 @@ -901,6 +1080,8 @@ ccp_nakci(f, p, len, treat_as_reject)
700 ccp_options *go = &ccp_gotoptions[f->unit];
701 + ccp_options *ao = &ccp_allowoptions[f->unit];
702 + ccp_options *wo = &ccp_wantoptions[f->unit];
703 ccp_options no; /* options we've seen already */
704 ccp_options try; /* options to ask for next time */
706 @@ -908,28 +1089,100 @@ ccp_nakci(f, p, len, treat_as_reject)
710 - if (go->mppe && len >= CILEN_MPPE
711 - && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
714 - * Peer wants us to use a different strength or other setting.
715 - * Fail if we aren't willing to use his suggestion.
717 - MPPE_CI_TO_OPTS(&p[2], try.mppe);
718 - if ((try.mppe & MPPE_OPT_STATEFUL) && refuse_mppe_stateful) {
719 - error("Refusing MPPE stateful mode offered by peer");
721 - } else if (((go->mppe | MPPE_OPT_STATEFUL) & try.mppe) != try.mppe) {
722 - /* Peer must have set options we didn't request (suggest) */
725 + if ((go->mppe || go->mppc || (!wo->mppe && ao->mppe)) &&
726 + len >= CILEN_MPPE && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
729 - error("MPPE required but peer negotiation failed");
730 - lcp_close(f->unit, "MPPE required but peer negotiation failed");
733 + if (!(p[5] & MPPE_MPPC))
745 + if (go->mppe_stateless)
746 + no.mppe_stateless = 1;
749 + if ((p[5] & MPPE_40BIT))
752 + try.mppe_40 = (p[5] == 0) ? 1 : 0;
755 + if ((p[5] & MPPE_56BIT))
758 + try.mppe_56 = (p[5] == 0) ? 1 : 0;
760 + if (ao->mppe_128) {
761 + if ((p[5] & MPPE_128BIT))
764 + try.mppe_128 = (p[5] == 0) ? 1 : 0;
767 + if (ao->mppe_stateless) {
768 + if ((p[2] & MPPE_STATELESS) || wo->mppe_stateless)
769 + try.mppe_stateless = 1;
771 + try.mppe_stateless = 0;
774 + if (!try.mppe_56 && !try.mppe_40 && !try.mppe_128) {
775 + try.mppe = try.mppe_stateless = 0;
777 + /* we require encryption, but peer doesn't support it
778 + so we close connection */
779 + wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
780 + wo->mppe_56 = wo->mppe_128 = 0;
781 + lcp_close(f->unit, "MPPE required but cannot negotiate MPPE "
785 + if (wo->mppe && (wo->mppe_40 != try.mppe_40) &&
786 + (wo->mppe_56 != try.mppe_56) && (wo->mppe_128 != try.mppe_128)) {
787 + /* cannot negotiate key length */
788 + wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
789 + wo->mppe_56 = wo->mppe_128 = 0;
790 + lcp_close(f->unit, "Cannot negotiate MPPE key length");
792 + if (try.mppe_40 && try.mppe_56 && try.mppe_128)
793 + try.mppe_40 = try.mppe_56 = 0;
795 + if (try.mppe_56 && try.mppe_128)
798 + if (try.mppe_40 && try.mppe_128)
801 + if (try.mppe_40 && try.mppe_56)
809 + if (go->lzs && len >= CILEN_LZS && p[0] == CI_LZS && p[1] == CILEN_LZS) {
811 + if (((p[2]<<8)|p[3]) > 1 || (p[4] != LZS_MODE_SEQ &&
812 + p[4] != LZS_MODE_EXT))
815 + try.lzs_mode = p[4];
816 + try.lzs_hists = (p[2] << 8) | p[3];
822 if (go->deflate && len >= CILEN_DEFLATE
823 && p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
824 && p[1] == CILEN_DEFLATE) {
825 @@ -1002,14 +1255,50 @@ ccp_rejci(f, p, len)
829 - if (go->mppe && len >= CILEN_MPPE
830 + if ((go->mppe || go->mppc) && len >= CILEN_MPPE
831 && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
832 - error("MPPE required but peer refused");
833 - lcp_close(f->unit, "MPPE required but peer refused");
834 + ccp_options *wo = &ccp_wantoptions[f->unit];
835 + if (p[2] != (go->mppe_stateless ? MPPE_STATELESS : 0) ||
838 + p[5] != ((go->mppe_40 ? MPPE_40BIT : 0) |
839 + (go->mppe_56 ? MPPE_56BIT : 0) |
840 + (go->mppe_128 ? MPPE_128BIT : 0) |
841 + (go->mppc ? MPPE_MPPC : 0)))
853 + if (go->mppe_stateless)
854 + try.mppe_stateless = 0;
855 + if (!try.mppe_56 && !try.mppe_40 && !try.mppe_128)
856 + try.mppe = try.mppe_stateless = 0;
857 + if (wo->mppe) { /* we want MPPE but cannot negotiate key length */
858 + wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
859 + wo->mppe_56 = wo->mppe_128 = 0;
860 + lcp_close(f->unit, "MPPE required but cannot negotiate MPPE "
869 + if (go->lzs && len >= CILEN_LZS && p[0] == CI_LZS && p[1] == CILEN_LZS) {
870 + if (p[2] != go->lzs_hists>>8 || p[3] != (go->lzs_hists&0xff)
871 + || p[4] != go->lzs_mode)
877 if (go->deflate_correct && len >= CILEN_DEFLATE
878 && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) {
879 if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
880 @@ -1073,14 +1362,15 @@ ccp_reqci(f, p, lenp, dont_nak)
883 int ret, newret, res;
885 + u_char *p0, *retp, p2, p5;
886 int len, clen, type, nb;
887 ccp_options *ho = &ccp_hisoptions[f->unit];
888 ccp_options *ao = &ccp_allowoptions[f->unit];
889 + ccp_options *wo = &ccp_wantoptions[f->unit];
891 - bool rej_for_ci_mppe = 1; /* Are we rejecting based on a bad/missing */
892 - /* CI_MPPE, or due to other options? */
894 + u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
900 @@ -1103,106 +1393,302 @@ ccp_reqci(f, p, lenp, dont_nak)
904 - if (!ao->mppe || clen != CILEN_MPPE) {
905 + if ((!ao->mppc && !ao->mppe) || clen != CILEN_MPPE) {
909 - MPPE_CI_TO_OPTS(&p[2], ho->mppe);
911 - /* Nak if anything unsupported or unknown are set. */
912 - if (ho->mppe & MPPE_OPT_UNSUPPORTED) {
914 - ho->mppe &= ~MPPE_OPT_UNSUPPORTED;
916 - if (ho->mppe & MPPE_OPT_UNKNOWN) {
919 + /* not sure what they want, tell 'em what we got */
920 + if (((p[2] & ~MPPE_STATELESS) != 0 || p[3] != 0 || p[4] != 0 ||
921 + (p[5] & ~(MPPE_40BIT | MPPE_56BIT | MPPE_128BIT |
922 + MPPE_MPPC)) != 0 || p[5] == 0) ||
923 + (p[2] == 0 && p[3] == 0 && p[4] == 0 && p[5] == 0)) {
925 - ho->mppe &= ~MPPE_OPT_UNKNOWN;
928 - /* Check state opt */
929 - if (ho->mppe & MPPE_OPT_STATEFUL) {
931 - * We can Nak and request stateless, but it's a
932 - * lot easier to just assume the peer will request
933 - * it if he can do it; stateful mode is bad over
934 - * the Internet -- which is where we expect MPPE.
936 - if (refuse_mppe_stateful) {
937 - error("Refusing MPPE stateful mode offered by peer");
940 + p[2] = (wo->mppe_stateless ? MPPE_STATELESS : 0);
943 + p[5] = (wo->mppe_40 ? MPPE_40BIT : 0) |
944 + (wo->mppe_56 ? MPPE_56BIT : 0) |
945 + (wo->mppe_128 ? MPPE_128BIT : 0) |
946 + (wo->mppc ? MPPE_MPPC : 0);
950 + if ((p[5] & MPPE_MPPC)) {
953 + BCOPY(p, opt_buf, CILEN_MPPE);
954 + opt_buf[2] = opt_buf[3] = opt_buf[4] = 0;
955 + opt_buf[5] = MPPE_MPPC;
956 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE, 1) <= 0) {
958 + p[5] &= ~MPPE_MPPC;
963 + if (wo->mppe || ao->mppe) {
964 + p[5] &= ~MPPE_MPPC;
970 - /* Find out which of {S,L} are set. */
971 - if ((ho->mppe & MPPE_OPT_128)
972 - && (ho->mppe & MPPE_OPT_40)) {
973 - /* Both are set, negotiate the strongest. */
975 - if (ao->mppe & MPPE_OPT_128)
976 - ho->mppe &= ~MPPE_OPT_40;
977 - else if (ao->mppe & MPPE_OPT_40)
978 - ho->mppe &= ~MPPE_OPT_128;
983 - } else if (ho->mppe & MPPE_OPT_128) {
984 - if (!(ao->mppe & MPPE_OPT_128)) {
988 - } else if (ho->mppe & MPPE_OPT_40) {
989 - if (!(ao->mppe & MPPE_OPT_40)) {
996 + if ((p[2] & MPPE_STATELESS)) {
997 + if (ao->mppe_stateless) {
998 + if (wo->mppe_stateless)
999 + ho->mppe_stateless = 1;
1003 + p[2] &= ~MPPE_STATELESS;
1008 + p[2] &= ~MPPE_STATELESS;
1011 + if (wo->mppe_stateless && !dont_nak) {
1012 + wo->mppe_stateless = 0;
1014 + p[2] |= MPPE_STATELESS;
1018 + if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_56BIT|MPPE_128BIT)) {
1020 + if (ao->mppe_128) {
1022 + p[5] &= ~(MPPE_40BIT|MPPE_56BIT);
1023 + BCOPY(p, opt_buf, CILEN_MPPE);
1024 + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1025 + MPPE_MAX_KEY_LEN);
1026 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
1027 + MPPE_MAX_KEY_LEN, 1) <= 0) {
1029 + p[5] |= (MPPE_40BIT|MPPE_56BIT);
1030 + p[5] &= ~MPPE_128BIT;
1031 + goto check_mppe_56_40;
1035 + p[5] &= ~MPPE_128BIT;
1036 + goto check_mppe_56_40;
1038 + if ((p[5] & ~MPPE_MPPC) == (MPPE_56BIT|MPPE_128BIT)) {
1040 + if (ao->mppe_128) {
1042 + p[5] &= ~MPPE_56BIT;
1043 + BCOPY(p, opt_buf, CILEN_MPPE);
1044 + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1045 + MPPE_MAX_KEY_LEN);
1046 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
1047 + MPPE_MAX_KEY_LEN, 1) <= 0) {
1049 + p[5] |= MPPE_56BIT;
1050 + p[5] &= ~MPPE_128BIT;
1051 + goto check_mppe_56;
1055 + p[5] &= ~MPPE_128BIT;
1056 + goto check_mppe_56;
1058 + if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_128BIT)) {
1060 + if (ao->mppe_128) {
1062 + p[5] &= ~MPPE_40BIT;
1063 + BCOPY(p, opt_buf, CILEN_MPPE);
1064 + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1065 + MPPE_MAX_KEY_LEN);
1066 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
1067 + MPPE_MAX_KEY_LEN, 1) <= 0) {
1069 + p[5] |= MPPE_40BIT;
1070 + p[5] &= ~MPPE_128BIT;
1071 + goto check_mppe_40;
1075 + p[5] &= ~MPPE_128BIT;
1076 + goto check_mppe_40;
1078 + if ((p[5] & ~MPPE_MPPC) == MPPE_128BIT) {
1079 + if (ao->mppe_128) {
1081 + BCOPY(p, opt_buf, CILEN_MPPE);
1082 + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1083 + MPPE_MAX_KEY_LEN);
1084 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
1085 + MPPE_MAX_KEY_LEN, 1) <= 0) {
1087 + p[5] &= ~MPPE_128BIT;
1092 + p[5] &= ~MPPE_128BIT;
1097 + if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_56BIT)) {
1099 + if (ao->mppe_56) {
1101 + p[5] &= ~MPPE_40BIT;
1102 + BCOPY(p, opt_buf, CILEN_MPPE);
1103 + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1104 + MPPE_MAX_KEY_LEN);
1105 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
1106 + MPPE_MAX_KEY_LEN, 1) <= 0) {
1108 + p[5] |= MPPE_40BIT;
1109 + p[5] &= ~MPPE_56BIT;
1111 + goto check_mppe_40;
1115 + p[5] &= ~MPPE_56BIT;
1116 + goto check_mppe_40;
1119 + if ((p[5] & ~MPPE_MPPC) == MPPE_56BIT) {
1120 + if (ao->mppe_56) {
1122 + BCOPY(p, opt_buf, CILEN_MPPE);
1123 + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1124 + MPPE_MAX_KEY_LEN);
1125 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
1126 + MPPE_MAX_KEY_LEN, 1) <= 0) {
1128 + p[5] &= ~MPPE_56BIT;
1133 + p[5] &= ~MPPE_56BIT;
1138 + if ((p[5] & ~MPPE_MPPC) == MPPE_40BIT) {
1139 + if (ao->mppe_40) {
1141 + BCOPY(p, opt_buf, CILEN_MPPE);
1142 + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1143 + MPPE_MAX_KEY_LEN);
1144 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
1145 + MPPE_MAX_KEY_LEN, 1) <= 0) {
1147 + p[5] &= ~MPPE_40BIT;
1152 + p[5] &= ~MPPE_40BIT;
1156 + if (!ho->mppe_40 && !ho->mppe_56 && !ho->mppe_128) {
1157 + if (wo->mppe_40 || wo->mppe_56 || wo->mppe_128) {
1159 + p[2] |= (wo->mppe_stateless ? MPPE_STATELESS : 0);
1160 + p[5] |= (wo->mppe_40 ? MPPE_40BIT : 0) |
1161 + (wo->mppe_56 ? MPPE_56BIT : 0) |
1162 + (wo->mppe_128 ? MPPE_128BIT : 0) |
1163 + (wo->mppc ? MPPE_MPPC : 0);
1165 + ho->mppe = ho->mppe_stateless = 0;
1168 - /* Neither are set. */
1169 - /* We cannot accept this. */
1171 - /* Give the peer our idea of what can be used,
1172 - so it can choose and confirm */
1173 - ho->mppe = ao->mppe;
1176 - /* rebuild the opts */
1177 - MPPE_OPTS_TO_CI(ho->mppe, &p[2]);
1178 - if (newret == CONFACK) {
1179 - u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
1182 - BCOPY(p, opt_buf, CILEN_MPPE);
1183 - BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1184 - MPPE_MAX_KEY_LEN);
1185 - if (ccp_test(f->unit, opt_buf,
1186 - CILEN_MPPE + MPPE_MAX_KEY_LEN, 1) <= 0) {
1187 - /* This shouldn't happen, we've already tested it! */
1188 - error("MPPE required, but kernel has no support.");
1189 - lcp_close(f->unit, "MPPE required but not available");
1194 - * We need to decrease the interface MTU by MPPE_PAD
1195 - * because MPPE frames **grow**. The kernel [must]
1196 - * allocate MPPE_PAD extra bytes in xmit buffers.
1198 - mtu = netif_get_mtu(f->unit);
1200 - netif_set_mtu(f->unit, mtu - MPPE_PAD);
1206 - * We have accepted MPPE or are willing to negotiate
1207 - * MPPE parameters. A CONFREJ is due to subsequent
1208 - * (non-MPPE) processing.
1210 - rej_for_ci_mppe = 0;
1213 + /* MPPE is not compatible with other compression types */
1215 + ao->bsd_compress = 0;
1216 + ao->predictor_1 = 0;
1217 + ao->predictor_2 = 0;
1222 + if ((!ho->mppc || !ao->mppc) && !ho->mppe) {
1230 + * I have commented the code below because according to RFC1547
1231 + * MTU is only information for higher level protocols about
1232 + * "the maximum allowable length for a packet (q.v.) transmitted
1233 + * over a point-to-point link without incurring network layer
1234 + * fragmentation." Of course a PPP implementation should be able
1235 + * to handle overhead added by MPPE - in our case apropriate code
1236 + * is located in drivers/net/ppp_generic.c in the kernel sources.
1238 + * According to RFC1661:
1239 + * - when negotiated MRU is less than 1500 octets, a PPP
1240 + * implementation must still be able to receive at least 1500
1242 + * - when PFC is negotiated, a PPP implementation is still
1243 + * required to receive frames with uncompressed protocol field.
1245 + * So why not to handle MPPE overhead without changing MTU value?
1246 + * I am sure that RFC3078, unfortunately silently, assumes that.
1250 + * We need to decrease the interface MTU by MPPE_PAD
1251 + * because MPPE frames **grow**. The kernel [must]
1252 + * allocate MPPE_PAD extra bytes in xmit buffers.
1255 + mtu = netif_get_mtu(f->unit);
1257 + netif_set_mtu(f->unit, mtu - MPPE_PAD);
1260 + if (ccp_wantoptions[f->unit].mppe) {
1261 + error("Cannot adjust MTU needed by MPPE.");
1262 + lcp_close(f->unit, "Cannot adjust MTU needed by MPPE.");
1270 + if (!ao->lzs || clen != CILEN_LZS) {
1276 + ho->lzs_hists = (p[2] << 8) | p[3];
1277 + ho->lzs_mode = p[4];
1278 + if ((ho->lzs_hists != ao->lzs_hists) ||
1279 + (ho->lzs_mode != ao->lzs_mode)) {
1282 + p[2] = ao->lzs_hists >> 8;
1283 + p[3] = ao->lzs_hists & 0xff;
1284 + p[4] = ao->lzs_mode;
1289 + if (p == p0 && ccp_test(f->unit, p, CILEN_LZS, 1) <= 0) {
1294 case CI_DEFLATE_DRAFT:
1295 if (!ao->deflate || clen != CILEN_DEFLATE
1296 @@ -1344,12 +1830,6 @@ ccp_reqci(f, p, lenp, dont_nak)
1301 - if (ret == CONFREJ && ao->mppe && rej_for_ci_mppe) {
1302 - error("MPPE required but peer negotiation failed");
1303 - lcp_close(f->unit, "MPPE required but peer negotiation failed");
1309 @@ -1371,24 +1851,35 @@ method_name(opt, opt2)
1311 char *q = result + sizeof(result); /* 1 past result */
1313 - slprintf(p, q - p, "MPPE ");
1315 - if (opt->mppe & MPPE_OPT_128) {
1316 - slprintf(p, q - p, "128-bit ");
1319 - if (opt->mppe & MPPE_OPT_40) {
1320 - slprintf(p, q - p, "40-bit ");
1323 - if (opt->mppe & MPPE_OPT_STATEFUL)
1324 - slprintf(p, q - p, "stateful");
1326 - slprintf(p, q - p, "stateless");
1330 + slprintf(p, q - p, "MPPC/MPPE ");
1333 + slprintf(p, q - p, "MPPE ");
1336 + if (opt->mppe_128) {
1337 + slprintf(p, q - p, "128-bit ");
1339 + } else if (opt->mppe_56) {
1340 + slprintf(p, q - p, "56-bit ");
1342 + } else if (opt->mppe_40) {
1343 + slprintf(p, q - p, "40-bit ");
1346 + if (opt->mppe_stateless)
1347 + slprintf(p, q - p, "stateless");
1349 + slprintf(p, q - p, "stateful");
1350 + } else if (opt->mppc)
1351 + slprintf(p, q - p, "MPPC");
1357 + return "Stac LZS";
1359 case CI_DEFLATE_DRAFT:
1360 if (opt2 != NULL && opt2->deflate_size != opt->deflate_size)
1361 @@ -1444,12 +1935,12 @@ ccp_up(f)
1362 } else if (ANY_COMPRESS(*ho))
1363 notice("%s transmit compression enabled", method_name(ho, NULL));
1366 + if (go->mppe || go->mppc) {
1367 BZERO(mppe_recv_key, MPPE_MAX_KEY_LEN);
1368 BZERO(mppe_send_key, MPPE_MAX_KEY_LEN);
1369 continue_networks(f->unit); /* Bring up IP et al */
1376 @@ -1472,7 +1963,7 @@ ccp_down(f)
1377 lcp_close(f->unit, "MPPE disabled");
1385 @@ -1532,24 +2023,28 @@ ccp_printpkt(p, plen, printer, arg)
1388 if (optlen >= CILEN_MPPE) {
1391 - MPPE_CI_TO_OPTS(&p[2], mppe_opts);
1392 - printer(arg, "mppe %s %s %s %s %s %s%s",
1393 - (p[2] & MPPE_H_BIT)? "+H": "-H",
1394 - (p[5] & MPPE_M_BIT)? "+M": "-M",
1395 - (p[5] & MPPE_S_BIT)? "+S": "-S",
1396 - (p[5] & MPPE_L_BIT)? "+L": "-L",
1397 + printer(arg, "mppe %s %s %s %s %s %s",
1398 + (p[2] & MPPE_STATELESS)? "+H": "-H",
1399 + (p[5] & MPPE_56BIT)? "+M": "-M",
1400 + (p[5] & MPPE_128BIT)? "+S": "-S",
1401 + (p[5] & MPPE_40BIT)? "+L": "-L",
1402 (p[5] & MPPE_D_BIT)? "+D": "-D",
1403 - (p[5] & MPPE_C_BIT)? "+C": "-C",
1404 - (mppe_opts & MPPE_OPT_UNKNOWN)? " +U": "");
1405 - if (mppe_opts & MPPE_OPT_UNKNOWN)
1406 + (p[5] & MPPE_MPPC)? "+C": "-C");
1407 + if ((p[5] & ~(MPPE_56BIT | MPPE_128BIT | MPPE_40BIT |
1408 + MPPE_D_BIT | MPPE_MPPC)) ||
1409 + (p[2] & ~MPPE_STATELESS))
1410 printer(arg, " (%.2x %.2x %.2x %.2x)",
1411 p[2], p[3], p[4], p[5]);
1418 + if (optlen >= CILEN_LZS) {
1419 + printer(arg, "lzs %.2x %.2x %.2x", p[2], p[3], p[4]);
1424 case CI_DEFLATE_DRAFT:
1425 if (optlen >= CILEN_DEFLATE) {
1426 @@ -1635,6 +2130,7 @@ ccp_datainput(unit, pkt, len)
1427 error("Lost compression sync: disabling compression");
1428 ccp_close(unit, "Lost compression sync");
1430 + /* My module dosn't need this. J.D., 2003-07-06 */
1432 * If we were doing MPPE, we must also take the link down.
1434 @@ -1642,9 +2138,18 @@ ccp_datainput(unit, pkt, len)
1435 error("Too many MPPE errors, closing LCP");
1436 lcp_close(unit, "Too many MPPE errors");
1442 + * When LZS or MPPE/MPPC is negotiated we just send CCP_RESETREQ
1443 + * and don't wait for CCP_RESETACK
1445 + if ((ccp_gotoptions[f->unit].method == CI_LZS) ||
1446 + (ccp_gotoptions[f->unit].method == CI_MPPE)) {
1447 + fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0);
1451 * Send a reset-request to reset the peer's compressor.
1452 * We don't do that if we are still waiting for an
1453 * acknowledgement to a previous reset-request.
1456 @@ -37,9 +37,17 @@ typedef struct ccp_options {
1457 bool predictor_2; /* do Predictor-2? */
1458 bool deflate_correct; /* use correct code for deflate? */
1459 bool deflate_draft; /* use draft RFC code for deflate? */
1460 + bool lzs; /* do Stac LZS? */
1461 + bool mppc; /* do MPPC? */
1462 bool mppe; /* do MPPE? */
1463 + bool mppe_40; /* allow 40 bit encryption? */
1464 + bool mppe_56; /* allow 56 bit encryption? */
1465 + bool mppe_128; /* allow 128 bit encryption? */
1466 + bool mppe_stateless; /* allow stateless encryption */
1467 u_short bsd_bits; /* # bits/code for BSD Compress */
1468 u_short deflate_size; /* lg(window size) for Deflate */
1469 + u_short lzs_mode; /* LZS check mode */
1470 + u_short lzs_hists; /* number of LZS histories */
1471 short method; /* code for chosen compression method */
1474 --- a/pppd/chap_ms.c
1475 +++ b/pppd/chap_ms.c
1476 @@ -898,13 +898,17 @@ set_mppe_enc_types(int policy, int types
1478 * Disable undesirable encryption types. Note that we don't ENABLE
1479 * any encryption types, to avoid overriding manual configuration.
1481 + * It seems that 56 bit keys are unsupported in MS-RADIUS (see RFC 2548)
1484 case MPPE_ENC_TYPES_RC4_40:
1485 - ccp_wantoptions[0].mppe &= ~MPPE_OPT_128; /* disable 128-bit */
1486 + ccp_wantoptions[0].mppe_128 = 0; /* disable 128-bit */
1487 + ccp_wantoptions[0].mppe_56 = 0; /* disable 56-bit */
1489 case MPPE_ENC_TYPES_RC4_128:
1490 - ccp_wantoptions[0].mppe &= ~MPPE_OPT_40; /* disable 40-bit */
1491 + ccp_wantoptions[0].mppe_56 = 0; /* disable 56-bit */
1492 + ccp_wantoptions[0].mppe_40 = 0; /* disable 40-bit */