svn commit: r348200 - stable/12/sys/dev/cxgbe/crypto

John Baldwin jhb at FreeBSD.org
Thu May 23 21:05:06 UTC 2019


Author: jhb
Date: Thu May 23 21:05:05 2019
New Revision: 348200
URL: https://svnweb.freebsd.org/changeset/base/348200

Log:
  MFC 346648: Fix requests for "plain" SHA digests of an empty buffer.
  
  To workaround limitations in the crypto engine, empty buffers are
  handled by manually constructing the final length block as the payload
  passed to the crypto engine and disabling the normal "final" handling.
  For HMAC this length block should hold the length of a single block
  since the hash is actually the hash of the IPAD digest, but for
  "plain" SHA the length should be zero instead.

Modified:
  stable/12/sys/dev/cxgbe/crypto/t4_crypto.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/crypto/t4_crypto.c
==============================================================================
--- stable/12/sys/dev/cxgbe/crypto/t4_crypto.c	Thu May 23 21:02:27 2019	(r348199)
+++ stable/12/sys/dev/cxgbe/crypto/t4_crypto.c	Thu May 23 21:05:05 2019	(r348200)
@@ -537,8 +537,9 @@ ccr_hash(struct ccr_softc *sc, struct ccr_session *s, 
 	dst = (char *)(crwr + 1) + kctx_len + DUMMY_BYTES;
 	if (crd->crd_len == 0) {
 		dst[0] = 0x80;
-		*(uint64_t *)(dst + axf->blocksize - sizeof(uint64_t)) =
-		    htobe64(axf->blocksize << 3);
+		if (s->mode == HMAC)
+			*(uint64_t *)(dst + axf->blocksize - sizeof(uint64_t)) =
+			    htobe64(axf->blocksize << 3);
 	} else if (imm_len != 0)
 		crypto_copydata(crp->crp_flags, crp->crp_buf, crd->crd_skip,
 		    crd->crd_len, dst);


More information about the svn-src-stable-12 mailing list