Re: [PATCH] crypto: sm3 - use the more precise type u32 instead of unsigned int

From: Tianjia Zhang
Date: Tue Apr 06 2021 - 23:26:37 EST




On 3/26/21 5:38 PM, Gilad Ben-Yossef wrote:
Hi,

Thank you for the patch!

On Fri, Mar 26, 2021 at 5:21 AM Tianjia Zhang
<tianjia.zhang@xxxxxxxxxxxxxxxxx> wrote:

In the process of calculating the hash, use the more accurate type
'u32' instead of the original 'unsigned int' to avoid ambiguity.

I don't think there is any ambiguity here, as both forms are always
the same size.

Generally, I tend to use the convention of using 'u32' as denoting
variables where the size is meaningful - e.g. mathematical operations
that are defined in the standard on 32 bit buffers, versus using
plain 'int' types where it isn't - e.g. loop counters etc.

Having said that, even under my own definition possibly the w and wt
arrays in sm3_trandform() should be changed to u32.
I don't object to changing those if it bugs you :-)

Cheers,
Gilad



Thanks for your opinions. This is just to make the form more uniform. This is not a mistake. If it is not necessary, just ignore this modification.

Best regards,
Tianjia