Rearrange terms in gf_mul to prevent segfault
authorAngel Baez <51308340+abaez004@users.noreply.github.com>
Wed, 7 Feb 2024 15:34:48 +0000 (10:34 -0500)
committerTomas Mraz <tomas@openssl.org>
Fri, 9 Feb 2024 09:34:48 +0000 (10:34 +0100)
CLA: trivial

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23512)

(cherry picked from commit 76cecff5e9bedb2bafc60062283f99722697082a)

crypto/ec/curve448/arch_64/f_impl64.c

index 10a9b065e554a8d28360c6c8d96ca7443e73f1db..9e2f0c66d504a349da5513d71f1530cc937c3afe 100644 (file)
@@ -45,9 +45,9 @@ void gf_mul(gf_s * RESTRICT cs, const gf as, const gf bs)
             accum0 += widemul(a[j + 4], b[i - j + 4]);
         }
         for (; j < 4; j++) {
-            accum2 += widemul(a[j], b[i - j + 8]);
-            accum1 += widemul(aa[j], bbb[i - j + 4]);
-            accum0 += widemul(a[j + 4], bb[i - j + 4]);
+            accum2 += widemul(a[j], b[i + 8 - j]);
+            accum1 += widemul(aa[j], bbb[i + 4 - j]);
+            accum0 += widemul(a[j + 4], bb[i + 4 - j]);
         }
 
         accum1 -= accum2;