Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Oct 2017 21:15:45 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r324288 - head/sys/crypto/aesni
Message-ID:  <201710042115.v94LFjp4050067@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Wed Oct  4 21:15:45 2017
New Revision: 324288
URL: https://svnweb.freebsd.org/changeset/base/324288

Log:
  aesni(4): CRYPTO_AES_NIST_GCM_16 mandates MAC
  
  Remove some dead conditionals and add an assertion around behavior already
  present in aesni_process().
  
  Silence a few Coverity false positives.
  
  CIDs:		1381571, 1381557
  Sponsored by:	Dell EMC Isilon

Modified:
  head/sys/crypto/aesni/aesni.c

Modified: head/sys/crypto/aesni/aesni.c
==============================================================================
--- head/sys/crypto/aesni/aesni.c	Wed Oct  4 21:05:44 2017	(r324287)
+++ head/sys/crypto/aesni/aesni.c	Wed Oct  4 21:15:45 2017	(r324288)
@@ -773,12 +773,15 @@ aesni_cipher_crypt(struct aesni_session *ses, struct c
 	int error, ivlen;
 	bool encflag, allocated, authallocated;
 
+	KASSERT(ses->algo != CRYPTO_AES_NIST_GCM_16 || authcrd != NULL,
+	    ("AES_NIST_GCM_16 must include MAC descriptor"));
+
 	buf = aesni_cipher_alloc(enccrd, crp, &allocated);
 	if (buf == NULL)
 		return (ENOMEM);
 
 	authallocated = false;
-	if (ses->algo == CRYPTO_AES_NIST_GCM_16 && authcrd != NULL) {
+	if (ses->algo == CRYPTO_AES_NIST_GCM_16) {
 		authbuf = aesni_cipher_alloc(authcrd, crp, &authallocated);
 		if (authbuf == NULL) {
 			error = ENOMEM;
@@ -851,7 +854,7 @@ aesni_cipher_crypt(struct aesni_session *ses, struct c
 			    iv);
 		break;
 	case CRYPTO_AES_NIST_GCM_16:
-		if (authcrd != NULL && !encflag)
+		if (!encflag)
 			crypto_copydata(crp->crp_flags, crp->crp_buf,
 			    authcrd->crd_inject, GMAC_DIGEST_LEN, tag);
 		else



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