From 45e545b1c057a342fb45921aad0efa70a6d765d7 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Thu, 22 Sep 2022 11:09:34 +0300 Subject: [PATCH] ripemd: Add OID support Signed-off-by: Dmitry Baryshkov --- .github/workflows/ripemd.yml | 17 +++++++++++++++++ Cargo.lock | 2 +- ripemd/CHANGELOG.md | 6 ++++++ ripemd/Cargo.toml | 7 ++++--- ripemd/src/lib.rs | 20 ++++++++++++++++++++ 5 files changed, 48 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ripemd.yml b/.github/workflows/ripemd.yml index 16cec9401..9e581acff 100644 --- a/.github/workflows/ripemd.yml +++ b/.github/workflows/ripemd.yml @@ -63,3 +63,20 @@ 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 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..7694318cd 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,21 @@ 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 { + 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 { + 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"); +}