Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Nov 2015 07:10:42 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r290924 - in head/sys: netipsec opencrypto
Message-ID:  <201511160710.tAG7AgJO082295@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Mon Nov 16 07:10:42 2015
New Revision: 290924
URL: https://svnweb.freebsd.org/changeset/base/290924

Log:
  Use explicitly specified ivsize instead of blocksize when we mean IV size.
  Set zero ivsize for enc_xform_null and remove special handling from
  xform_esp.c.
  
  Reviewed by:	gnn
  Differential Revision:	https://reviews.freebsd.org/D1503

Modified:
  head/sys/netipsec/key.c
  head/sys/netipsec/xform_esp.c
  head/sys/opencrypto/xform.c

Modified: head/sys/netipsec/key.c
==============================================================================
--- head/sys/netipsec/key.c	Mon Nov 16 07:03:00 2015	(r290923)
+++ head/sys/netipsec/key.c	Mon Nov 16 07:10:42 2015	(r290924)
@@ -6706,7 +6706,7 @@ key_register(struct socket *so, struct m
 				continue;
 			alg = (struct sadb_alg *)(mtod(n, caddr_t) + off);
 			alg->sadb_alg_id = i;
-			alg->sadb_alg_ivlen = ealgo->blocksize;
+			alg->sadb_alg_ivlen = ealgo->ivsize;
 			alg->sadb_alg_minbits = _BITS(ealgo->minkey);
 			alg->sadb_alg_maxbits = _BITS(ealgo->maxkey);
 			off += PFKEY_ALIGN8(sizeof(struct sadb_alg));

Modified: head/sys/netipsec/xform_esp.c
==============================================================================
--- head/sys/netipsec/xform_esp.c	Mon Nov 16 07:03:00 2015	(r290923)
+++ head/sys/netipsec/xform_esp.c	Mon Nov 16 07:10:42 2015	(r290924)
@@ -200,16 +200,10 @@ esp_init(struct secasvar *sav, struct xf
 		return EINVAL;
 	}
 
-	/*
-	 * NB: The null xform needs a non-zero blocksize to keep the
-	 *      crypto code happy but if we use it to set ivlen then
-	 *      the ESP header will be processed incorrectly.  The
-	 *      compromise is to force it to zero here.
-	 */
 	if (SAV_ISCTRORGCM(sav))
 		sav->ivlen = 8;	/* RFC4106 3.1 and RFC3686 3.1 */
 	else
-		sav->ivlen = (txform == &enc_xform_null ? 0 : txform->ivsize);
+		sav->ivlen = txform->ivsize;
 
 	/*
 	 * Setup AH-related state.

Modified: head/sys/opencrypto/xform.c
==============================================================================
--- head/sys/opencrypto/xform.c	Mon Nov 16 07:03:00 2015	(r290923)
+++ head/sys/opencrypto/xform.c	Mon Nov 16 07:10:42 2015	(r290924)
@@ -154,7 +154,7 @@ MALLOC_DEFINE(M_XDATA, "xform", "xform d
 struct enc_xform enc_xform_null = {
 	CRYPTO_NULL_CBC, "NULL",
 	/* NB: blocksize of 4 is to generate a properly aligned ESP header */
-	NULL_BLOCK_LEN, NULL_BLOCK_LEN, NULL_MIN_KEY, NULL_MAX_KEY, 
+	NULL_BLOCK_LEN, 0, NULL_MIN_KEY, NULL_MAX_KEY, 
 	null_encrypt,
 	null_decrypt,
 	null_setkey,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511160710.tAG7AgJO082295>