diff --git a/Cargo.lock b/Cargo.lock index 1cf9a41f1..01e7546bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -451,6 +451,7 @@ dependencies = [ "block-buffer 0.11.0-pre.5", "const-oid 0.10.0-pre.2", "crypto-common 0.2.0-pre.5 (registry+https://github.com/rust-lang/crates.io-index)", + "spki 0.8.0-pre.0", "subtle", "zeroize", ] diff --git a/digest/Cargo.toml b/digest/Cargo.toml index 848216478..50ceda96c 100644 --- a/digest/Cargo.toml +++ b/digest/Cargo.toml @@ -20,6 +20,7 @@ block-buffer = { version = "=0.11.0-pre.5", optional = true } subtle = { version = "2.4", default-features = false, optional = true } blobby = { version = "0.3", optional = true } const-oid = { version = "=0.10.0-pre.2", optional = true } +spki = { version = "=0.8.0-pre.0", optional = true } zeroize = { version = "1.7", optional = true, default-features = false } [features] diff --git a/digest/src/core_api/ct_variable.rs b/digest/src/core_api/ct_variable.rs index fe917bfd8..1b6dbfbbc 100644 --- a/digest/src/core_api/ct_variable.rs +++ b/digest/src/core_api/ct_variable.rs @@ -18,6 +18,8 @@ use crypto_common::{ typenum::{IsLess, IsLessOrEqual, Le, LeEq, NonZero, Sum, U1, U256}, Block, BlockSizeUser, OutputSizeUser, }; +#[cfg(feature = "spki")] +use spki::{AlgorithmIdentifier, AssociatedAlgorithmIdentifier}; /// Dummy type used with [`CtVariableCoreWrapper`] in cases when /// resulting hash does not have a known OID. @@ -167,6 +169,19 @@ where const OID: ObjectIdentifier = O::OID; } +#[cfg(feature = "spki")] +impl AssociatedAlgorithmIdentifier for CtVariableCoreWrapper +where + T: VariableOutputCore, + O: AssociatedAlgorithmIdentifier, + OutSize: ArraySize + IsLessOrEqual, + LeEq: NonZero, +{ + type Params = O::Params; + + const ALGORITHM_IDENTIFIER: AlgorithmIdentifier = O::ALGORITHM_IDENTIFIER; +} + #[cfg(feature = "zeroize")] impl zeroize::ZeroizeOnDrop for CtVariableCoreWrapper where diff --git a/digest/src/core_api/wrapper.rs b/digest/src/core_api/wrapper.rs index d366249fe..44ee3ea91 100644 --- a/digest/src/core_api/wrapper.rs +++ b/digest/src/core_api/wrapper.rs @@ -23,6 +23,8 @@ use crypto_common::{ use crate::MacMarker; #[cfg(feature = "oid")] use const_oid::{AssociatedOid, ObjectIdentifier}; +#[cfg(feature = "spki")] +use spki::{AlgorithmIdentifier, AssociatedAlgorithmIdentifier}; /// Wrapper around [`BufferKindUser`]. /// @@ -179,6 +181,16 @@ where const OID: ObjectIdentifier = T::OID; } +#[cfg(feature = "spki")] +impl AssociatedAlgorithmIdentifier for CoreWrapper +where + T: BufferKindUser + AssociatedAlgorithmIdentifier, +{ + type Params = T::Params; + + const ALGORITHM_IDENTIFIER: AlgorithmIdentifier = T::ALGORITHM_IDENTIFIER; +} + type CoreWrapperSerializedStateSize = Sum::SerializedStateSize, U1>, ::BlockSize>; diff --git a/digest/src/lib.rs b/digest/src/lib.rs index b535bc8aa..2d26d0d04 100644 --- a/digest/src/lib.rs +++ b/digest/src/lib.rs @@ -61,6 +61,8 @@ pub use block_buffer; #[cfg(feature = "oid")] pub use const_oid; pub use crypto_common; +#[cfg(feature = "spki")] +pub use spki; #[cfg(feature = "const-oid")] pub use crate::digest::DynDigestWithOid;