Commit c8206733 authored by Jon Griffiths's avatar Jon Griffiths

sha256: Use fewer magic magic numbers

Show the derivation of the constants to match the comment above them.
The compiler doesn't care, but it helps the code read better.
Signed-off-by: default avatarJon Griffiths <jon_p_griffiths@yahoo.com>
parent fe21b246
......@@ -231,7 +231,7 @@ void sha256_done(struct sha256_ctx *ctx, struct sha256 *res)
sizedesc = cpu_to_be64((uint64_t)ctx->bytes << 3);
/* Add '1' bit to terminate, then all 0 bits, up to next block - 8. */
add(ctx, pad, 1 + ((119 - (ctx->bytes % 64)) % 64));
add(ctx, pad, 1 + ((128 - 8 - (ctx->bytes % 64) - 1) % 64));
/* Add number of bits of data (big endian) */
add(ctx, &sizedesc, 8);
for (i = 0; i < sizeof(ctx->s) / sizeof(ctx->s[0]); i++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment