Skip to content

Commit

Permalink
Rename mont_data to order_mont.
Browse files Browse the repository at this point in the history
It's confusing to have both mont and mont_data on EC_GROUP. The
documentation was also wrong.

Change-Id: I4e2e3169ed79307018212fba51d015bbbe5c4227
Reviewed-on: https://boringssl-review.googlesource.com/10348
Reviewed-by: Adam Langley <[email protected]>
Commit-Queue: David Benjamin <[email protected]>
CQ-Verified: CQ bot account: [email protected] <[email protected]>
  • Loading branch information
davidben authored and CQ bot account: [email protected] committed Aug 18, 2017
1 parent 65b87ce commit 331d2ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions crypto/fipsmodule/ec/ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ static EC_GROUP *ec_group_new_from_data(unsigned built_in_index) {

const BN_MONT_CTX **monts = *built_in_curve_scalar_field_monts();
if (monts != NULL) {
group->mont_data = monts[built_in_index];
group->order_mont = monts[built_in_index];
}

group->generator = P;
Expand Down Expand Up @@ -514,8 +514,8 @@ void EC_GROUP_free(EC_GROUP *group) {
OPENSSL_free(group);
}

const BN_MONT_CTX *ec_group_get_mont_data(const EC_GROUP *group) {
return group->mont_data;
const BN_MONT_CTX *ec_group_get_order_mont(const EC_GROUP *group) {
return group->order_mont;
}

EC_GROUP *EC_GROUP_dup(const EC_GROUP *a) {
Expand All @@ -533,7 +533,7 @@ EC_GROUP *EC_GROUP_dup(const EC_GROUP *a) {
return NULL;
}

ret->mont_data = a->mont_data;
ret->order_mont = a->order_mont;
ret->curve_name = a->curve_name;

if (a->generator != NULL) {
Expand Down
10 changes: 5 additions & 5 deletions crypto/fipsmodule/ec/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct ec_group_st {

int curve_name; /* optional NID for named curve */

const BN_MONT_CTX *mont_data; /* data for ECDSA inverse */
const BN_MONT_CTX *order_mont; /* data for ECDSA inverse */

/* The following members are handled by the method functions,
* even if they appear generic */
Expand Down Expand Up @@ -147,10 +147,10 @@ struct ec_point_st {
EC_GROUP *ec_group_new(const EC_METHOD *meth);
int ec_group_copy(EC_GROUP *dest, const EC_GROUP *src);

/* ec_group_get_mont_data returns a Montgomery context for operations in the
* scalar field of |group|. It may return NULL in the case that |group| is not
* a built-in group. */
const BN_MONT_CTX *ec_group_get_mont_data(const EC_GROUP *group);
/* ec_group_get_order_mont returns a Montgomery context for operations modulo
* |group|'s order. It may return NULL in the case that |group| is not a
* built-in group. */
const BN_MONT_CTX *ec_group_get_order_mont(const EC_GROUP *group);

int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar,
const EC_POINT *p, const BIGNUM *p_scalar, BN_CTX *ctx);
Expand Down
4 changes: 2 additions & 2 deletions crypto/fipsmodule/ecdsa/ecdsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ static int ecdsa_sign_setup(const EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
}

/* Compute the inverse of k. The order is a prime, so use Fermat's Little
* Theorem. Note |ec_group_get_mont_data| may return NULL but
* Theorem. Note |ec_group_get_order_mont| may return NULL but
* |bn_mod_inverse_prime| allows this. */
if (!bn_mod_inverse_prime(kinv, k, order, ctx,
ec_group_get_mont_data(group))) {
ec_group_get_order_mont(group))) {
OPENSSL_PUT_ERROR(ECDSA, ERR_R_BN_LIB);
goto err;
}
Expand Down

0 comments on commit 331d2ce

Please sign in to comment.