]> git.codecow.com Git - Monocypher.git/commitdiff
Try not to waste the stack
authorLoup Vaillant <loup@loup-vaillant.fr>
Fri, 14 Dec 2018 20:12:33 +0000 (21:12 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Fri, 14 Dec 2018 20:12:33 +0000 (21:12 +0100)
src/monocypher.c

index 3f156c25577ccb48da53085738421694c9f86b50..962c47c43fb7c52cc769fb0a54c5adc9020cb6d2 100644 (file)
@@ -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