summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>2000-11-07 23:32:05 +0000
committerbrian <brian@cvs.openbsd.org>2000-11-07 23:32:05 +0000
commitc9c2783223e0a4f6a2b708141b4097df61333d16 (patch)
tree8be402a1e7ed9e5a17ab2ef00aca0e7f6a11beb7 /usr.sbin
parent78f1224c8e04850a3c0d479b35186692399923b8 (diff)
Pass the correct option data to the compression modules Init function
rather than the data associated with the first protocol REQuested. Initiate MPPE session keys correctly based on whether we're client or server
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/ppp/ccp.c25
-rw-r--r--usr.sbin/ppp/ppp/ccp.h6
-rw-r--r--usr.sbin/ppp/ppp/chap.c15
-rw-r--r--usr.sbin/ppp/ppp/mppe.c9
-rw-r--r--usr.sbin/ppp/ppp/mppe.h3
5 files changed, 42 insertions, 16 deletions
diff --git a/usr.sbin/ppp/ppp/ccp.c b/usr.sbin/ppp/ppp/ccp.c
index 7a98e451b08..6c58c8edd34 100644
--- a/usr.sbin/ppp/ppp/ccp.c
+++ b/usr.sbin/ppp/ppp/ccp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $OpenBSD: ccp.c,v 1.15 2000/11/02 00:54:33 brian Exp $
+ * $OpenBSD: ccp.c,v 1.16 2000/11/07 23:32:04 brian Exp $
*
* TODO:
* o Support other compression protocols
@@ -376,7 +376,20 @@ static void
CcpLayerFinish(struct fsm *fp)
{
/* We're now down */
+ struct ccp *ccp = fsm2ccp(fp);
+ struct ccp_opt *next;
+
log_Printf(LogCCP, "%s: LayerFinish.\n", fp->link->name);
+
+ /*
+ * Nuke options that may be left over from sending a REQ but never
+ * coming up.
+ */
+ while (ccp->out.opt) {
+ next = ccp->out.opt->next;
+ free(ccp->out.opt);
+ ccp->out.opt = next;
+ }
}
/* Called when CCP has reached the OPEN state */
@@ -385,6 +398,8 @@ CcpLayerUp(struct fsm *fp)
{
/* We're now up */
struct ccp *ccp = fsm2ccp(fp);
+ struct ccp_opt **o;
+ int f;
log_Printf(LogCCP, "%s: LayerUp.\n", fp->link->name);
@@ -400,10 +415,14 @@ CcpLayerUp(struct fsm *fp)
}
}
+ o = &ccp->out.opt;
+ for (f = 0; f < ccp->out.algorithm; f++)
+ if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]))
+ o = &(*o)->next;
+
if (ccp->out.state == NULL && ccp->out.algorithm >= 0 &&
ccp->out.algorithm < NALGORITHMS) {
- ccp->out.state = (*algorithm[ccp->out.algorithm]->o.Init)
- (&ccp->out.opt->val);
+ ccp->out.state = (*algorithm[ccp->out.algorithm]->o.Init)(&(*o)->val);
if (ccp->out.state == NULL) {
log_Printf(LogERROR, "%s: %s (out) initialisation failure\n",
fp->link->name, protoname(ccp->my_proto));
diff --git a/usr.sbin/ppp/ppp/ccp.h b/usr.sbin/ppp/ppp/ccp.h
index 95f3ff15c06..5127a33614e 100644
--- a/usr.sbin/ppp/ppp/ccp.h
+++ b/usr.sbin/ppp/ppp/ccp.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $OpenBSD: ccp.h,v 1.6 2000/11/02 00:54:33 brian Exp $
+ * $OpenBSD: ccp.h,v 1.7 2000/11/07 23:32:04 brian Exp $
*
* TODO:
*/
@@ -82,13 +82,13 @@ struct ccp {
struct {
int algorithm; /* Algorithm in use */
void *state; /* Returned by implementations Init() */
- struct lcp_opt opt; /* Set by implementations OptInit() */
+ struct lcp_opt opt; /* Set by implementation's OptInit() */
} in;
struct {
int algorithm; /* Algorithm in use */
void *state; /* Returned by implementations Init() */
- struct ccp_opt *opt; /* Set by implementations OptInit() */
+ struct ccp_opt *opt; /* Set by implementation's OptInit() */
} out;
u_int32_t his_reject; /* Request codes rejected by peer */
diff --git a/usr.sbin/ppp/ppp/chap.c b/usr.sbin/ppp/ppp/chap.c
index c7cad849796..53c778ec53c 100644
--- a/usr.sbin/ppp/ppp/chap.c
+++ b/usr.sbin/ppp/ppp/chap.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $OpenBSD: chap.c,v 1.24 2000/11/02 00:54:33 brian Exp $
+ * $OpenBSD: chap.c,v 1.25 2000/11/07 23:32:04 brian Exp $
*
* TODO:
*/
@@ -203,7 +203,7 @@ chap_BuildAnswer(char *name, char *key, u_char id, char *challenge, u_char type
expkey, klen * 2, ntresponse);
/* Generate MPPE MASTERKEY */
- GetMasterKey(pwdhashhash, ntresponse, MPPE_MasterKey);
+ GetMasterKey(pwdhashhash, ntresponse, MPPE_MasterKey); /* XXX Global ! */
/* Generate AUTHRESPONSE to verify on auth success */
GenerateAuthenticatorResponse(expkey, klen * 2, ntresponse,
@@ -371,6 +371,7 @@ chap_Respond(struct chap *chap, char *name, char *key, u_char type
ans, *ans + 1 + strlen(name), name);
#ifdef HAVE_DES
chap->NTRespSent = !lm;
+ MPPE_IsServer = 0; /* XXX Global ! */
#endif
free(ans);
} else
@@ -536,7 +537,7 @@ chap_Success(struct authinfo *authp)
#ifdef HAVE_DES
if (authp->physical->link.lcp.want_authtype == 0x81) {
msg = auth2chap(authp)->authresponse;
- MPPE_MasterKeyValid = 1;
+ MPPE_MasterKeyValid = 1; /* XXX Global ! */
} else
#endif
msg = "Welcome!!";
@@ -857,9 +858,11 @@ chap_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
p->link.lcp.want_authtype
#ifdef HAVE_DES
, chap->challenge.peer,
- chap->authresponse, lanman
-#endif
+ chap->authresponse, lanman);
+ MPPE_IsServer = 1; /* XXX Global ! */
+#else
);
+#endif
if (myans == NULL)
key = NULL;
else {
@@ -896,7 +899,7 @@ chap_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
} else {
/* Successful login */
- MPPE_MasterKeyValid = 1;
+ MPPE_MasterKeyValid = 1; /* XXX Global ! */
datalink_AuthOk(p->dl);
}
} else
diff --git a/usr.sbin/ppp/ppp/mppe.c b/usr.sbin/ppp/ppp/mppe.c
index 275c6057edf..daad8b2295c 100644
--- a/usr.sbin/ppp/ppp/mppe.c
+++ b/usr.sbin/ppp/ppp/mppe.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: mppe.c,v 1.1 2000/11/02 00:54:34 brian Exp $
+ * $OpenBSD: mppe.c,v 1.2 2000/11/07 23:32:04 brian Exp $
*/
#include <sys/types.h>
@@ -67,6 +67,7 @@ struct mppe_state {
};
int MPPE_MasterKeyValid = 0;
+int MPPE_IsServer = 0;
char MPPE_MasterKey[MPPE_KEY_LEN];
static void
@@ -340,7 +341,8 @@ MPPEInitInput(struct lcp_opt *o)
log_Printf(LogDEBUG, "MPPE: InitInput: %d-bits\n", mip->keybits);
- GetAsymetricStartKey(MPPE_MasterKey, mip->mastkey, mip->keylen, 0, 0);
+ GetAsymetricStartKey(MPPE_MasterKey, mip->mastkey, mip->keylen, 0,
+ MPPE_IsServer);
GetNewKeyFromSHA(mip->mastkey, mip->mastkey, mip->keylen, mip->sesskey);
MPPEReduceSessionKey(mip);
@@ -381,7 +383,8 @@ MPPEInitOutput(struct lcp_opt *o)
log_Printf(LogDEBUG, "MPPE: InitOutput: %d-bits\n", mop->keybits);
- GetAsymetricStartKey(MPPE_MasterKey, mop->mastkey, mop->keylen, 1, 0);
+ GetAsymetricStartKey(MPPE_MasterKey, mop->mastkey, mop->keylen, 1,
+ MPPE_IsServer);
GetNewKeyFromSHA(mop->mastkey, mop->mastkey, mop->keylen, mop->sesskey);
MPPEReduceSessionKey(mop);
diff --git a/usr.sbin/ppp/ppp/mppe.h b/usr.sbin/ppp/ppp/mppe.h
index 499da5e0059..8e868791791 100644
--- a/usr.sbin/ppp/ppp/mppe.h
+++ b/usr.sbin/ppp/ppp/mppe.h
@@ -23,10 +23,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: mppe.h,v 1.1 2000/11/02 00:54:34 brian Exp $
+ * $OpenBSD: mppe.h,v 1.2 2000/11/07 23:32:04 brian Exp $
*/
#define MPPE_KEY_LEN 16
extern const struct ccp_algorithm MPPEAlgorithm;
extern int MPPE_MasterKeyValid;
+extern int MPPE_IsServer;
extern char MPPE_MasterKey[];