Linux cryptographic layer development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>,
	linux-crypto@vger.kernel.org,
	"Herbert Xu" <herbert@gondor.apana.org.au>
Cc: "Srujana Challa" <schalla@marvell.com>,
	"Bharat Bhushan" <bbhushan2@marvell.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Arnaud Ebalard" <arno@natisbad.org>,
	"Boris Brezillon" <bbrezillon@kernel.org>,
	"Russell King" <rmk+kernel@arm.linux.org.uk>,
	"Romain Perier" <romain.perier@free-electrons.com>
Subject: Re: [PATCH 4/8] crypto: cesa - finish the HMAC outer hash when padding by hand
Date: Sat, 28 Nov 2026 04:52:04 +0000	[thread overview]
Message-ID: <sashiko-outbox-238462@kernel.org> (raw)
In-Reply-To: <20261128044050.722617-5-rosenp@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] crypto: cesa - Fixes trailer cites TDMA commit instead of
  f63601fd616a
--

commit 1b090efdccb0bcfaec213f4a5b0122cbc6cbc29d
Author: Rosen Penev <rosenp@gmail.com>

> crypto: cesa - finish the HMAC outer hash when padding by hand
>
> The engine applies the HMAC outer hash only when it finalises the
> message itself, i.e. on a last or unfragmented operation that has data
> and whose total length fits the descriptor field (0xffff). Otherwise
> the driver pads the message by hand and runs the padding as a middle
> fragment, which leaves the engine with a plain inner hash state. For
> HMAC that is wrong twice over:
>
>  - the padding encodes the message length only, while the inner hash
>    also covers the ipad block, and
>  - the outer hash is never computed, so the result read back from the
>    IVDIG registers is H(ipad || m) instead of HMAC(k, m).
>
> This hits every HMAC whose last request has no data left to hash, i.e.
> any update()/final() sequence over a block-aligned length and any
> finup() or digest() of an empty message, and every HMAC of 64 KiB or
> more.
>
> Count the ipad block in the manual padding of HMAC requests, and when
> the result comes from the IVDIG registers on the last request of an
> HMAC, finish the outer hash in software: import the opad state computed
> at setkey time into a software hash, with one block already counted,
> and hash the inner digest. Each HMAC transform allocates that software
> hash at cra_init(). Select the software hashes so they are always
> available.
>
> Verified on an Armada 385 (WRT3200ACM) against the software HMACs,
> single threaded with random lengths and update splits: about 0.5% of
> HMAC-SHA1 and HMAC-SHA256 digests were wrong before, all of them with a
> block-aligned total length, and none of about 195000 after, nor of
> 30000 more with lengths up to 140000 bytes. HMAC-MD5 was not tested:
> the test kernel has no software MD5.
>
> Fixes: db509a45339f ("crypto: marvell/cesa - add TDMA support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Rosen Penev <rosenp@gmail.com>

[Severity: Low]
Should the Fixes tag reference f63601fd616a ("crypto: marvell/cesa - add a
new driver for Marvell's CESA") instead?  mv_cesa_ahash_pad_req(), the
manual padding fallback in mv_cesa_ahash_std_step(), and the CESA_IVDIG
result readback for HMAC were all introduced in that initial driver commit
rather than in db509a45339f ("crypto: marvell/cesa - add TDMA support").

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261128044050.722617-1-rosenp@gmail.com?part=4

  reply	other threads:[~2026-11-28  4:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28  4:40 [PATCH 0/8] crypto: cesa - fixes for the Marvell CESA driver Rosen Penev
2026-11-28  4:40 ` [PATCH 1/8] crypto: cesa - clear the IRQ affinity hint before freeing the IRQ Rosen Penev
2026-11-28  4:40 ` [PATCH 2/8] crypto: cesa - do not allow unbinding the device Rosen Penev
2026-11-28  4:40 ` [PATCH 3/8] crypto: cesa - hash the last full SRAM chunk before the padding Rosen Penev
2026-11-28  4:40 ` [PATCH 4/8] crypto: cesa - finish the HMAC outer hash when padding by hand Rosen Penev
2026-11-28  4:52   ` sashiko-bot [this message]
2026-11-28  4:40 ` [PATCH 5/8] crypto: cesa - keep the chained IV on the non-TDMA cipher path Rosen Penev
2026-11-28  4:40 ` [PATCH 6/8] crypto: cesa - put the non-TDMA hash padding behind the data Rosen Penev
2026-11-28  4:40 ` [PATCH 7/8] crypto: cesa - do not step empty hash operations on the non-TDMA path Rosen Penev
2026-11-28  4:40 ` [PATCH 8/8] crypto: cesa - finish long hashes " Rosen Penev
2026-11-28  4:52   ` sashiko-bot

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=sashiko-outbox-238462@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=arno@natisbad.org \
    --cc=bbhushan2@marvell.com \
    --cc=bbrezillon@kernel.org \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=rmk+kernel@arm.linux.org.uk \
    --cc=romain.perier@free-electrons.com \
    --cc=rosenp@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=schalla@marvell.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