On Sat, Mar 29, 2025 at 11:19:19AM -0700, Linus Torvalds wrote: > On Sat, 29 Mar 2025 at 11:17, Linus Torvalds > <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote: > > > > I happened to just merge the rdma updates a couple of minutes ago, and > > they actually removed the example I was using (ie the whole "use > > crypto layer for crc32c" insanity). > > Heh. Looking closer, the "they" was actually you who did the patch and > Leon who applied it. > > Linus Yes. Those cases were just a single algorithm, though, so of course the library was simpler. fs-verity supports two hash algorithms (SHA-256 and SHA-512), and dm-verity unfortunately supports every hash algorithm the crypto API supports since it accepts it as a string and passes it directly to the crypto API. I know for sure dm-verity is used with at least SHA-256, SHA-1, and BLAKE2b, but there could be more. The crypto API also supports various "national pride" algorithms like SM3 and Streebog, for example, and some people might expect those to work with dm-verity. (Unfortunately SM3 keeps getting pushed into various standards, libraries, CPU instruction sets, etc.) So for fs-verity we'd basically need: if (using SHA-256) sha256() else sha512() (and the same for any other algorithms that may get added in the future) And for dm-verity we'd basically need: if (using SHA-256) sha256() else Use crypto_ahash or crypto_shash to handle arbitrary algorithm And that's okay -- we can do that. Just crypto_shash ends up being approximately what is needed already, so just using it seems slightly preferable. But using the libraries whenever possible would be fine with me too. - Eric