Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sha2: provide support for spki::AlgorithmIdentifier #586

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ opt-level = 2

[patch.crates-io]
# https://github.com/RustCrypto/traits/pull/1537 - Unreleased
digest = { git = "https://github.com/RustCrypto/traits.git" }
# https://github.com/RustCrypto/traits/pull/1575
digest = { git = "https://github.com/baloo/traits.git", branch = "baloo/digest/expose-spki" }

sha1 = { path = "./sha1" }
1 change: 1 addition & 0 deletions sha2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ hex-literal = "0.4"
default = ["oid", "std"]
std = ["digest/std"]
oid = ["digest/oid"] # Enable OID support
spki = ["oid", "digest/spki"]
zeroize = ["digest/zeroize"]
force-soft = [] # Force software implementation

Expand Down
2 changes: 2 additions & 0 deletions sha2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ mod consts;
mod core_api;
mod sha256;
mod sha512;
#[cfg(feature = "spki")]
mod spki;

pub use sha256::compress256;
pub use sha512::compress512;
Expand Down
28 changes: 28 additions & 0 deletions sha2/src/spki.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! Implements [`AlgorithmIdentifier`] according to [RFC5754 section 2]
//!
//! [RFC5754 section 2]: https://www.rfc-editor.org/rfc/rfc5754#section-2

use digest::{
const_oid::AssociatedOid,
spki::{der::asn1::AnyRef, AlgorithmIdentifierRef, AssociatedAlgorithmIdentifier},
};

use super::{OidSha224, OidSha256, OidSha384, OidSha512};

macro_rules! impl_aai {
($name:ident) => {
impl AssociatedAlgorithmIdentifier for $name {
type Params = AnyRef<'static>;

const ALGORITHM_IDENTIFIER: AlgorithmIdentifierRef<'static> = AlgorithmIdentifierRef {
oid: Self::OID,
parameters: None,
};
}
};
}

impl_aai!(OidSha224);
impl_aai!(OidSha256);
impl_aai!(OidSha384);
impl_aai!(OidSha512);
Loading