Loading openssl/src/ec.rs +62 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ use libc::c_int; use std::fmt; use std::ptr; use crate::bn::{BigNumContextRef, BigNumRef}; use crate::bn::{BigNum, BigNumContextRef, BigNumRef}; use crate::error::ErrorStack; use crate::nid::Nid; use crate::pkey::{HasParams, HasPrivate, HasPublic, Params, Private, Public}; Loading Loading @@ -123,6 +123,26 @@ impl EcGroup { cvt_p(ffi::EC_GROUP_new_by_curve_name(nid.as_raw())).map(EcGroup) } } /// Returns the group for given parameters #[corresponds(EC_GROUP_new_curve_GFp)] pub fn from_components( p: BigNum, a: BigNum, b: BigNum, ctx: &mut BigNumContextRef, ) -> Result<EcGroup, ErrorStack> { unsafe { init(); cvt_p(ffi::EC_GROUP_new_curve_GFp( p.as_ptr(), a.as_ptr(), b.as_ptr(), ctx.as_ptr(), )) .map(EcGroup) } } } impl EcGroupRef { Loading Loading @@ -214,6 +234,25 @@ impl EcGroupRef { } } /// Sets the generator point for the given curve #[corresponds(EC_GROUP_set_generator)] pub fn set_generator( &self, generator: EcPoint, order: BigNum, cofactor: BigNum, ) -> Result<(), ErrorStack> { unsafe { cvt(ffi::EC_GROUP_set_generator( self.as_ptr(), generator.as_ptr(), order.as_ptr(), cofactor.as_ptr(), )) .map(|_| ()) } } /// Places the order of the curve in the provided `BigNum`. #[corresponds(EC_GROUP_get_order)] pub fn order( Loading Loading @@ -476,6 +515,28 @@ impl EcPointRef { } } /// Sets affine coordinates of a curve over a prime field using the provided /// `x` and `y` `BigNum`s #[corresponds(EC_POINT_set_affine_coordinates_GFp)] pub fn set_affine_coordinates_gfp( &self, group: &EcGroupRef, x: &BigNumRef, y: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack> { unsafe { cvt(ffi::EC_POINT_set_affine_coordinates_GFp( group.as_ptr(), self.as_ptr(), x.as_ptr(), y.as_ptr(), ctx.as_ptr(), )) .map(|_| ()) } } /// Places affine coordinates of a curve over a binary field in the provided /// `x` and `y` `BigNum`s #[corresponds(EC_POINT_get_affine_coordinates_GF2m)] Loading Loading
openssl/src/ec.rs +62 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ use libc::c_int; use std::fmt; use std::ptr; use crate::bn::{BigNumContextRef, BigNumRef}; use crate::bn::{BigNum, BigNumContextRef, BigNumRef}; use crate::error::ErrorStack; use crate::nid::Nid; use crate::pkey::{HasParams, HasPrivate, HasPublic, Params, Private, Public}; Loading Loading @@ -123,6 +123,26 @@ impl EcGroup { cvt_p(ffi::EC_GROUP_new_by_curve_name(nid.as_raw())).map(EcGroup) } } /// Returns the group for given parameters #[corresponds(EC_GROUP_new_curve_GFp)] pub fn from_components( p: BigNum, a: BigNum, b: BigNum, ctx: &mut BigNumContextRef, ) -> Result<EcGroup, ErrorStack> { unsafe { init(); cvt_p(ffi::EC_GROUP_new_curve_GFp( p.as_ptr(), a.as_ptr(), b.as_ptr(), ctx.as_ptr(), )) .map(EcGroup) } } } impl EcGroupRef { Loading Loading @@ -214,6 +234,25 @@ impl EcGroupRef { } } /// Sets the generator point for the given curve #[corresponds(EC_GROUP_set_generator)] pub fn set_generator( &self, generator: EcPoint, order: BigNum, cofactor: BigNum, ) -> Result<(), ErrorStack> { unsafe { cvt(ffi::EC_GROUP_set_generator( self.as_ptr(), generator.as_ptr(), order.as_ptr(), cofactor.as_ptr(), )) .map(|_| ()) } } /// Places the order of the curve in the provided `BigNum`. #[corresponds(EC_GROUP_get_order)] pub fn order( Loading Loading @@ -476,6 +515,28 @@ impl EcPointRef { } } /// Sets affine coordinates of a curve over a prime field using the provided /// `x` and `y` `BigNum`s #[corresponds(EC_POINT_set_affine_coordinates_GFp)] pub fn set_affine_coordinates_gfp( &self, group: &EcGroupRef, x: &BigNumRef, y: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack> { unsafe { cvt(ffi::EC_POINT_set_affine_coordinates_GFp( group.as_ptr(), self.as_ptr(), x.as_ptr(), y.as_ptr(), ctx.as_ptr(), )) .map(|_| ()) } } /// Places affine coordinates of a curve over a binary field in the provided /// `x` and `y` `BigNum`s #[corresponds(EC_POINT_get_affine_coordinates_GF2m)] Loading