Make sure RSA and ECDSA have KeyPair instances.

This commit is contained in:
2019-04-13 21:15:29 -07:00
parent cfc06c3b56
commit 8a7e604fbd
3 changed files with 18 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ use self::point::{ECCPoint,Point};
pub use self::private::ECCPrivateKey;
pub use self::public::{ECDSAPublic,ECCPublicKey};
pub use self::public::{ECDSADecodeErr,ECDSAEncodeErr};
use super::KeyPair;
pub struct ECDSAKeyPair<Curve: EllipticCurve> {
pub public: ECCPublicKey<Curve>,
@@ -21,6 +22,15 @@ pub struct ECDSAKeyPair<Curve: EllipticCurve> {
macro_rules! generate_impl {
($curve: ident, $un: ident, $si: ident) => {
impl KeyPair for ECDSAKeyPair<$curve> {
type Public = ECCPublicKey<$curve>;
type Private = ECCPrivateKey<$curve>;
fn new(public: ECCPublicKey<$curve>, private: ECCPrivateKey<$curve>) -> ECDSAKeyPair<$curve>
{
ECDSAKeyPair{ public, private }
}
}
impl ECDSAKeyPair<$curve> {
pub fn generate<G: Rng>(rng: &mut G) -> ECDSAKeyPair<$curve>
{