diff --git a/Cargo.lock b/Cargo.lock index 5557e0138..d9be74e84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1069,13 +1069,13 @@ dependencies = [ "rand_core 0.6.4", "regex", "reqwest 0.13.2", - "ring", "ruma", "sanitize-filename", "serde", "serde-saphyr", "serde_json", "serde_regex", + "sha2 0.11.0", "smallstr", "smallvec", "thiserror 2.0.18", diff --git a/Cargo.toml b/Cargo.toml index 813332ff0..95a8fb6b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -562,7 +562,7 @@ version = "0.15.0" [workspace.dependencies.lettre] version = "0.11.19" default-features = false -features = ["smtp-transport", "pool", "hostname", "builder", "rustls", "rustls-native-certs", "tokio1", "ring", "tokio1-rustls", "tracing", "serde"] +features = ["smtp-transport", "pool", "hostname", "builder", "rustls", "rustls-native-certs", "tokio1", "rustls-no-provider", "tokio1-rustls", "tracing", "serde"] [workspace.dependencies.governor] version = "0.10.4" diff --git a/src/core/Cargo.toml b/src/core/Cargo.toml index 9c69f2246..0e2ae64fd 100644 --- a/src/core/Cargo.toml +++ b/src/core/Cargo.toml @@ -92,7 +92,7 @@ rand.workspace = true rand_core = { version = "0.6.4", features = ["getrandom"] } regex.workspace = true reqwest.workspace = true -ring.workspace = true +sha2.workspace = true ruma.workspace = true sanitize-filename.workspace = true serde_json.workspace = true diff --git a/src/core/utils/hash/sha256.rs b/src/core/utils/hash/sha256.rs index 06e210a7e..454e92bf3 100644 --- a/src/core/utils/hash/sha256.rs +++ b/src/core/utils/hash/sha256.rs @@ -1,19 +1,16 @@ -use ring::{ - digest, - digest::{Context, SHA256, SHA256_OUTPUT_LEN}, -}; +use sha2::{Digest, Sha256}; -pub type Digest = [u8; SHA256_OUTPUT_LEN]; +pub type DigestOut = [u8; 256 / 8]; /// Sha256 hash (input gather joined by 0xFF bytes) #[must_use] #[tracing::instrument(skip(inputs), level = "trace")] -pub fn delimited<'a, T, I>(mut inputs: I) -> Digest +pub fn delimited<'a, T, I>(mut inputs: I) -> DigestOut where I: Iterator + 'a, T: AsRef<[u8]> + 'a, { - let mut ctx = Context::new(&SHA256); + let mut ctx = Sha256::new(); if let Some(input) = inputs.next() { ctx.update(input.as_ref()); for input in inputs { @@ -22,8 +19,7 @@ where } } - ctx.finish() - .as_ref() + ctx.finalize() .try_into() .expect("failed to return Digest buffer") } @@ -31,18 +27,17 @@ where /// Sha256 hash (input gather) #[must_use] #[tracing::instrument(skip(inputs), level = "trace")] -pub fn concat<'a, T, I>(inputs: I) -> Digest +pub fn concat<'a, T, I>(inputs: I) -> DigestOut where I: Iterator + 'a, T: AsRef<[u8]> + 'a, { inputs - .fold(Context::new(&SHA256), |mut ctx, input| { + .fold(Sha256::new(), |mut ctx, input| { ctx.update(input.as_ref()); ctx }) - .finish() - .as_ref() + .finalize() .try_into() .expect("failed to return Digest buffer") } @@ -51,12 +46,11 @@ where #[inline] #[must_use] #[tracing::instrument(skip(input), level = "trace")] -pub fn hash(input: T) -> Digest +pub fn hash(input: T) -> DigestOut where T: AsRef<[u8]>, { - digest::digest(&SHA256, input.as_ref()) - .as_ref() + Sha256::digest(input) .try_into() .expect("failed to return Digest buffer") }