Commit 1efcbf0e authored by Eric Biggers's avatar Eric Biggers Committed by Herbert Xu

crypto: arm64/sha2-ce - implement ->digest for sha256

Implement a ->digest function for sha256-ce.  This improves the
performance of crypto_shash_digest() with this algorithm by reducing the
number of indirect calls that are made.  This only adds ~112 bytes of
code, mostly for the inlined init, as the finup function is tail-called.

For now, don't bother with this for sha224, since sha224 is rarely used.
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 2e02c25a
...@@ -116,6 +116,13 @@ static int sha256_ce_final(struct shash_desc *desc, u8 *out) ...@@ -116,6 +116,13 @@ static int sha256_ce_final(struct shash_desc *desc, u8 *out)
return sha256_base_finish(desc, out); return sha256_base_finish(desc, out);
} }
static int sha256_ce_digest(struct shash_desc *desc, const u8 *data,
unsigned int len, u8 *out)
{
sha256_base_init(desc);
return sha256_ce_finup(desc, data, len, out);
}
static int sha256_ce_export(struct shash_desc *desc, void *out) static int sha256_ce_export(struct shash_desc *desc, void *out)
{ {
struct sha256_ce_state *sctx = shash_desc_ctx(desc); struct sha256_ce_state *sctx = shash_desc_ctx(desc);
...@@ -155,6 +162,7 @@ static struct shash_alg algs[] = { { ...@@ -155,6 +162,7 @@ static struct shash_alg algs[] = { {
.update = sha256_ce_update, .update = sha256_ce_update,
.final = sha256_ce_final, .final = sha256_ce_final,
.finup = sha256_ce_finup, .finup = sha256_ce_finup,
.digest = sha256_ce_digest,
.export = sha256_ce_export, .export = sha256_ce_export,
.import = sha256_ce_import, .import = sha256_ce_import,
.descsize = sizeof(struct sha256_ce_state), .descsize = sizeof(struct sha256_ce_state),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment