diff mbox series

[02/30] crypto: sun4i-ss - remove unnecessary alignmask for ahashes

Message ID 20231022081100.123613-3-ebiggers@kernel.org (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series crypto: reduce ahash API overhead | expand

Commit Message

Eric Biggers Oct. 22, 2023, 8:10 a.m. UTC
From: Eric Biggers <ebiggers@google.com>

The crypto API's support for alignmasks for ahash algorithms is nearly
useless, as its only effect is to cause the API to align the key and
result buffers.  The drivers that happen to be specifying an alignmask
for ahash rarely actually need it.  When they do, it's easily fixable,
especially considering that these buffers cannot be used for DMA.

In preparation for removing alignmask support from ahash, this patch
makes the sun4i-ss driver no longer use it.  This driver didn't actually
rely on it; it only writes to the result buffer in sun4i_hash(), already
using the unaligned access helpers.  And this driver only supports
unkeyed hash algorithms, so the key buffer need not be considered.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Corentin Labbe Oct. 25, 2023, 1:15 p.m. UTC | #1
Le Sun, Oct 22, 2023 at 01:10:32AM -0700, Eric Biggers a écrit :
> From: Eric Biggers <ebiggers@google.com>
> 
> The crypto API's support for alignmasks for ahash algorithms is nearly
> useless, as its only effect is to cause the API to align the key and
> result buffers.  The drivers that happen to be specifying an alignmask
> for ahash rarely actually need it.  When they do, it's easily fixable,
> especially considering that these buffers cannot be used for DMA.
> 
> In preparation for removing alignmask support from ahash, this patch
> makes the sun4i-ss driver no longer use it.  This driver didn't actually
> rely on it; it only writes to the result buffer in sun4i_hash(), already
> using the unaligned access helpers.  And this driver only supports
> unkeyed hash algorithms, so the key buffer need not be considered.
> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c
> index 3bcfcfc370842..e23a020a64628 100644
> --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c
> +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c
> @@ -42,21 +42,20 @@ static struct sun4i_ss_alg_template ss_algs[] = {
>  		.digest = sun4i_hash_digest,
>  		.export = sun4i_hash_export_md5,
>  		.import = sun4i_hash_import_md5,
>  		.halg = {
>  			.digestsize = MD5_DIGEST_SIZE,
>  			.statesize = sizeof(struct md5_state),
>  			.base = {
>  				.cra_name = "md5",
>  				.cra_driver_name = "md5-sun4i-ss",
>  				.cra_priority = 300,
> -				.cra_alignmask = 3,
>  				.cra_blocksize = MD5_HMAC_BLOCK_SIZE,
>  				.cra_ctxsize = sizeof(struct sun4i_req_ctx),
>  				.cra_module = THIS_MODULE,
>  				.cra_init = sun4i_hash_crainit,
>  				.cra_exit = sun4i_hash_craexit,
>  			}
>  		}
>  	}
>  },
>  {       .type = CRYPTO_ALG_TYPE_AHASH,
> @@ -69,21 +68,20 @@ static struct sun4i_ss_alg_template ss_algs[] = {
>  		.digest = sun4i_hash_digest,
>  		.export = sun4i_hash_export_sha1,
>  		.import = sun4i_hash_import_sha1,
>  		.halg = {
>  			.digestsize = SHA1_DIGEST_SIZE,
>  			.statesize = sizeof(struct sha1_state),
>  			.base = {
>  				.cra_name = "sha1",
>  				.cra_driver_name = "sha1-sun4i-ss",
>  				.cra_priority = 300,
> -				.cra_alignmask = 3,
>  				.cra_blocksize = SHA1_BLOCK_SIZE,
>  				.cra_ctxsize = sizeof(struct sun4i_req_ctx),
>  				.cra_module = THIS_MODULE,
>  				.cra_init = sun4i_hash_crainit,
>  				.cra_exit = sun4i_hash_craexit,
>  			}
>  		}
>  	}
>  },
>  {       .type = CRYPTO_ALG_TYPE_SKCIPHER,
> -- 
> 2.42.0
> 
Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>

Thanks
diff mbox series

Patch

diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c
index 3bcfcfc370842..e23a020a64628 100644
--- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c
+++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c
@@ -42,21 +42,20 @@  static struct sun4i_ss_alg_template ss_algs[] = {
 		.digest = sun4i_hash_digest,
 		.export = sun4i_hash_export_md5,
 		.import = sun4i_hash_import_md5,
 		.halg = {
 			.digestsize = MD5_DIGEST_SIZE,
 			.statesize = sizeof(struct md5_state),
 			.base = {
 				.cra_name = "md5",
 				.cra_driver_name = "md5-sun4i-ss",
 				.cra_priority = 300,
-				.cra_alignmask = 3,
 				.cra_blocksize = MD5_HMAC_BLOCK_SIZE,
 				.cra_ctxsize = sizeof(struct sun4i_req_ctx),
 				.cra_module = THIS_MODULE,
 				.cra_init = sun4i_hash_crainit,
 				.cra_exit = sun4i_hash_craexit,
 			}
 		}
 	}
 },
 {       .type = CRYPTO_ALG_TYPE_AHASH,
@@ -69,21 +68,20 @@  static struct sun4i_ss_alg_template ss_algs[] = {
 		.digest = sun4i_hash_digest,
 		.export = sun4i_hash_export_sha1,
 		.import = sun4i_hash_import_sha1,
 		.halg = {
 			.digestsize = SHA1_DIGEST_SIZE,
 			.statesize = sizeof(struct sha1_state),
 			.base = {
 				.cra_name = "sha1",
 				.cra_driver_name = "sha1-sun4i-ss",
 				.cra_priority = 300,
-				.cra_alignmask = 3,
 				.cra_blocksize = SHA1_BLOCK_SIZE,
 				.cra_ctxsize = sizeof(struct sun4i_req_ctx),
 				.cra_module = THIS_MODULE,
 				.cra_init = sun4i_hash_crainit,
 				.cra_exit = sun4i_hash_craexit,
 			}
 		}
 	}
 },
 {       .type = CRYPTO_ALG_TYPE_SKCIPHER,