]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
crypto: adiantum - add fast path for single-page messages
authorEric Biggers <ebiggers@google.com>
Tue, 10 Oct 2023 05:59:43 +0000 (22:59 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 20 Oct 2023 05:39:25 +0000 (13:39 +0800)
commitdadf5e56c967a095213f664135784bf770eb96ab
tree6aad2475b2de73c0b03902a84dc1a8bbb8d694e3
parent01aed663e6c421aeafc9c330bda630976b50a764
crypto: adiantum - add fast path for single-page messages

When the source scatterlist is a single page, optimize the first hash
step of adiantum to use crypto_shash_digest() instead of
init/update/final, and use the same local kmap for both hashing the bulk
part and loading the narrow part of the source data.

Likewise, when the destination scatterlist is a single page, optimize
the second hash step of adiantum to use crypto_shash_digest() instead of
init/update/final, and use the same local kmap for both hashing the bulk
part and storing the narrow part of the destination data.

In some cases these optimizations improve performance significantly.

Note: ideally, for optimal performance each architecture should
implement the full "adiantum(xchacha12,aes)" algorithm and fully
optimize the contiguous buffer case to use no indirect calls.  That's
not something I've gotten around to doing, though.  This commit just
makes a relatively small change that provides some benefit with the
existing template-based approach.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/adiantum.c