Skip to content

Commit

Permalink
Use closure-to-fn coersion feature in P-384.
Browse files Browse the repository at this point in the history
  • Loading branch information
briansmith committed May 6, 2017
1 parent ab4c97d commit 44170d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/ec/suite_b/ops/p384.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -329,15 +331,6 @@ fn p384_scalar_inv_to_mont(a: &Scalar<Unencoded>) -> Scalar<R> {
}


#[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]*/,
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//!
Expand Down

0 comments on commit 44170d4

Please sign in to comment.