From 6d18297d6423e7f86757ac13d369ba19c8286591 Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Sun, 28 Jan 2018 21:06:31 -0800 Subject: [PATCH] ECC --> ECDSA --- src/publickey.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/publickey.rs b/src/publickey.rs index 12b80aa..7045ffd 100644 --- a/src/publickey.rs +++ b/src/publickey.rs @@ -4,14 +4,14 @@ use num::bigint::Sign; use simple_asn1::{ASN1Block,ASN1Class,FromASN1,OID,ToASN1, der_decode,der_encode,from_der}; use simple_dsa::dsa::{DSAParameters,DSAPublicKey}; -use simple_dsa::ecdsa::{EllipticCurve,ECCPoint,ECCPublicKey}; +use simple_dsa::ecdsa::{EllipticCurve,ECDSAPoint,ECDSAPublicKey}; use simple_rsa::RSAPublicKey; #[derive(Clone,Debug,PartialEq)] pub enum X509PublicKey { DSA(DSAPublicKey), RSA(RSAPublicKey), - ECDSA(ECCPublicKey) + ECDSA(ECDSAPublicKey) } impl FromASN1 for X509PublicKey { @@ -125,7 +125,7 @@ fn encode_dsa_pubkey(c: ASN1Class, key: &DSAPublicKey) Ok(ASN1Block::Sequence(c, 0, vec![headinfo, objkey])) } -fn encode_ecc_pubkey(c: ASN1Class, key: &ECCPublicKey) +fn encode_ecc_pubkey(c: ASN1Class, key: &ECDSAPublicKey) -> Result { let objoid = ASN1Block::ObjectIdentifier(c, 0, oid!(1,2,840,10045,2,1)); @@ -184,7 +184,7 @@ fn decode_dsa_key(b: &ASN1Block, params: &DSAParameters) } } -fn encode_ecc_key(c: ASN1Class, k: &ECCPublicKey) +fn encode_ecc_key(c: ASN1Class, k: &ECDSAPublicKey) -> Result { let mut bytes = vec![4]; @@ -210,7 +210,7 @@ fn encode_ecc_key(c: ASN1Class, k: &ECCPublicKey) } fn decode_ecc_key(b: &ASN1Block, curve: &EllipticCurve) - -> Result + -> Result { match b { &ASN1Block::BitString(_, _, size, ref vec) if size % 8 == 0 => { @@ -224,8 +224,8 @@ fn decode_ecc_key(b: &ASN1Block, curve: &EllipticCurve) let (xbytes, ybytes) = input.split_at(bytesize); let x = BigInt::from_bytes_be(Sign::Plus, xbytes); let y = BigInt::from_bytes_be(Sign::Plus, ybytes); - let point = ECCPoint::new(curve, x, y)?; - Ok(ECCPublicKey::new(curve, &point)) + let point = ECDSAPoint::new(curve, x, y)?; + Ok(ECDSAPublicKey::new(curve, &point)) } _ => Err(X509ParseError::InvalidPointForm) @@ -296,7 +296,7 @@ fn decode_biguint(b: &ASN1Block) -> Result { #[cfg(test)] mod test { use simple_dsa::dsa::{DSAParameterSize,DSAKeyPair}; - use simple_dsa::ecdsa::{ECCKeyPair}; + use simple_dsa::ecdsa::{ECDSAKeyPair}; use simple_rsa::RSAKeyPair; use super::*; @@ -348,7 +348,7 @@ mod test { ecc_info_test(&EllipticCurve::p384()); ecc_info_test(&EllipticCurve::p521()); for _ in 0..NUM_TESTS { - let pair = ECCKeyPair::generate(&curve256); + let pair = ECDSAKeyPair::generate(&curve256); let public = pair.public; let block = encode_ecc_key(ASN1Class::Universal, &public).unwrap(); let public2 = decode_ecc_key(&block, &curve256).unwrap();