This avoids wiping w[] for each block, and reclaims the speed
we lost in the previous commit. It's also simpler.
static void sha512_compress(crypto_sha512_ctx *ctx)
{
- u64 w[80];
+ u64 *w = ctx->w;
FOR(i, 0, 16) { w[i] = ctx->input[i]; }
FOR(i, 16, 80) { w[i] = (lit_sigma1(w[i- 2]) + w[i- 7] +
lit_sigma0(w[i-15]) + w[i-16]); }
ctx->hash[2] += c; ctx->hash[3] += d;
ctx->hash[4] += e; ctx->hash[5] += f;
ctx->hash[6] += g; ctx->hash[7] += h;
-
- volatile u64 *W = w;
- FOR (i, 0, 80) {
- W[i] = 0;
- }
}
static void sha512_set_input(crypto_sha512_ctx *ctx, u8 input)
#include <inttypes.h>
typedef struct {
+ uint64_t w[80]; // work area
uint64_t hash[8];
uint64_t input[16];
uint64_t input_size[2];