linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Gilad Ben-Yossef <gilad@benyossef.com>,
	Eric Biggers <ebiggers@google.com>,
	Mimi Zohar <zohar@linux.ibm.com>,
	Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Jia Zhang <zhang.jia@linux.alibaba.com>
Subject: Re: [PATCH] crypto: sm3 - use the more precise type u32 instead of unsigned int
Date: Fri, 26 Mar 2021 09:59:50 +0100	[thread overview]
Message-ID: <CAMj1kXEqQLhg_JHiZZG0Vzf7ijVHARpta_9yFqyONtVJYj_4fQ@mail.gmail.com> (raw)
In-Reply-To: <20210326022128.71727-1-tianjia.zhang@linux.alibaba.com>

On Fri, 26 Mar 2021 at 03:22, Tianjia Zhang
<tianjia.zhang@linux.alibaba.com> wrote:
>
> In the process of calculating the hash, use the more accurate type
> 'u32' instead of the original 'unsigned int' to avoid ambiguity.
>
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>

I don't see the point of this patch. u32 and unsigned int are always
the same type, regardless of architecture.


> ---
>  crypto/sm3_generic.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/crypto/sm3_generic.c b/crypto/sm3_generic.c
> index 193c4584bd00..562e96f92f64 100644
> --- a/crypto/sm3_generic.c
> +++ b/crypto/sm3_generic.c
> @@ -36,17 +36,17 @@ static inline u32 p1(u32 x)
>         return x ^ rol32(x, 15) ^ rol32(x, 23);
>  }
>
> -static inline u32 ff(unsigned int n, u32 a, u32 b, u32 c)
> +static inline u32 ff(u32 n, u32 a, u32 b, u32 c)
>  {
>         return (n < 16) ? (a ^ b ^ c) : ((a & b) | (a & c) | (b & c));
>  }
>
> -static inline u32 gg(unsigned int n, u32 e, u32 f, u32 g)
> +static inline u32 gg(u32 n, u32 e, u32 f, u32 g)
>  {
>         return (n < 16) ? (e ^ f ^ g) : ((e & f) | ((~e) & g));
>  }
>
> -static inline u32 t(unsigned int n)
> +static inline u32 t(u32 n)
>  {
>         return (n < 16) ? SM3_T1 : SM3_T2;
>  }
> @@ -54,7 +54,7 @@ static inline u32 t(unsigned int n)
>  static void sm3_expand(u32 *t, u32 *w, u32 *wt)
>  {
>         int i;
> -       unsigned int tmp;
> +       u32 tmp;
>
>         /* load the input */
>         for (i = 0; i <= 15; i++)
> @@ -123,8 +123,8 @@ static void sm3_compress(u32 *w, u32 *wt, u32 *m)
>
>  static void sm3_transform(struct sm3_state *sst, u8 const *src)
>  {
> -       unsigned int w[68];
> -       unsigned int wt[64];
> +       u32 w[68];
> +       u32 wt[64];
>
>         sm3_expand((u32 *)src, w, wt);
>         sm3_compress(w, wt, sst->state);
> --
> 2.19.1.3.ge56e4f7
>

  reply	other threads:[~2021-03-26  9:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26  2:21 [PATCH] crypto: sm3 - use the more precise type u32 instead of unsigned int Tianjia Zhang
2021-03-26  8:59 ` Ard Biesheuvel [this message]
2021-03-26  9:38 ` Gilad Ben-Yossef
2021-04-07  3:26   ` Tianjia Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMj1kXEqQLhg_JHiZZG0Vzf7ijVHARpta_9yFqyONtVJYj_4fQ@mail.gmail.com \
    --to=ardb@kernel.org \
    --cc=davem@davemloft.net \
    --cc=ebiggers@google.com \
    --cc=gilad@benyossef.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tianjia.zhang@linux.alibaba.com \
    --cc=zhang.jia@linux.alibaba.com \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).