From: Loup Vaillant Date: Fri, 14 Dec 2018 20:12:33 +0000 (+0100) Subject: Try not to waste the stack X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=e9e53806708bfad57f0c61c7c3e2e22d31f09951;p=Monocypher.git Try not to waste the stack --- diff --git a/src/monocypher.c b/src/monocypher.c index 3f156c2..962c47c 100644 --- a/src/monocypher.c +++ b/src/monocypher.c @@ -1685,12 +1685,15 @@ static void ge_double_scalarmult_vartime(ge *sum, const ge *P, { // cache P window for addition ge_cached cP[P_WINDOW_SIZE]; - ge P2, tmp; - ge_double(&P2, P, &tmp); - ge_cache(&cP[0], P); - FOR (i, 0, (P_WINDOW_SIZE)-1) { - ge_add(&tmp, &P2, &cP[i]); - ge_cache(&cP[i+1], &tmp); + ge tmp; + { + ge P2; + ge_double(&P2, P, &tmp); + ge_cache(&cP[0], P); + FOR (i, 0, (P_WINDOW_SIZE)-1) { + ge_add(&tmp, &P2, &cP[i]); + ge_cache(&cP[i+1], &tmp); + } } // Compute the indices for the windows