Use the NLIMBS macro rather than try and calculate the number of limbs
[openssl.git] / crypto / ec / curve448 / arch_32 / f_impl.h
index 25bfa1f79ef2a37d52f787f1c819f0e66129a4c8..78971e8576df48298357ad2c634068df77d77d56 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright 2014-2016 Cryptography Research, Inc.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
@@ -20,7 +20,7 @@ void gf_add_RAW(gf out, const gf a, const gf b)
 {
     unsigned int i;
 
-    for (i = 0; i < sizeof(*out) / sizeof(out->limb[0]); i++) {
+    for (i = 0; i < NLIMBS; i++) {
         out->limb[i] = a->limb[i] + b->limb[i];
     }
 }
@@ -39,9 +39,8 @@ void gf_bias(gf a, int amt)
     unsigned int i;
     uint32_t co1 = ((1 << 28) - 1) * amt, co2 = co1 - amt;
 
-    for (i = 0; i < sizeof(*a) / sizeof(a->limb[0]); i++) {
+    for (i = 0; i < sizeof(*a) / sizeof(a->limb[0]); i++)
         a->limb[i] += (i == sizeof(*a) / sizeof(a->limb[0]) / 2) ? co2 : co1;
-    }
 }
 
 void gf_weak_reduce(gf a)
@@ -51,8 +50,7 @@ void gf_weak_reduce(gf a)
     unsigned int i;
 
     a->limb[8] += tmp;
-    for (i = 15; i > 0; i--) {
+    for (i = 15; i > 0; i--)
         a->limb[i] = (a->limb[i] & mask) + (a->limb[i - 1] >> 28);
-    }
     a->limb[0] = (a->limb[0] & mask) + tmp;
 }