diff options
author | Eric Biggers <ebiggers@google.com> | 2023-10-09 00:32:13 -0700 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2023-10-20 13:39:25 +0800 |
commit | e5dcb2c03a0cecf042e52ca1c84f7c6595723fe5 (patch) | |
tree | 39dd3c069a3f55de673307c06c9e10084a0b03e0 /crypto/sha256_generic.c | |
parent | 7612222ba4d506b41beb8f40abaa206942a4109a (diff) | |
download | linux-crypto-e5dcb2c03a0cecf042e52ca1c84f7c6595723fe5.tar.gz linux-crypto-e5dcb2c03a0cecf042e52ca1c84f7c6595723fe5.zip |
crypto: shash - optimize the default digest and finup
For an shash algorithm that doesn't implement ->digest, currently
crypto_shash_digest() with aligned input makes 5 indirect calls: 1 to
shash_digest_unaligned(), 1 to ->init, 2 to ->update ('alignmask + 1'
bytes, then the rest), then 1 to ->final. This is true even if the
algorithm implements ->finup. This is caused by an unnecessary fallback
to code meant to handle unaligned inputs. In fact,
crypto_shash_digest() already does the needed alignment check earlier.
Therefore, optimize the number of indirect calls for aligned inputs to 3
when the algorithm implements ->finup. It remains at 5 when the
algorithm implements neither ->finup nor ->digest.
Similarly, for an shash algorithm that doesn't implement ->finup,
currently crypto_shash_finup() with aligned input makes 4 indirect
calls: 1 to shash_finup_unaligned(), 2 to ->update, and
1 to ->final. Optimize this to 3 calls.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/sha256_generic.c')
0 files changed, 0 insertions, 0 deletions