aboutsummaryrefslogtreecommitdiff
path: root/third_party
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@google.com>2020-04-06 14:34:09 -0400
committerAdam Langley <agl@google.com>2020-04-07 20:28:59 +0000
commitbd1fa86feb7de41910ed111d003fd1b49235168a (patch)
tree10e53ac1aeb68c44ce34468f510f920bb28d4e2c /third_party
parent243a29241ca582a6e47bb5caa193be12cf8890f9 (diff)
downloadboringssl-bd1fa86feb7de41910ed111d003fd1b49235168a.zip
boringssl-bd1fa86feb7de41910ed111d003fd1b49235168a.tar.gz
boringssl-bd1fa86feb7de41910ed111d003fd1b49235168a.tar.bz2
Clean up various EC inversion functions.
This fixes two issues. First, we have been lax about whether the low-level inversion functions fail on zero input or output zero. Fix the documentation and call the latter inv0 or inverse0 to match the terminology used in draft-irtf-cfrg-hash-to-curve. (Although we may not actually need inv0 given the optimization in D.2.) This has no actual effect because the functions were only used in contexts where the inputs were already guaranteed to be non-zero. Still, we should be consistent here. Second, ec_scalar_inv_montgomery and ec_scalar_inv_montgomery_vartime claim to perform the same operation, but they do not. First, one computed inv0 and the other computed inv (except only in some implementations, so fix it to be consistent). Second, the former computes inverses in the Montgomery domain, while the latter converts to the Montgomery domain and then inverts. Rename it to ec_scalar_to_montgomery_inv_vartime, which is... questionably understandable but at least looks different. Change-Id: I9b4829ce5013bdb9528078a093f41b1b158df265 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40526 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'third_party')
-rw-r--r--third_party/fiat/p256.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/third_party/fiat/p256.c b/third_party/fiat/p256.c
index 23ec71f..dd113c4 100644
--- a/third_party/fiat/p256.c
+++ b/third_party/fiat/p256.c
@@ -1055,8 +1055,9 @@ DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_nistp256_method) {
out->felem_sqr = ec_GFp_mont_felem_sqr;
out->bignum_to_felem = ec_GFp_mont_bignum_to_felem;
out->felem_to_bignum = ec_GFp_mont_felem_to_bignum;
- out->scalar_inv_montgomery = ec_simple_scalar_inv_montgomery;
- out->scalar_inv_montgomery_vartime = ec_GFp_simple_mont_inv_mod_ord_vartime;
+ out->scalar_inv0_montgomery = ec_simple_scalar_inv0_montgomery;
+ out->scalar_to_montgomery_inv_vartime =
+ ec_simple_scalar_to_montgomery_inv_vartime;
out->cmp_x_coordinate = ec_GFp_nistp256_cmp_x_coordinate;
}