From 662a42f752be8b20469c7f9eb9c4afcacfb2a8b3 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Sat, 7 Jul 2001 03:06:20 +0000 Subject: [PATCH] When we miss one or more packets in stateful mode *and* need to perform a key change, *and* our sequence numbers have wrapped, ensure that the number of key changes is calculated correctly. The previous code counted down from a negative number to zero, re-encrypting the current key on each iteration - this took some time and strangely enough got the answer wrong !!! Fix a(nother) spelling mistake while I'm there. --- usr.sbin/ppp/mppe.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/usr.sbin/ppp/mppe.c b/usr.sbin/ppp/mppe.c index 891492b49e3..f079660c2fa 100644 --- a/usr.sbin/ppp/mppe.c +++ b/usr.sbin/ppp/mppe.c @@ -70,12 +70,13 @@ #define MPPE_OPT_BITMASK 0xe0 #define MPPE_OPT_MASK (MPPE_OPT_STATELESS | MPPE_OPT_BITMASK) -#define MPPE_FLUSHED 0x8000 -#define MPPE_ENCRYPTED 0x1000 -#define MPPE_HEADER_BITMASK 0xf000 -#define MPPE_HEADER_FLAG 0x00ff -#define MPPE_HEADER_FLAGMASK 0x00ff -#define MPPE_HEADER_FLAGSHIFT 8 +#define MPPE_FLUSHED 0x8000 +#define MPPE_ENCRYPTED 0x1000 +#define MPPE_HEADER_BITMASK 0xf000 +#define MPPE_HEADER_FLAG 0x00ff +#define MPPE_HEADER_FLAGMASK 0x00ff +#define MPPE_HEADER_FLAGSHIFT 8 +#define MPPE_HEADER_STATEFUL_KEYCHANGES 16 struct mppe_state { unsigned stateless : 1; @@ -276,6 +277,8 @@ MPPEInput(void *v, struct ccp *ccp, u_short *proto, struct mbuf *mp) */ n = (prefix >> MPPE_HEADER_FLAGSHIFT) - (mip->cohnum >> MPPE_HEADER_FLAGSHIFT); + if (n < 0) + n += MPPE_HEADER_STATEFUL_KEYCHANGES; while (n--) { log_Printf(LogDEBUG, "MPPEInput: Key changed during catchup [%u]\n", prefix); @@ -388,7 +391,7 @@ MPPEDispOpts(struct lcp_opt *o) } snprintf(buf + len, sizeof buf - len, " bits, state%s", - (val & MPPE_OPT_STATELESS) ? "less" : "full"); + (val & MPPE_OPT_STATELESS) ? "less" : "ful"); len += strlen(buf + len); if (val & MPPE_OPT_COMPRESSED) {