Date: Mon, 8 Sep 2014 04:49:17 GMT From: John-Mark Gurney <jmg@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 1198701 for review Message-ID: <201409080449.s884nHJC020565@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@1198701?ac=10 Change 1198701 by jmg@jmg_carbon2 on 2014/08/14 07:39:04 spell crd_alg properly instead of checking the length... properly only free an allocation when allocated by using the common cleanup code... don't need to zero auth data buffer, it's associated data and not confidential... add some comments... Affected files ... .. //depot/projects/opencrypto/sys/crypto/aesni/aesni.c#3 edit Differences ... ==== //depot/projects/opencrypto/sys/crypto/aesni/aesni.c#3 (text+ko) ==== @@ -328,7 +328,7 @@ } /* CBC & XTS can only handle full blocks for now */ - if ((enccrd->crd_len == CRYPTO_AES_CBC || enccrd->crd_len == + if ((enccrd->crd_alg == CRYPTO_AES_CBC || enccrd->crd_alg == CRYPTO_AES_XTS) && (enccrd->crd_len % AES_BLOCK_LEN) != 0) { error = EINVAL; goto out; @@ -442,6 +442,9 @@ printf("%02hhx", ptr[i]); } +/* + * authcrd contains the associated date. + */ static int aesni_cipher_process(struct aesni_session *ses, struct cryptodesc *enccrd, struct cryptodesc *authcrd, struct cryptop *crp) @@ -463,10 +466,8 @@ authallocated = 0; if (authcrd != NULL) { authbuf = aesni_cipher_alloc(authcrd, crp, &authallocated); - if (authbuf == NULL) { - free(buf, M_AESNI); - return (ENOMEM); - } + if (authbuf == NULL) + goto out1; } td = curthread; @@ -574,7 +575,7 @@ crypto_copyback(crp->crp_flags, crp->crp_buf, enccrd->crd_skip, enccrd->crd_len, buf); - /* OpenBSD doesn't copy this back. */ + /* OpenBSD doesn't copy this back. Why not? */ if ((enccrd->crd_flags & CRD_F_ENCRYPT) != 0) crypto_copydata(crp->crp_flags, crp->crp_buf, enccrd->crd_skip + enccrd->crd_len - AES_BLOCK_LEN, @@ -592,9 +593,7 @@ bzero(buf, enccrd->crd_len); free(buf, M_AESNI); } - if (authallocated) { - bzero(authbuf, authcrd->crd_len); + if (authallocated) free(authbuf, M_AESNI); - } return (error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409080449.s884nHJC020565>