aboutsummaryrefslogtreecommitdiff
path: root/crypto/ec/curve448/f_generic.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/ec/curve448/f_generic.c')
-rw-r--r--crypto/ec/curve448/f_generic.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/crypto/ec/curve448/f_generic.c b/crypto/ec/curve448/f_generic.c
index 9a4675a8b3db..ad605b65e8f1 100644
--- a/crypto/ec/curve448/f_generic.c
+++ b/crypto/ec/curve448/f_generic.c
@@ -13,8 +13,8 @@
static const gf MODULUS = {
FIELD_LITERAL(0xffffffffffffffULL, 0xffffffffffffffULL, 0xffffffffffffffULL,
- 0xffffffffffffffULL, 0xfffffffffffffeULL, 0xffffffffffffffULL,
- 0xffffffffffffffULL, 0xffffffffffffffULL)
+ 0xffffffffffffffULL, 0xfffffffffffffeULL, 0xffffffffffffffULL,
+ 0xffffffffffffffULL, 0xffffffffffffffULL)
};
/* Serialize to wire format. */
@@ -32,7 +32,7 @@ void gf_serialize(uint8_t serial[SER_BYTES], const gf x, int with_hibit)
for (i = 0; i < (with_hibit ? X_SER_BYTES : SER_BYTES); i++) {
if (fill < 8 && j < NLIMBS) {
- buffer |= ((dword_t) red->limb[LIMBPERM(j)]) << fill;
+ buffer |= ((dword_t)red->limb[LIMBPERM(j)]) << fill;
fill += LIMB_PLACE_VALUE(LIMBPERM(j));
j++;
}
@@ -64,7 +64,7 @@ mask_t gf_lobit(const gf x)
/* Deserialize from wire format; return -1 on success and 0 on failure. */
mask_t gf_deserialize(gf x, const uint8_t serial[SER_BYTES], int with_hibit,
- uint8_t hi_nmask)
+ uint8_t hi_nmask)
{
unsigned int j = 0, fill = 0;
dword_t buffer = 0;
@@ -80,19 +80,16 @@ mask_t gf_deserialize(gf x, const uint8_t serial[SER_BYTES], int with_hibit,
sj = serial[j];
if (j == nbytes - 1)
sj &= ~hi_nmask;
- buffer |= ((dword_t) sj) << fill;
+ buffer |= ((dword_t)sj) << fill;
fill += 8;
j++;
}
- x->limb[LIMBPERM(i)] = (word_t)
- ((i < NLIMBS - 1) ? buffer & LIMB_MASK(LIMBPERM(i)) : buffer);
+ x->limb[LIMBPERM(i)] = (word_t)((i < NLIMBS - 1) ? buffer & LIMB_MASK(LIMBPERM(i)) : buffer);
fill -= LIMB_PLACE_VALUE(LIMBPERM(i));
buffer >>= LIMB_PLACE_VALUE(LIMBPERM(i));
- scarry =
- (scarry + x->limb[LIMBPERM(i)] -
- MODULUS->limb[LIMBPERM(i)]) >> (8 * sizeof(word_t));
+ scarry = (scarry + x->limb[LIMBPERM(i)] - MODULUS->limb[LIMBPERM(i)]) >> (8 * sizeof(word_t));
}
- succ = with_hibit ? 0 - (mask_t) 1 : ~gf_hibit(x);
+ succ = with_hibit ? 0 - (mask_t)1 : ~gf_hibit(x);
return succ & word_is_zero((word_t)buffer) & ~word_is_zero((word_t)scarry);
}
@@ -105,7 +102,7 @@ void gf_strong_reduce(gf a)
unsigned int i;
/* first, clear high */
- gf_weak_reduce(a); /* Determined to have negligible perf impact. */
+ gf_weak_reduce(a); /* Determined to have negligible perf impact. */
/* now the total is less than 2p */
@@ -128,9 +125,7 @@ void gf_strong_reduce(gf a)
/* add it back */
for (i = 0; i < NLIMBS; i++) {
- carry =
- carry + a->limb[LIMBPERM(i)] +
- (scarry_0 & MODULUS->limb[LIMBPERM(i)]);
+ carry = carry + a->limb[LIMBPERM(i)] + (scarry_0 & MODULUS->limb[LIMBPERM(i)]);
a->limb[LIMBPERM(i)] = carry & LIMB_MASK(LIMBPERM(i));
carry >>= LIMB_PLACE_VALUE(LIMBPERM(i));
}