From: Loup Vaillant Date: Tue, 3 Dec 2019 07:52:01 +0000 (+0100) Subject: Moved SHA 512 work area to local stack X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=9e5f98e946336363bf39107de958664b7ecc8317;p=Monocypher.git Moved SHA 512 work area to local stack 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. --- diff --git a/src/optional/ed25519.c b/src/optional/ed25519.c index 2bb4545..d19eede 100644 --- a/src/optional/ed25519.c +++ b/src/optional/ed25519.c @@ -72,7 +72,7 @@ static const u64 K[80] = { 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]); } diff --git a/src/optional/ed25519.h b/src/optional/ed25519.h index 3f5bff9..32cb5c4 100644 --- a/src/optional/ed25519.h +++ b/src/optional/ed25519.h @@ -12,7 +12,6 @@ // 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];