While some users could perhaps benefit from saving 640 bytes of stack
space by allocating the context statically, or in the heap, in practice
it's not he bottleneck. Besides, putting the work area there actually
*increases* stack usage on signatures and signature verification, which
are the most stack hungry parts of Monocypher to begin with.
Better not try to be clever.
static void sha512_compress(crypto_sha512_ctx *ctx)
{
- u64 *w = ctx->w;
+ u64 w[80];
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]); }
// Do not rely on the size or content on any of those types,
// they may change without notice.
typedef struct {
- uint64_t w[80]; // work area
uint64_t hash[8];
uint64_t input[16];
uint64_t input_size[2];