summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2000-03-29 07:19:51 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2000-03-29 07:19:51 +0000
commit9dd20a98e049ddc88c79f9315cc7a871bd662aa7 (patch)
treebc5f264a51257125cc2abaf30f6c79668c84658c
parent919c2f647150f47decb46e4adfdc994a87a4426c (diff)
Note to self: test before committing.
-rw-r--r--sys/netinet/ip_esp.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/sys/netinet/ip_esp.c b/sys/netinet/ip_esp.c
index 1d43ea408bb..729bb8bab8d 100644
--- a/sys/netinet/ip_esp.c
+++ b/sys/netinet/ip_esp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_esp.c,v 1.37 2000/03/29 07:09:57 angelos Exp $ */
+/* $OpenBSD: ip_esp.c,v 1.38 2000/03/29 07:19:50 angelos Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
@@ -150,6 +150,15 @@ esp_init(struct tdb *tdbp, struct xformsw *xsp, struct ipsecinit *ii)
DPRINTF(("esp_init(): keylength %d too large (max length is %d) for algorithm %s\n", ii->ii_enckeylen, txform->maxkey, txform->name));
return EINVAL;
}
+
+ tdbp->tdb_encalgxform = txform;
+
+ DPRINTF(("esp_init(): initialized TDB with enc algorithm %s\n",
+ txform->name));
+
+ tdbp->tdb_ivlen = txform->ivmask;
+ if (tdbp->tdb_flags & TDBF_HALFIV)
+ tdbp->tdb_ivlen /= 2;
}
if (ii->ii_authalg)
@@ -186,37 +195,18 @@ esp_init(struct tdb *tdbp, struct xformsw *xsp, struct ipsecinit *ii)
}
tdbp->tdb_xform = xsp;
- tdbp->tdb_encalgxform = txform;
tdbp->tdb_bitmap = 0;
tdbp->tdb_rpl = AH_HMAC_INITIAL_RPL;
- DPRINTF(("esp_init(): initialized TDB with enc algorithm %s\n",
- txform->name));
-
- tdbp->tdb_ivlen = txform->ivmask;
- if (tdbp->tdb_flags & TDBF_HALFIV)
- tdbp->tdb_ivlen /= 2;
-
- /* Save the raw keys */
- if (tdbp->tdb_authalgxform)
- {
- tdbp->tdb_amxkeylen = ii->ii_authkeylen;
- MALLOC(tdbp->tdb_amxkey, u_int8_t *, tdbp->tdb_amxkeylen, M_XDATA,
- M_WAITOK);
- bcopy(ii->ii_authkey, tdbp->tdb_amxkey, tdbp->tdb_amxkeylen);
- }
-
+ /* Initialize crypto session */
if (tdbp->tdb_encalgxform)
{
+ /* Save the raw keys */
tdbp->tdb_emxkeylen = ii->ii_enckeylen;
MALLOC(tdbp->tdb_emxkey, u_int8_t *, tdbp->tdb_emxkeylen, M_XDATA,
M_WAITOK);
bcopy(ii->ii_enckey, tdbp->tdb_emxkey, tdbp->tdb_emxkeylen);
- }
- /* Initialize crypto session */
- if (tdbp->tdb_encalgxform)
- {
bzero(&crie, sizeof(crie));
crie.cri_alg = tdbp->tdb_encalgxform->type;
@@ -233,6 +223,12 @@ esp_init(struct tdb *tdbp, struct xformsw *xsp, struct ipsecinit *ii)
if (tdbp->tdb_authalgxform)
{
+ /* Save the raw keys */
+ tdbp->tdb_amxkeylen = ii->ii_authkeylen;
+ MALLOC(tdbp->tdb_amxkey, u_int8_t *, tdbp->tdb_amxkeylen, M_XDATA,
+ M_WAITOK);
+ bcopy(ii->ii_authkey, tdbp->tdb_amxkey, tdbp->tdb_amxkeylen);
+
bzero(&cria, sizeof(cria));
cria.cri_alg = tdbp->tdb_authalgxform->type;