Re: [PATCH v4 10/12] Add a base implementation of SHA-256 support
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Oct 27, 2018, 09:03 UTC
- Message-ID
- <CAP8UFD3oYY=brGz1HZ67vxaRrxdwCdwNaJ9n78yJy9bUncW9pQ@mail.gmail.com>
- In-Reply-To
- <20181025024005.154208-11-sandals@crustytoothpaste.net>
On Thu, Oct 25, 2018 at 4:42 AM brian m. carlson <sandals@crustytoothpaste.net> wrote:
Show 10 quoted lines
> +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.
Show 9 quoted lines
> + /* 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];