All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: hmac - Improve local variable types
@ 2024-09-24 11:27 Thorsten Blum
  2024-10-05  4:57 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2024-09-24 11:27 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller; +Cc: Thorsten Blum, linux-crypto, linux-kernel

Since crypto_shash_blocksize(), crypto_shash_digestsize(), and
crypto_shash_statesize() return an unsigned int, also use unsigned int
for the local variables.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 crypto/hmac.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/crypto/hmac.c b/crypto/hmac.c
index 7cec25ff9889..6ab7ce4cb930 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -31,9 +31,9 @@ struct hmac_ctx {
 static int hmac_setkey(struct crypto_shash *parent,
 		       const u8 *inkey, unsigned int keylen)
 {
-	int bs = crypto_shash_blocksize(parent);
-	int ds = crypto_shash_digestsize(parent);
-	int ss = crypto_shash_statesize(parent);
+	unsigned int bs = crypto_shash_blocksize(parent);
+	unsigned int ds = crypto_shash_digestsize(parent);
+	unsigned int ss = crypto_shash_statesize(parent);
 	struct hmac_ctx *tctx = crypto_shash_ctx(parent);
 	struct crypto_shash *hash = tctx->hash;
 	u8 *ipad = &tctx->pads[0];
@@ -108,8 +108,8 @@ static int hmac_update(struct shash_desc *pdesc,
 static int hmac_final(struct shash_desc *pdesc, u8 *out)
 {
 	struct crypto_shash *parent = pdesc->tfm;
-	int ds = crypto_shash_digestsize(parent);
-	int ss = crypto_shash_statesize(parent);
+	unsigned int ds = crypto_shash_digestsize(parent);
+	unsigned int ss = crypto_shash_statesize(parent);
 	const struct hmac_ctx *tctx = crypto_shash_ctx(parent);
 	const u8 *opad = &tctx->pads[ss];
 	struct shash_desc *desc = shash_desc_ctx(pdesc);
@@ -124,8 +124,8 @@ static int hmac_finup(struct shash_desc *pdesc, const u8 *data,
 {
 
 	struct crypto_shash *parent = pdesc->tfm;
-	int ds = crypto_shash_digestsize(parent);
-	int ss = crypto_shash_statesize(parent);
+	unsigned int ds = crypto_shash_digestsize(parent);
+	unsigned int ss = crypto_shash_statesize(parent);
 	const struct hmac_ctx *tctx = crypto_shash_ctx(parent);
 	const u8 *opad = &tctx->pads[ss];
 	struct shash_desc *desc = shash_desc_ctx(pdesc);
-- 
2.46.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: hmac - Improve local variable types
  2024-09-24 11:27 [PATCH] crypto: hmac - Improve local variable types Thorsten Blum
@ 2024-10-05  4:57 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2024-10-05  4:57 UTC (permalink / raw)
  To: Thorsten Blum; +Cc: David S. Miller, linux-crypto, linux-kernel

On Tue, Sep 24, 2024 at 01:27:27PM +0200, Thorsten Blum wrote:
> Since crypto_shash_blocksize(), crypto_shash_digestsize(), and
> crypto_shash_statesize() return an unsigned int, also use unsigned int
> for the local variables.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  crypto/hmac.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/crypto/hmac.c b/crypto/hmac.c
> index 7cec25ff9889..6ab7ce4cb930 100644
> --- a/crypto/hmac.c
> +++ b/crypto/hmac.c
> @@ -31,9 +31,9 @@ struct hmac_ctx {
>  static int hmac_setkey(struct crypto_shash *parent,
>  		       const u8 *inkey, unsigned int keylen)
>  {
> -	int bs = crypto_shash_blocksize(parent);
> -	int ds = crypto_shash_digestsize(parent);
> -	int ss = crypto_shash_statesize(parent);
> +	unsigned int bs = crypto_shash_blocksize(parent);
> +	unsigned int ds = crypto_shash_digestsize(parent);
> +	unsigned int ss = crypto_shash_statesize(parent);

These values are all capped by the API.  So I don't think this
churn is worth it.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-05  5:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-24 11:27 [PATCH] crypto: hmac - Improve local variable types Thorsten Blum
2024-10-05  4:57 ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.