crypto: arm64/sha2-ce - implement ->digest for sha256
Subsystems (2)
PATCH 1/1 crypto: arm64/sha2-ce - implement ->digest for sha256
From: Eric Biggers <[email protected]>
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.
--- arch/arm64/crypto/sha2-ce-glue.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm64/crypto/sha2-ce-glue.c +8 -0
@@ -109,20 +109,27 @@ static int sha256_ce_final(struct shash_desc *desc, u8 *out)if (!crypto_simd_usable ()) {sha256_base_do_finalize (desc, __sha256_block_data_order);return sha256_base_finish (desc, out); } sctx->finalize =0 ;sha256_base_do_finalize (desc, __sha2_ce_transform);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) {struct sha256_ce_state *sctx =shash_desc_ctx (desc);memcpy (out, &sctx->sst,sizeof (struct sha256_state ));return 0 ; }static int sha256_ce_import (struct shash_desc *desc,const void *in) {
@@ -148,20 +155,21 @@ static struct shash_alg algs[] = { { .cra_driver_name = "sha224-ce", .cra_priority = 200, .cra_blocksize = SHA256_BLOCK_SIZE, .cra_module = THIS_MODULE, } }, { .init = sha256_base_init, .update = sha256_ce_update, .final = sha256_ce_final, .finup = sha256_ce_finup, + .digest = sha256_ce_digest, .export = sha256_ce_export, .import = sha256_ce_import, .descsize = sizeof(struct sha256_ce_state), .statesize = sizeof(struct sha256_state), .digestsize = SHA256_DIGEST_SIZE, .base = { .cra_name = "sha256", .cra_driver_name = "sha256-ce", .cra_priority = 200, .cra_blocksize = SHA256_BLOCK_SIZE,
base-commit: 8468516f9f93a41dc65158b6428a1a1039c68f20
Signature · 1 line
2.42.0
Herbert Xu
maintainerQuoted 7 lines · Eric Biggers
From: Eric Biggers <[email protected]>
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.
Quoted 6 lines
For now, don't bother with this for sha224, since sha224 is rarely used.
Signed-off-by Eric Biggers <[email protected]>---
arch/arm64/crypto/sha2-ce-glue.c| 8 ++++++++1 file changed, 8 insertions(+)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt