From 0f6f9bed0946df08d44240a80cbc48035b011aa5 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Thu, 22 Sep 2022 11:09:34 +0300 Subject: [PATCH 1/3] ripemd: Add OID support Signed-off-by: Dmitry Baryshkov --- .github/workflows/ripemd.yml | 22 +++++++++++++++++++++- Cargo.lock | 2 +- ripemd/CHANGELOG.md | 6 ++++++ ripemd/Cargo.toml | 7 ++++--- ripemd/src/lib.rs | 26 ++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ripemd.yml b/.github/workflows/ripemd.yml index 16cec9401..7c1e74c30 100644 --- a/.github/workflows/ripemd.yml +++ b/.github/workflows/ripemd.yml @@ -49,7 +49,9 @@ jobs: strategy: matrix: rust: - - 1.41.0 # MSRV + # Crate supports MSRV 1.41 without `oid` feature. We test true MSRV + # in the `test-msrv` job. + - 1.57.0 - stable steps: - uses: actions/checkout@v3 @@ -63,3 +65,21 @@ jobs: - run: cargo test --no-default-features - run: cargo test - run: cargo test --all-features + + # TODO: merge with test on MSRV bump to 1.57 or higher + test-msrv: + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - 1.57.0 # MSRV + steps: + - uses: actions/checkout@v3 + - uses: RustCrypto/actions/cargo-cache@master + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.rust }} + override: true + - run: cargo test --features oid + - run: cargo test --no-default-features diff --git a/Cargo.lock b/Cargo.lock index 345f1b7aa..9b1e65dba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -191,7 +191,7 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "ripemd" -version = "0.1.2" +version = "0.1.3" dependencies = [ "digest", "hex-literal", diff --git a/ripemd/CHANGELOG.md b/ripemd/CHANGELOG.md index c56bda0b5..9723db07e 100644 --- a/ripemd/CHANGELOG.md +++ b/ripemd/CHANGELOG.md @@ -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.1.2 (2022-09-22) +### Added +- Feature-gated OID support ([#415]) + +[#415]: https://github.com/RustCrypto/hashes/pull/415 + ## 0.1.2 (2022-09-16) ### Added - RIPEMD-128 algorithm ([#406]) diff --git a/ripemd/Cargo.toml b/ripemd/Cargo.toml index 3758af607..3e8394d04 100644 --- a/ripemd/Cargo.toml +++ b/ripemd/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ripemd" -version = "0.1.2" +version = "0.1.3" description = "Pure Rust implementation of the RIPEMD hash functions" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" @@ -12,12 +12,13 @@ keywords = ["crypto", "ripemd", "hash", "digest"] categories = ["cryptography", "no-std"] [dependencies] -digest = "0.10.3" +digest = "0.10.4" [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 diff --git a/ripemd/src/lib.rs b/ripemd/src/lib.rs index 06b69f02d..1a28ed76b 100644 --- a/ripemd/src/lib.rs +++ b/ripemd/src/lib.rs @@ -49,6 +49,8 @@ pub use digest::{self, Digest}; use core::fmt; +#[cfg(feature = "oid")] +use digest::const_oid::{AssociatedOid, ObjectIdentifier}; use digest::{ block_buffer::Eager, core_api::{ @@ -158,3 +160,27 @@ impl_ripemd!(Ripemd128Core, Ripemd128, c128, "128", "RIPEMD-128", U16); impl_ripemd!(Ripemd160Core, Ripemd160, c160, "160", "RIPEMD-160", U20); impl_ripemd!(Ripemd256Core, Ripemd256, c256, "256", "RIPEMD-256", U32); impl_ripemd!(Ripemd320Core, Ripemd320, c320, "320", "RIPEMD-320", U40); + +#[cfg(feature = "oid")] +#[cfg_attr(docsrs, doc(cfg(feature = "oid")))] +impl AssociatedOid for Ripemd128Core { + /// The OID used for the RIPEMD-160. There are two OIDs defined. The Teletrust one (which is + /// used by almost anybody, including BouncyCastle, OpenSSL, GnuTLS, etc. and the ISO one + /// (1.0.10118.3.0.50), which seems to be used by nobody. + const OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.3.36.3.2.2"); +} + +#[cfg(feature = "oid")] +#[cfg_attr(docsrs, doc(cfg(feature = "oid")))] +impl AssociatedOid for Ripemd160Core { + /// The OID used for the RIPEMD-160. There are two OIDs defined. The Teletrust one (which is + /// used by almost anybody, including BouncyCastle, OpenSSL, GnuTLS, etc. and the ISO one + /// (1.0.10118.3.0.49), which seems to be used by Go and nobody else. + const OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.3.36.3.2.1"); +} + +#[cfg(feature = "oid")] +#[cfg_attr(docsrs, doc(cfg(feature = "oid")))] +impl AssociatedOid for Ripemd256Core { + const OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.3.36.3.2.3"); +} From 251d6892096c6e898e27d137c2e1df60de8c71df Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Fri, 23 Sep 2022 10:21:24 +0000 Subject: [PATCH 2/3] Update release date --- ripemd/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ripemd/CHANGELOG.md b/ripemd/CHANGELOG.md index 9723db07e..bf044ddb8 100644 --- a/ripemd/CHANGELOG.md +++ b/ripemd/CHANGELOG.md @@ -5,7 +5,7 @@ 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.1.2 (2022-09-22) +## 0.1.2 (2022-09-23) ### Added - Feature-gated OID support ([#415]) From 184e8d521657cb6cd5fd07a08b56beeb6c14ce5d Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Fri, 23 Sep 2022 10:22:29 +0000 Subject: [PATCH 3/3] Fix release version --- ripemd/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ripemd/CHANGELOG.md b/ripemd/CHANGELOG.md index bf044ddb8..81cef616c 100644 --- a/ripemd/CHANGELOG.md +++ b/ripemd/CHANGELOG.md @@ -5,7 +5,7 @@ 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.1.2 (2022-09-23) +## 0.1.3 (2022-09-23) ### Added - Feature-gated OID support ([#415])