ECDSA SSH key support.
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
use cryptonum::signed::{I192,I256,I384,I576};
|
||||
use cryptonum::unsigned::{Decoder};
|
||||
use cryptonum::unsigned::{U192,U256,U384,U576};
|
||||
use std::fmt::Debug;
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub trait EllipticCurve {
|
||||
type Unsigned : Clone;
|
||||
type Signed : Clone;
|
||||
type Signed : Clone + Debug + PartialEq;
|
||||
|
||||
fn size() -> usize;
|
||||
fn p() -> Self::Unsigned;
|
||||
@@ -18,6 +19,7 @@ pub trait EllipticCurve {
|
||||
fn Gy() -> Self::Signed;
|
||||
}
|
||||
|
||||
#[derive(Debug,PartialEq)]
|
||||
pub enum P192 {}
|
||||
|
||||
impl EllipticCurve for P192 {
|
||||
@@ -61,6 +63,7 @@ impl EllipticCurve for P192 {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug,PartialEq)]
|
||||
pub enum P224 {}
|
||||
|
||||
impl EllipticCurve for P224 {
|
||||
@@ -143,6 +146,7 @@ impl EllipticCurve for P224 {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug,PartialEq)]
|
||||
pub enum P256 {}
|
||||
|
||||
impl EllipticCurve for P256 {
|
||||
@@ -226,6 +230,7 @@ impl EllipticCurve for P256 {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug,PartialEq)]
|
||||
pub enum P384 {}
|
||||
|
||||
impl EllipticCurve for P384 {
|
||||
@@ -322,6 +327,7 @@ impl EllipticCurve for P384 {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug,PartialEq)]
|
||||
pub enum P521 {}
|
||||
|
||||
impl EllipticCurve for P521 {
|
||||
|
||||
@@ -20,6 +20,7 @@ pub trait ECCPoint : Sized {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug,PartialEq)]
|
||||
pub struct Point<T: EllipticCurve>
|
||||
{
|
||||
pub x: T::Signed,
|
||||
|
||||
@@ -5,9 +5,18 @@ use dsa::rfc6979::{DSASignature,KIterator,bits2int};
|
||||
use ecdsa::curve::{EllipticCurve,P192,P224,P256,P384,P521};
|
||||
use ecdsa::point::{ECCPoint,Point};
|
||||
use hmac::{Hmac,Mac};
|
||||
use std::fmt;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub struct ECCPrivateKey<Curve: EllipticCurve> {
|
||||
d: Curve::Unsigned
|
||||
pub(crate) d: Curve::Unsigned
|
||||
}
|
||||
|
||||
impl<Curve: EllipticCurve> fmt::Debug for ECCPrivateKey<Curve> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(),fmt::Error>
|
||||
{
|
||||
f.write_str("<ECCPrivateKey>")
|
||||
}
|
||||
}
|
||||
|
||||
pub enum ECDSAPrivate {
|
||||
|
||||
@@ -8,8 +8,9 @@ use hmac::{Hmac,Mac};
|
||||
use simple_asn1::{ASN1Block,ASN1Class,ASN1DecodeErr,ASN1EncodeErr,FromASN1,ToASN1};
|
||||
use std::cmp::min;
|
||||
|
||||
#[derive(Debug,PartialEq)]
|
||||
pub struct ECCPublicKey<Curve: EllipticCurve> {
|
||||
q: Point<Curve>
|
||||
pub(crate) q: Point<Curve>
|
||||
}
|
||||
|
||||
pub enum ECDSAPublic {
|
||||
|
||||
Reference in New Issue
Block a user