Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 May 2019 21:05:05 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r348200 - stable/12/sys/dev/cxgbe/crypto
Message-ID:  <201905232105.x4NL550G049236@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



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