Skip to content

Commit

Permalink
digest: add DynDigestWithOid wrapper trait (#1390)
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov authored Nov 12, 2023
1 parent 8e1df19 commit b3313d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions digest/src/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down Expand Up @@ -224,3 +226,10 @@ impl Clone for Box<dyn DynDigest> {
self.box_clone()
}
}

/// Convenience wrapper trait around [DynDigest] and [DynAssociatedOid].
#[cfg(feature = "const-oid")]
pub trait DynDigestWithOid: DynDigest + DynAssociatedOid {}

#[cfg(feature = "const-oid")]
impl<T: DynDigest + DynAssociatedOid> DynDigestWithOid for T {}
2 changes: 2 additions & 0 deletions digest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down

0 comments on commit b3313d9

Please sign in to comment.