Re: [PATCH] sample/tsm-mr: Use SHA-2 library APIs
From: Dan Williams
Date: Thu Mar 19 2026 - 14:04:28 EST
Eric Biggers wrote:
> On Wed, Mar 18, 2026 at 08:57:01PM +0100, Arnd Bergmann wrote:
> > On Wed, Mar 18, 2026, at 17:42, Eric Biggers wrote:
> > > Given that tsm_mr_sample has a particular set of algorithms that it
> > > wants, just use the library APIs for those algorithms rather than
> > > crypto_shash. This is more straightforward and a bit more efficient.
> > >
> > > This fixes an issue where this module failed to build due to the kconfig
> > > options CRYPTO and CRYPTO_HASH not being selected. Also, even if it
> > > built, crypto_alloc_shash() could fail at runtime due to the needed
> > > algorithms not being available.
> > >
> > > The library functions simply use direct linking. So if it builds, which
> > > it will due to the kconfig options being enabled, they are available.
> > >
> > > Fixes: f6953f1f9ec4 ("tsm-mr: Add tsm-mr sample code")
> > > Fixes: 44a3873df811 ("coco/guest: Remove unneeded selection of CRYPTO")
> > > Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
> > > ---
> > >
> > > I'd like to take this via libcrypto-next, as that is where
> > > "coco/guest: Remove unneeded selection of CRYPTO" is.
> >
> > Thanks for fixing this! It is indeed nicer than the fix
> > I sent earlier today.
> >
> > Acked-by: Arnd Bergmann <arnd@xxxxxxxx>
>
> Thanks. Additional acks from the people owning this code (Dan, Cedric?)
> would be appreciated. But since this fixes a build error and is related
> to the crypto library, I went ahead and applied this to
> https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next
>
> I also found that the build error is pre-existing, as CRYPTO_HASH was
> not being selected. "coco/guest: Remove unneeded selection of CRYPTO"
> just made it a bit easier to encounter, by not selecting CRYPTO either.
>
> So I updated the second paragraph of the commit message to:
>
> This also fixes a bug where this module failed to build if it was
> enabled without CRYPTO_HASH happening to be set elsewhere in the
> kconfig. (With the concurrent change to make TSM_MEASUREMENTS stop
> selecting CRYPTO, this existing build error would have become easier to
> encounter, as well.) Also, even if it built, crypto_alloc_shash() could
> fail at runtime due to the needed algorithms not being available.
>
> I also put this commit before "coco/guest: Remove unneeded selection of
> CRYPTO" and dropped the Fixes reference to that. So now it just has:
>
> Fixes: f6953f1f9ec4 ("tsm-mr: Add tsm-mr sample code")
It looks good to me:
Acked-by: Dan Williams <dan.j.williams@xxxxxxxxx>
Feel free to take it through your tree since I have nothing immediately
pending for tsm.git.