Browse Source

Create an abstraction around the hash functions

rel #2
pull/5/head
Rodolphe Breard 6 years ago
parent
commit
ea1183c18c
  1. 7
      acme_common/src/crypto.rs
  2. 3
      acme_common/src/crypto/openssl_hash.rs
  3. 3
      acmed/src/acme_proto/jws.rs
  4. 3
      acmed/src/acme_proto/structs/authorization.rs

7
acme_common/src/crypto.rs

@ -1,6 +1,9 @@
mod openssl_certificate;
mod openssl_hash;
mod openssl_keys; mod openssl_keys;
pub use openssl_keys::{gen_keypair, KeyType, PrivateKey, PublicKey};
pub const DEFAULT_ALGO: &str = "rsa2048"; pub const DEFAULT_ALGO: &str = "rsa2048";
mod openssl_certificate;
pub use openssl_certificate::{Csr, X509Certificate}; pub use openssl_certificate::{Csr, X509Certificate};
pub use openssl_hash::sha256;
pub use openssl_keys::{gen_keypair, KeyType, PrivateKey, PublicKey};

3
acme_common/src/crypto/openssl_hash.rs

@ -0,0 +1,3 @@
pub fn sha256(data: &[u8]) -> Vec<u8> {
openssl::sha::sha256(data).to_vec()
}

3
acmed/src/acme_proto/jws.rs

@ -1,8 +1,7 @@
use crate::acme_proto::jws::algorithms::{EdDsaVariant, SignatureAlgorithm}; use crate::acme_proto::jws::algorithms::{EdDsaVariant, SignatureAlgorithm};
use acme_common::b64_encode; use acme_common::b64_encode;
use acme_common::crypto::PrivateKey;
use acme_common::crypto::{sha256, PrivateKey};
use acme_common::error::Error; use acme_common::error::Error;
use openssl::sha::sha256;
use serde::Serialize; use serde::Serialize;
pub mod algorithms; pub mod algorithms;

3
acmed/src/acme_proto/structs/authorization.rs

@ -1,8 +1,7 @@
use crate::acme_proto::structs::{ApiError, HttpApiError, Identifier}; use crate::acme_proto::structs::{ApiError, HttpApiError, Identifier};
use acme_common::b64_encode; use acme_common::b64_encode;
use acme_common::crypto::PrivateKey;
use acme_common::crypto::{sha256, PrivateKey};
use acme_common::error::Error; use acme_common::error::Error;
use openssl::sha::sha256;
use serde::Deserialize; use serde::Deserialize;
use std::fmt; use std::fmt;
use std::str::FromStr; use std::str::FromStr;

Loading…
Cancel
Save