X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fec%2Fcurve448%2Farch_32%2Ff_impl.c;h=d1825cc60f1f27839cd824efc4daad4084d3db29;hp=76ec9711f0811fda12f46a4f94b0c5207548c653;hb=52a9587c78a135ff200b8c92f8aad7ea1bd4de75;hpb=205fd6388175704bd7597dbfb571c84f868ce6da diff --git a/crypto/ec/curve448/arch_32/f_impl.c b/crypto/ec/curve448/arch_32/f_impl.c index 76ec9711f0..d1825cc60f 100644 --- a/crypto/ec/curve448/arch_32/f_impl.c +++ b/crypto/ec/curve448/arch_32/f_impl.c @@ -10,27 +10,25 @@ * Originally written by Mike Hamburg */ -#include "f_field.h" +#include "field.h" #if (defined(__OPTIMIZE__) && !defined(__OPTIMIZE_SIZE__) && !I_HATE_UNROLLED_LOOPS) \ - || defined(DECAF_FORCE_UNROLL) + || defined(C448_FORCE_UNROLL) # define REPEAT8(_x) _x _x _x _x _x _x _x _x # define FOR_LIMB(_i,_start,_end,_x) do { _i=_start; REPEAT8( if (_i<_end) { _x; } _i++;) } while (0) #else # define FOR_LIMB(_i,_start,_end,_x) do { for (_i=_start; _i<_end; _i++) _x; } while (0) #endif -void gf_mul(gf_s * __restrict__ cs, const gf as, const gf bs) +void gf_mul(gf_s * RESTRICT cs, const gf as, const gf bs) { const uint32_t *a = as->limb, *b = bs->limb; uint32_t *c = cs->limb; - uint64_t accum0 = 0, accum1 = 0, accum2 = 0; uint32_t mask = (1 << 28) - 1; - uint32_t aa[8], bb[8]; - int i, j; + for (i = 0; i < 8; i++) { aa[i] = a[i] + a[i + 8]; bb[i] = b[i] + b[i + 8]; @@ -73,7 +71,7 @@ void gf_mul(gf_s * __restrict__ cs, const gf as, const gf bs) c[1] += ((uint32_t)(accum1)); } -void gf_mulw_unsigned(gf_s * __restrict__ cs, const gf as, uint32_t b) +void gf_mulw_unsigned(gf_s * RESTRICT cs, const gf as, uint32_t b) { const uint32_t *a = as->limb; uint32_t *c = cs->limb; @@ -90,15 +88,15 @@ void gf_mulw_unsigned(gf_s * __restrict__ cs, const gf as, uint32_t b) }); accum0 += accum8 + c[8]; - c[8] = accum0 & mask; - c[9] += accum0 >> 28; + c[8] = ((uint32_t)accum0) & mask; + c[9] += (uint32_t)(accum0 >> 28); accum8 += c[0]; - c[0] = accum8 & mask; - c[1] += accum8 >> 28; + c[0] = ((uint32_t)accum8) & mask; + c[1] += (uint32_t)(accum8 >> 28); } -void gf_sqr(gf_s * __restrict__ cs, const gf as) +void gf_sqr(gf_s * RESTRICT cs, const gf as) { gf_mul(cs, as, as); /* Performs better with a dedicated square */ }