From b3313d9a9594cf1df727668e7fa9da9eace30c8a Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Sun, 12 Nov 2023 16:54:06 +0300 Subject: [PATCH] digest: add DynDigestWithOid wrapper trait (#1390) --- digest/src/digest.rs | 9 +++++++++ digest/src/lib.rs | 2 ++ 2 files changed, 11 insertions(+) diff --git a/digest/src/digest.rs b/digest/src/digest.rs index 0642af43..c8d1ca87 100644 --- a/digest/src/digest.rs +++ b/digest/src/digest.rs @@ -3,6 +3,8 @@ use crypto_common::{typenum::Unsigned, Output, OutputSizeUser}; #[cfg(feature = "alloc")] use alloc::boxed::Box; +#[cfg(feature = "const-oid")] +use const_oid::DynAssociatedOid; /// Marker trait for cryptographic hash functions. pub trait HashMarker {} @@ -224,3 +226,10 @@ impl Clone for Box { self.box_clone() } } + +/// Convenience wrapper trait around [DynDigest] and [DynAssociatedOid]. +#[cfg(feature = "const-oid")] +pub trait DynDigestWithOid: DynDigest + DynAssociatedOid {} + +#[cfg(feature = "const-oid")] +impl DynDigestWithOid for T {} diff --git a/digest/src/lib.rs b/digest/src/lib.rs index b076853b..1bb0d532 100644 --- a/digest/src/lib.rs +++ b/digest/src/lib.rs @@ -59,6 +59,8 @@ pub use block_buffer; pub use const_oid; pub use crypto_common; +#[cfg(feature = "const-oid")] +pub use crate::digest::DynDigestWithOid; pub use crate::digest::{Digest, DynDigest, HashMarker}; pub use crypto_common::{array, typenum, typenum::consts, Output, OutputSizeUser, Reset}; #[cfg(feature = "mac")]