From 44170d4936b477d2de6135e1ab668a881d8d6943 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Fri, 5 May 2017 14:05:21 -1000 Subject: [PATCH] Use closure-to-fn coersion feature in P-384. --- src/ec/suite_b/ops/p384.rs | 13 +++---------- src/lib.rs | 2 ++ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/ec/suite_b/ops/p384.rs b/src/ec/suite_b/ops/p384.rs index 11ad494ca7..72aca51723 100644 --- a/src/ec/suite_b/ops/p384.rs +++ b/src/ec/suite_b/ops/p384.rs @@ -64,7 +64,9 @@ pub static COMMON_OPS: CommonOps = CommonOps { elem_add_impl: GFp_p384_elem_add, elem_mul_mont: GFp_p384_elem_mul_mont, - elem_sqr_mont: GFp_p384_elem_sqr_mont, + + // XXX: Inefficient. TODO: Make a dedicated squaring routine. + elem_sqr_mont: |r, a| GFp_p384_elem_mul_mont(r, a, a), point_add_jacobian_impl: GFp_nistz384_point_add, }; @@ -329,15 +331,6 @@ fn p384_scalar_inv_to_mont(a: &Scalar) -> Scalar { } -#[allow(non_snake_case)] -unsafe extern fn GFp_p384_elem_sqr_mont( - r: *mut Limb/*[COMMON_OPS.num_limbs]*/, - a: *const Limb/*[COMMON_OPS.num_limbs]*/) { - // XXX: Inefficient. TODO: Make a dedicated squaring routine. - GFp_p384_elem_mul_mont(r, a, a); -} - - extern { fn GFp_p384_elem_add(r: *mut Limb/*[COMMON_OPS.num_limbs]*/, a: *const Limb/*[COMMON_OPS.num_limbs]*/, diff --git a/src/lib.rs b/src/lib.rs index 985e64eb2e..b33dd1cc8a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,8 @@ // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +#![feature(closure_to_fn_coercion)] + //! Safe, fast, small crypto using Rust with BoringSSL's cryptography //! primitives. //!