Browse Source

Remove unused Curve25519

pull/5/head
Rodolphe Breard 5 years ago
parent
commit
37d9fd5e57
  1. 2
      acmed/src/acme_proto/jws.rs
  2. 28
      acmed/src/acme_proto/jws/algorithms.rs
  3. 12
      acmed/src/acme_proto/jws/jwk.rs

2
acmed/src/acme_proto/jws.rs

@ -1,4 +1,4 @@
use crate::acme_proto::jws::algorithms::{EdDsaVariant, SignatureAlgorithm};
use crate::acme_proto::jws::algorithms::SignatureAlgorithm;
use acme_common::b64_encode;
use acme_common::crypto::{sha256, KeyPair};
use acme_common::error::Error;

28
acmed/src/acme_proto/jws/algorithms.rs

@ -1,34 +1,18 @@
use super::jwk::{EdDsaEd25519Jwk, Es256Jwk, Jwk};
use super::jwk::{Es256Jwk, Jwk};
use acme_common::crypto::{gen_keypair, KeyPair, KeyType};
use acme_common::error::Error;
use std::fmt;
use std::str::FromStr;
#[derive(Debug, PartialEq, Eq)]
pub enum EdDsaVariant {
Ed25519,
}
impl fmt::Display for EdDsaVariant {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let s = match self {
EdDsaVariant::Ed25519 => "Ed25519",
};
write!(f, "{}", s)
}
}
#[derive(Debug, PartialEq, Eq)]
pub enum SignatureAlgorithm {
Es256,
EdDsa(EdDsaVariant),
}
impl fmt::Display for SignatureAlgorithm {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let s = match self {
SignatureAlgorithm::Es256 => "ES256",
SignatureAlgorithm::EdDsa(_) => "EdDSA",
};
write!(f, "{}", s)
}
@ -40,7 +24,6 @@ impl FromStr for SignatureAlgorithm {
fn from_str(data: &str) -> Result<Self, Self::Err> {
match data.to_lowercase().as_str() {
"es256" => Ok(SignatureAlgorithm::Es256),
"eddsa-ed25519" => Ok(SignatureAlgorithm::EdDsa(EdDsaVariant::Ed25519)),
_ => Err(format!("{}: unknown signature algorithm", data).into()),
}
}
@ -63,14 +46,13 @@ impl SignatureAlgorithm {
pub fn gen_key_pair(&self) -> Result<KeyPair, Error> {
match self {
SignatureAlgorithm::Es256 => gen_keypair(KeyType::EcdsaP256),
SignatureAlgorithm::EdDsa(EdDsaVariant::Ed25519) => Err("Not implemented".into()),
}
}
}
#[cfg(test)]
mod tests {
use super::{EdDsaVariant, SignatureAlgorithm};
use super::SignatureAlgorithm;
use acme_common::crypto::KeyPair;
use std::str::FromStr;
@ -102,12 +84,6 @@ mod tests {
}
}
#[test]
fn test_eddsa_ed25519_to_str() {
let a = SignatureAlgorithm::EdDsa(EdDsaVariant::Ed25519);
assert_eq!(a.to_string().as_str(), "EdDSA");
}
#[test]
fn test_from_p256() {
let pem = b"-----BEGIN PRIVATE KEY-----

12
acmed/src/acme_proto/jws/jwk.rs

@ -4,7 +4,6 @@ use serde::Serialize;
#[serde(untagged)]
pub enum Jwk {
Es256(Es256Jwk),
EdDsaEd25519(EdDsaEd25519Jwk),
}
#[derive(Serialize)]
@ -30,14 +29,3 @@ impl Es256Jwk {
}
}
}
#[derive(Serialize)]
pub struct EdDsaEd25519Jwk {
// TODO: implement EdDsaEd25519Jwk
}
impl EdDsaEd25519Jwk {
pub fn new() -> Self {
EdDsaEd25519Jwk {}
}
}
Loading…
Cancel
Save