Re: [PATCH v4 10/12] Add a base implementation of SHA-256 support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 25, 2018 at 4:42 AM brian m. carlson
<sandals@xxxxxxxxxxxxxxxxxxxx> wrote:

> +static void blk_SHA256_Transform(blk_SHA256_CTX *ctx, const unsigned char *buf)
> +{
> +
> +       uint32_t S[8], W[64], t0, t1;
> +       int i;
> +
> +       /* copy state into S */
> +       for (i = 0; i < 8; i++) {
> +               S[i] = ctx->state[i];
> +       }

Maybe remove unnecessary brackets above and below.

> +       /* copy the state into 512-bits into W[0..15] */
> +       for (i = 0; i < 16; i++, buf += sizeof(uint32_t)) {
> +               W[i] = get_be32(buf);
> +       }
> +
> +       /* fill W[16..63] */
> +       for (i = 16; i < 64; i++) {
> +               W[i] = gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16];
> +       }

[...]

> +       RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],62,0xbef9a3f7);
> +       RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],63,0xc67178f2);
> +
> +

Spurious new line.

> +       for (i = 0; i < 8; i++) {
> +               ctx->state[i] = ctx->state[i] + S[i];
> +       }

Maybe remove unnecessary brackets and use "+=", like:

       for (i = 0; i < 8; i++)
               ctx->state[i] += S[i];



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux