Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Nov 2014 05:40:46 GMT
From:      John-Mark Gurney <jmg@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 1202876 for review
Message-ID:  <201411160540.sAG5ek3P043443@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@1202876?ac=10

Change 1202876 by jmg@jmg_carbon2 on 2014/11/16 05:40:36

	for some reason, when I access mbuf directly, things don't
	work...  more investigation is needed...
	
	Simplify how IV's are calculated..  There needs to be more
	work in this area...
	
	Sponsored by:	FreeBSD Foundation
	Sponsored by:	Netgate

Affected files ...

.. //depot/projects/opencrypto/sys/crypto/aesni/aesni.c#15 edit

Differences ...

==== //depot/projects/opencrypto/sys/crypto/aesni/aesni.c#15 (text+ko) ====

@@ -382,6 +382,7 @@
 	uint8_t *addr;
 
 	if (crp->crp_flags & CRYPTO_F_IMBUF) {
+		goto alloc;
 		m = (struct mbuf *)crp->crp_buf;
 		if (m->m_next != NULL)
 			goto alloc;
@@ -505,7 +506,7 @@
 	switch (enccrd->crd_alg) {
 	case CRYPTO_AES_CBC:
 	case CRYPTO_AES_ICM:
-		ivlen = 16;
+		ivlen = AES_BLOCK_LEN;
 		break;
 	case CRYPTO_AES_XTS:
 		ivlen = 8;
@@ -517,21 +518,13 @@
 
 	/* Setup ses->iv */
 	bzero(ses->iv, sizeof ses->iv);
-	if (encflag) {
-		if ((enccrd->crd_flags & CRD_F_IV_EXPLICIT) != 0)
-			bcopy(enccrd->crd_iv, ses->iv, ivlen);
-		else
-			arc4rand(ses->iv, ivlen, 0);
-		if ((enccrd->crd_flags & CRD_F_IV_PRESENT) == 0)
-			crypto_copyback(crp->crp_flags, crp->crp_buf,
-			    enccrd->crd_inject, ivlen, ses->iv);
-	} else {
-		if ((enccrd->crd_flags & CRD_F_IV_EXPLICIT) != 0)
-			bcopy(enccrd->crd_iv, ses->iv, ivlen);
-		else
-			crypto_copydata(crp->crp_flags, crp->crp_buf,
-			    enccrd->crd_inject, ivlen, ses->iv);
-	}
+	if ((enccrd->crd_flags & CRD_F_IV_EXPLICIT) != 0)
+		bcopy(enccrd->crd_iv, ses->iv, ivlen);
+	else if (encflag && ((enccrd->crd_flags & CRD_F_IV_PRESENT) != 0))
+		arc4rand(ses->iv, ivlen, 0);
+	else
+		crypto_copydata(crp->crp_flags, crp->crp_buf,
+		    enccrd->crd_inject, ivlen, ses->iv);
 
 	if (authcrd != NULL && !encflag)
 		crypto_copydata(crp->crp_flags, crp->crp_buf,



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