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

Add OID support #405

Merged
merged 7 commits into from
Sep 16, 2022
Merged
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
18 changes: 17 additions & 1 deletion .github/workflows/sha1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ jobs:
set-msrv:
uses: RustCrypto/actions/.github/workflows/set-msrv.yml@master
with:
msrv: 1.41.0
# Crate supports MSRV 1.41 without `oid` feature. We test true MSRV
# in the `test-msrv` job.
msrv: 1.57.0

# Builds for no_std platforms
build:
Expand Down Expand Up @@ -171,3 +173,17 @@ jobs:
package: ${{ github.workflow }}
target: ${{ matrix.target }}
features: ${{ matrix.features }}

# TODO: remove on MSRV bump to 1.57 or higher
test-msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: RustCrypto/actions/cargo-cache@master
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.41.0
override: true
- run: cargo test --no-default-features
- run: cargo test
18 changes: 17 additions & 1 deletion .github/workflows/sha2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ jobs:
set-msrv:
uses: RustCrypto/actions/.github/workflows/set-msrv.yml@master
with:
msrv: 1.41.0
# Crate supports MSRV 1.41 without `oid` feature. We test true MSRV
# in the `test-msrv` job.
msrv: 1.57.0

# Builds for no_std platforms
build:
Expand Down Expand Up @@ -166,3 +168,17 @@ jobs:
package: ${{ github.workflow }}
target: ${{ matrix.target }}
features: ${{ matrix.features }}

# TODO: remove on MSRV bump to 1.57 or higher
test-msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: RustCrypto/actions/cargo-cache@master
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.41.0
override: true
- run: cargo test --no-default-features
- run: cargo test
18 changes: 17 additions & 1 deletion .github/workflows/sha3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ jobs:
set-msrv:
uses: RustCrypto/actions/.github/workflows/set-msrv.yml@master
with:
msrv: 1.41.0
# Crate supports MSRV 1.41 without `oid` feature. We test true MSRV
# in the `test-msrv` job.
msrv: 1.57.0

build:
needs: set-msrv
Expand Down Expand Up @@ -97,3 +99,17 @@ jobs:
package: ${{ github.workflow }}
target: ${{ matrix.target }}
features: ${{ matrix.features }}

# TODO: remove on MSRV bump to 1.57 or higher
test-msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: RustCrypto/actions/cargo-cache@master
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.41.0
override: true
- run: cargo test --no-default-features
- run: cargo test
16 changes: 15 additions & 1 deletion .github/workflows/streebog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
strategy:
matrix:
rust:
- 1.41.0 # MSRV
#- 1.41.0 # MSRV
- stable
steps:
- uses: actions/checkout@v2
Expand All @@ -63,3 +63,17 @@ jobs:
- run: cargo test --no-default-features
- run: cargo test
- run: cargo test --all-features

