Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Cc: Thara Gopinath <thara.gopinath@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Stanimir Varbanov <svarbanov@mm-sol.com>,
	Eneas U de Queiroz <cotequeiroz@gmail.com>,
	Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>,
	Eric Biggers <ebiggers@kernel.org>,
	linux-crypto@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, brgl@kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v4 2/8] crypto: qce - Fix HMAC self-test failures for empty messages
Date: Fri, 3 Jul 2026 17:23:51 +0800	[thread overview]
Message-ID: <akd_p0Psntcp01F1@gondor.apana.org.au> (raw)
In-Reply-To: <20260622-qce-fix-self-tests-v4-2-4f82ffa716c6@oss.qualcomm.com>

On Mon, Jun 22, 2026 at 03:18:10PM +0200, Bartosz Golaszewski wrote:
> BAM DMA cannot process zero-length transfers. For plain hashes this is
> handled by returning the precomputed hash of the empty message
> (tmpl->hash_zero), but for keyed HMAC the result depends on the key and
> cannot be a constant. As a result, hmac(sha256) produced an incorrect
> digest for an empty message and the crypto self-tests failed.
> 
> Allocate a software fallback ahash for the HMAC transforms and use it to
> compute the digest whenever the message is empty (in both the .final()
> and .digest() paths). The fallback is allocated in a dedicated cra_init
> for the HMAC algorithms and is excluded from matching the crypto engine's
> own algorithm to avoid recursion. It is kept keyed in sync with the
> hardware transform in .setkey().
> 
> Cc: stable@vger.kernel.org
> Fixes: ec8f5d8f6f76 ("crypto: qce - Qualcomm crypto engine driver")
> Tested-by: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
>  drivers/crypto/qce/sha.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++-
>  drivers/crypto/qce/sha.h |  1 +
>  2 files changed, 84 insertions(+), 1 deletion(-)

There is no need to allocate fallbacks anymore because the Crypto
API now does it unconditionally.

Please see aspeed for an example on how to use the fallback.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  reply	other threads:[~2026-07-03  9:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22 13:18 [PATCH v4 0/8] crypto: qce - Fix crypto self-test failures Bartosz Golaszewski
2026-06-22 13:18 ` [PATCH v4 1/8] crypto: qce - Remove unsafe/deprecated algorithms Bartosz Golaszewski
2026-07-05  8:38   ` Herbert Xu
2026-06-22 13:18 ` [PATCH v4 2/8] crypto: qce - Fix HMAC self-test failures for empty messages Bartosz Golaszewski
2026-07-03  9:23   ` Herbert Xu [this message]
2026-06-22 13:18 ` [PATCH v4 3/8] crypto: qce - Reject empty messages for AES-XTS Bartosz Golaszewski
2026-06-22 13:18 ` [PATCH v4 4/8] crypto: qce - Fix CTR-AES for partial block requests Bartosz Golaszewski
2026-06-22 13:18 ` [PATCH v4 5/8] crypto: qce - Use a fallback for AES-CTR with a partial final block Bartosz Golaszewski
2026-06-22 13:18 ` [PATCH v4 6/8] crypto: qce - Fix xts-aes-qce for weak keys Bartosz Golaszewski
2026-06-22 13:18 ` [PATCH v4 7/8] crypto: qce - Use a fallback for CCM with a partial final block Bartosz Golaszewski
2026-06-22 13:18 ` [PATCH v4 8/8] crypto: qce - Use fallback for CCM with a fragmented payload Bartosz Golaszewski
2026-07-02  7:54 ` [PATCH v4 0/8] crypto: qce - Fix crypto self-test failures Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=akd_p0Psntcp01F1@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=cotequeiroz@gmail.com \
    --cc=davem@davemloft.net \
    --cc=ebiggers@kernel.org \
    --cc=kuldeep.singh@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=svarbanov@mm-sol.com \
    --cc=thara.gopinath@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox