Skip to content

Commit

Permalink
Use the GFp_ prefix for nistz384 externs.
Browse files Browse the repository at this point in the history
  • Loading branch information
briansmith committed Aug 29, 2016
1 parent c378a2e commit fcbf905
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions crypto/ec/ecp_nistz384.h
Expand Up @@ -37,10 +37,10 @@ typedef struct {


/* Prototypes to avoid -Wmissing-prototypes warnings. */
void ecp_nistz384_point_double(P384_POINT *r, const P384_POINT *a);
void ecp_nistz384_point_add(P384_POINT *r, const P384_POINT *a,
void GFp_nistz384_point_double(P384_POINT *r, const P384_POINT *a);
void GFp_nistz384_point_add(P384_POINT *r, const P384_POINT *a,
const P384_POINT *b);
void ecp_nistz384_point_add_affine(P384_POINT *r, const P384_POINT *a,
void GFp_nistz384_point_add_affine(P384_POINT *r, const P384_POINT *a,
const P384_POINT_AFFINE *b);


Expand Down
6 changes: 3 additions & 3 deletions crypto/ec/ecp_nistz384.inl
Expand Up @@ -37,7 +37,7 @@ static BN_ULONG is_infinity(const BN_ULONG x[P384_LIMBS],
}

/* Point double: r = 2*a */
void ecp_nistz384_point_double(P384_POINT *r, const P384_POINT *a) {
void GFp_nistz384_point_double(P384_POINT *r, const P384_POINT *a) {
BN_ULONG S[P384_LIMBS];
BN_ULONG M[P384_LIMBS];
BN_ULONG Zsqr[P384_LIMBS];
Expand Down Expand Up @@ -82,7 +82,7 @@ void ecp_nistz384_point_double(P384_POINT *r, const P384_POINT *a) {
}

/* Point addition: r = a+b */
void ecp_nistz384_point_add(P384_POINT *r, const P384_POINT *a,
void GFp_nistz384_point_add(P384_POINT *r, const P384_POINT *a,
const P384_POINT *b) {
BN_ULONG U2[P384_LIMBS], S2[P384_LIMBS];
BN_ULONG U1[P384_LIMBS], S1[P384_LIMBS];
Expand Down Expand Up @@ -126,7 +126,7 @@ void ecp_nistz384_point_add(P384_POINT *r, const P384_POINT *a,
* so no constant time violation */
if (is_equal(U1, U2) && !in1infty && !in2infty) {
if (is_equal(S1, S2)) {
ecp_nistz384_point_double(r, a);
GFp_nistz384_point_double(r, a);
} else {
memset(r, 0, sizeof(*r));
}
Expand Down
46 changes: 23 additions & 23 deletions crypto/ec/ecp_nistz384_mul.inl
Expand Up @@ -25,7 +25,7 @@


/* Prototypes to avoid -Wmissing-prototypes warnings. */
void ecp_nistz384_point_mul(P384_POINT *r, const BN_ULONG p_scalar[P384_LIMBS],
void GFp_nistz384_point_mul(P384_POINT *r, const BN_ULONG p_scalar[P384_LIMBS],
const BN_ULONG p_x[P384_LIMBS],
const BN_ULONG p_y[P384_LIMBS]);

Expand All @@ -43,11 +43,11 @@ static void add_precomputed_w5(P384_POINT *r, unsigned wvalue,
GFp_p384_elem_neg(tmp, h.Y);
copy_conditional(h.Y, tmp, recoded_is_negative);

ecp_nistz384_point_add(r, r, &h);
GFp_nistz384_point_add(r, r, &h);
}

/* r = p * p_scalar */
void ecp_nistz384_point_mul(P384_POINT *r, const BN_ULONG p_scalar[P384_LIMBS],
void GFp_nistz384_point_mul(P384_POINT *r, const BN_ULONG p_scalar[P384_LIMBS],
const BN_ULONG p_x[P384_LIMBS],
const BN_ULONG p_y[P384_LIMBS]) {
static const unsigned kWindowSize = 5;
Expand All @@ -71,21 +71,21 @@ void ecp_nistz384_point_mul(P384_POINT *r, const BN_ULONG p_scalar[P384_LIMBS],
memcpy(row[1 - 1].Y, p_y, P384_LIMBS * BN_BYTES);
memcpy(row[1 - 1].Z, ONE, P384_LIMBS * BN_BYTES);

ecp_nistz384_point_double(&row[2 - 1], &row[1 - 1]);
ecp_nistz384_point_add(&row[3 - 1], &row[2 - 1], &row[1 - 1]);
ecp_nistz384_point_double(&row[4 - 1], &row[2 - 1]);
ecp_nistz384_point_double(&row[6 - 1], &row[3 - 1]);
ecp_nistz384_point_double(&row[8 - 1], &row[4 - 1]);
ecp_nistz384_point_double(&row[12 - 1], &row[6 - 1]);
ecp_nistz384_point_add(&row[5 - 1], &row[4 - 1], &row[1 - 1]);
ecp_nistz384_point_add(&row[7 - 1], &row[6 - 1], &row[1 - 1]);
ecp_nistz384_point_add(&row[9 - 1], &row[8 - 1], &row[1 - 1]);
ecp_nistz384_point_add(&row[13 - 1], &row[12 - 1], &row[1 - 1]);
ecp_nistz384_point_double(&row[14 - 1], &row[7 - 1]);
ecp_nistz384_point_double(&row[10 - 1], &row[5 - 1]);
ecp_nistz384_point_add(&row[15 - 1], &row[14 - 1], &row[1 - 1]);
ecp_nistz384_point_add(&row[11 - 1], &row[10 - 1], &row[1 - 1]);
ecp_nistz384_point_double(&row[16 - 1], &row[8 - 1]);
GFp_nistz384_point_double(&row[2 - 1], &row[1 - 1]);
GFp_nistz384_point_add(&row[3 - 1], &row[2 - 1], &row[1 - 1]);
GFp_nistz384_point_double(&row[4 - 1], &row[2 - 1]);
GFp_nistz384_point_double(&row[6 - 1], &row[3 - 1]);
GFp_nistz384_point_double(&row[8 - 1], &row[4 - 1]);
GFp_nistz384_point_double(&row[12 - 1], &row[6 - 1]);
GFp_nistz384_point_add(&row[5 - 1], &row[4 - 1], &row[1 - 1]);
GFp_nistz384_point_add(&row[7 - 1], &row[6 - 1], &row[1 - 1]);
GFp_nistz384_point_add(&row[9 - 1], &row[8 - 1], &row[1 - 1]);
GFp_nistz384_point_add(&row[13 - 1], &row[12 - 1], &row[1 - 1]);
GFp_nistz384_point_double(&row[14 - 1], &row[7 - 1]);
GFp_nistz384_point_double(&row[10 - 1], &row[5 - 1]);
GFp_nistz384_point_add(&row[15 - 1], &row[14 - 1], &row[1 - 1]);
GFp_nistz384_point_add(&row[11 - 1], &row[10 - 1], &row[1 - 1]);
GFp_nistz384_point_double(&row[16 - 1], &row[8 - 1]);

static const unsigned START_INDEX = 384 - 4;
unsigned index = START_INDEX;
Expand All @@ -112,11 +112,11 @@ void ecp_nistz384_point_mul(P384_POINT *r, const BN_ULONG p_scalar[P384_LIMBS],

index -= kWindowSize;

ecp_nistz384_point_double(r, r);
ecp_nistz384_point_double(r, r);
ecp_nistz384_point_double(r, r);
ecp_nistz384_point_double(r, r);
ecp_nistz384_point_double(r, r);
GFp_nistz384_point_double(r, r);
GFp_nistz384_point_double(r, r);
GFp_nistz384_point_double(r, r);
GFp_nistz384_point_double(r, r);
GFp_nistz384_point_double(r, r);
}

/* Final window */
Expand Down
8 changes: 4 additions & 4 deletions src/ec/suite_b/ops/p384.rs
Expand Up @@ -58,15 +58,15 @@ pub static COMMON_OPS: CommonOps = CommonOps {
elem_mul_mont: GFp_p384_elem_mul_mont,
elem_sqr_mont: GFp_p384_elem_sqr_mont,

point_add_jacobian_impl: ecp_nistz384_point_add,
point_add_jacobian_impl: GFp_nistz384_point_add,
};


pub static PRIVATE_KEY_OPS: PrivateKeyOps = PrivateKeyOps {
common: &COMMON_OPS,
elem_inv: p384_elem_inv,
point_mul_base_impl: p384_point_mul_base_impl,
point_mul_impl: ecp_nistz384_point_mul,
point_mul_impl: GFp_nistz384_point_mul,
};

fn p384_elem_inv(a: &ElemUnreduced) -> ElemUnreduced {
Expand Down Expand Up @@ -339,10 +339,10 @@ extern {
a: *const Limb/*[COMMON_OPS.num_limbs]*/,
b: *const Limb/*[COMMON_OPS.num_limbs]*/);

fn ecp_nistz384_point_add(r: *mut Limb/*[3][COMMON_OPS.num_limbs]*/,
fn GFp_nistz384_point_add(r: *mut Limb/*[3][COMMON_OPS.num_limbs]*/,
a: *const Limb/*[3][COMMON_OPS.num_limbs]*/,
b: *const Limb/*[3][COMMON_OPS.num_limbs]*/);
fn ecp_nistz384_point_mul(r: *mut Limb/*[3][COMMON_OPS.num_limbs]*/,
fn GFp_nistz384_point_mul(r: *mut Limb/*[3][COMMON_OPS.num_limbs]*/,
p_scalar: *const Limb/*[COMMON_OPS.num_limbs]*/,
p_x: *const Limb/*[COMMON_OPS.num_limbs]*/,
p_y: *const Limb/*[COMMON_OPS.num_limbs]*/);
Expand Down

0 comments on commit fcbf905

Please sign in to comment.