# `oid` feature bumps MSRV to 1.57, so we temporarily split this job.
test-msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: RustCrypto/actions/cargo-cache@master
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.41.0
override: true
- run: cargo test --no-default-features
- run: cargo test
23 changes: 15 additions & 8 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions sha1/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.10.5 (2022-09-16)
### Added
- Feature-gated OID support ([#405])

[#405]: https://github.com/RustCrypto/hashes/pull/405

## 0.10.4 (2022-09-02)
### Fixed
- MSRV issue which was not resolved by v0.10.3 ([#401])
Expand Down
7 changes: 4 additions & 3 deletions sha1/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sha1"
version = "0.10.4"
version = "0.10.5"
description = "SHA-1 hash function"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
Expand All @@ -12,20 +12,21 @@ keywords = ["crypto", "sha1", "hash", "digest"]
categories = ["cryptography", "no-std"]

[dependencies]
digest = "0.10.3"
digest = "0.10.4"
cfg-if = "1.0"

[target.'cfg(any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64"))'.dependencies]
cpufeatures = "0.2"
sha1-asm = { version = "0.5", optional = true }

[dev-dependencies]
digest = { version = "0.10.3", features = ["dev"] }
digest = { version = "0.10.4", features = ["dev"] }
hex-literal = "0.2.2"

[features]
default = ["std"]
std = ["digest/std"]
oid = ["digest/oid"] # Enable OID support. WARNING: Bumps MSRV to 1.57
asm = ["sha1-asm"] # WARNING: this feature SHOULD NOT be enabled by library crates
compress = [] # Expose compress function
force-soft = [] # Force software implementation
Expand Down
8 changes: 8 additions & 0 deletions sha1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
pub use digest::{self, Digest};

use core::{fmt, slice::from_ref};
#[cfg(feature = "oid")]
use digest::const_oid::{AssociatedOid, ObjectIdentifier};
use digest::{
block_buffer::Eager,
core_api::{
Expand Down Expand Up @@ -142,5 +144,11 @@ impl fmt::Debug for Sha1Core {
}
}

#[cfg(feature = "oid")]
#[cfg_attr(docsrs, doc(cfg(feature = "oid")))]
impl AssociatedOid for Sha1Core {
const OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.3.14.3.2.26");
}

/// SHA-1 hasher state.
pub type Sha1 = CoreWrapper<Sha1Core>;
6 changes: 6 additions & 0 deletions sha2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.10.6 (2022-09-16)
### Added
- Feature-gated OID support ([#405])

[#405]: https://github.com/RustCrypto/hashes/pull/405

## 0.10.5 (2022-09-02)
### Fixed
- MSRV issue which was not resolved by v0.10.4 ([#401])
Expand Down
7 changes: 4 additions & 3 deletions sha2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sha2"
version = "0.10.5"
version = "0.10.6"
description = """
Pure Rust implementation of the SHA-2 hash function family
including SHA-224, SHA-256, SHA-384, and SHA-512.
Expand All @@ -15,20 +15,21 @@ keywords = ["crypto", "sha2", "hash", "digest"]
categories = ["cryptography", "no-std"]

[dependencies]
digest = "0.10.3"
digest = "0.10.4"
cfg-if = "1.0"

[target.'cfg(any(target_arch = "aarch64", target_arch = "x86_64", target_arch = "x86"))'.dependencies]
cpufeatures = "0.2"
sha2-asm = { version = "0.6.1", optional = true }

[dev-dependencies]
digest = { version = "0.10.3", features = ["dev"] }
digest = { version = "0.10.4", features = ["dev"] }
hex-literal = "0.2.2"

[features]
default = ["std"]
std = ["digest/std"]
oid = ["digest/oid"] # Enable OID support. WARNING: Bumps MSRV to 1.57
asm = ["sha2-asm"] # WARNING: this feature SHOULD NOT be enabled by library crates
compress = [] # Expose compress functions
force-soft = [] # Force software implementation
Expand Down
22 changes: 16 additions & 6 deletions sha2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@

pub use digest::{self, Digest};

#[cfg(feature = "oid")]
use digest::const_oid::{AssociatedOid, ObjectIdentifier};
use digest::{
consts::{U28, U32, U48, U64},
core_api::{CoreWrapper, CtVariableCoreWrapper},
impl_oid_carrier,
};

#[rustfmt::skip]
Expand All @@ -71,15 +74,22 @@ pub use sha512::compress512;

pub use core_api::{Sha256VarCore, Sha512VarCore};

impl_oid_carrier!(OidSha256, "2.16.840.1.101.3.4.2.1");
impl_oid_carrier!(OidSha384, "2.16.840.1.101.3.4.2.2");
impl_oid_carrier!(OidSha512, "2.16.840.1.101.3.4.2.3");
impl_oid_carrier!(OidSha224, "2.16.840.1.101.3.4.2.4");
impl_oid_carrier!(OidSha512_224, "2.16.840.1.101.3.4.2.5");
impl_oid_carrier!(OidSha512_256, "2.16.840.1.101.3.4.2.6");

/// SHA-224 hasher.
pub type Sha224 = CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, U28>>;
pub type Sha224 = CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, U28, OidSha224>>;
/// SHA-256 hasher.
pub type Sha256 = CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, U32>>;
pub type Sha256 = CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, U32, OidSha256>>;
/// SHA-512/224 hasher.
pub type Sha512_224 = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U28>>;
pub type Sha512_224 = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U28, OidSha512_224>>;
/// SHA-512/256 hasher.
pub type Sha512_256 = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U32>>;
pub type Sha512_256 = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U32, OidSha512_256>>;
/// SHA-384 hasher.
pub type Sha384 = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U48>>;
pub type Sha384 = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U48, OidSha384>>;
/// SHA-512 hasher.
pub type Sha512 = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U64>>;
pub type Sha512 = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U64, OidSha512>>;
6 changes: 6 additions & 0 deletions sha3/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.10.5 (2022-09-16)
### Added
- Feature-gated OID support ([#405])

[#405]: https://github.com/RustCrypto/hashes/pull/405

## 0.10.4 (2022-09-02)
### Fixed
- MSRV issue which was not resolved by v0.10.3 ([#401])
Expand Down
7 changes: 4 additions & 3 deletions sha3/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sha3"
version = "0.10.4"
version = "0.10.5"
description = "SHA-3 (Keccak) hash function"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
Expand All @@ -12,14 +12,15 @@ keywords = ["crypto", "sha3", "keccak", "hash", "digest"]
categories = ["cryptography", "no-std"]

[dependencies]
digest = "0.10.3"
digest = "0.10.4"
keccak = "0.1"

[dev-dependencies]
digest = { version = "0.10.3", features = ["dev"] }
digest = { version = "0.10.4", features = ["dev"] }
hex-literal = "0.2.2"

[features]
default = ["std"]
std = ["digest/std"]
oid = ["digest/oid"] # Enable OID support. WARNING: Bumps MSRV to 1.57
reset = [] # Enable reset functionality
Loading