diff --git a/acme_common/src/crypto.rs b/acme_common/src/crypto.rs index 2943f29..441cf6e 100644 --- a/acme_common/src/crypto.rs +++ b/acme_common/src/crypto.rs @@ -1,6 +1,9 @@ +mod openssl_certificate; +mod openssl_hash; mod openssl_keys; -pub use openssl_keys::{gen_keypair, KeyType, PrivateKey, PublicKey}; + pub const DEFAULT_ALGO: &str = "rsa2048"; -mod openssl_certificate; pub use openssl_certificate::{Csr, X509Certificate}; +pub use openssl_hash::sha256; +pub use openssl_keys::{gen_keypair, KeyType, PrivateKey, PublicKey}; diff --git a/acme_common/src/crypto/openssl_hash.rs b/acme_common/src/crypto/openssl_hash.rs new file mode 100644 index 0000000..330c9b1 --- /dev/null +++ b/acme_common/src/crypto/openssl_hash.rs @@ -0,0 +1,3 @@ +pub fn sha256(data: &[u8]) -> Vec { + openssl::sha::sha256(data).to_vec() +} diff --git a/acmed/src/acme_proto/jws.rs b/acmed/src/acme_proto/jws.rs index b601262..0b3ef3d 100644 --- a/acmed/src/acme_proto/jws.rs +++ b/acmed/src/acme_proto/jws.rs @@ -1,8 +1,7 @@ use crate::acme_proto::jws::algorithms::{EdDsaVariant, SignatureAlgorithm}; use acme_common::b64_encode; -use acme_common::crypto::PrivateKey; +use acme_common::crypto::{sha256, PrivateKey}; use acme_common::error::Error; -use openssl::sha::sha256; use serde::Serialize; pub mod algorithms; diff --git a/acmed/src/acme_proto/structs/authorization.rs b/acmed/src/acme_proto/structs/authorization.rs index b84c88a..5ef1a94 100644 --- a/acmed/src/acme_proto/structs/authorization.rs +++ b/acmed/src/acme_proto/structs/authorization.rs @@ -1,8 +1,7 @@ use crate::acme_proto::structs::{ApiError, HttpApiError, Identifier}; use acme_common::b64_encode; -use acme_common::crypto::PrivateKey; +use acme_common::crypto::{sha256, PrivateKey}; use acme_common::error::Error; -use openssl::sha::sha256; use serde::Deserialize; use std::fmt; use std::str::FromStr;