Skip to content

Commit

Permalink
ripemd: Add OID support
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Baryshkov <[email protected]>
  • Loading branch information
lumag committed Sep 22, 2022
1 parent bd9fd26 commit 45e545b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ripemd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion 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 ripemd/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.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])
Expand Down
7 changes: 4 additions & 3 deletions ripemd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
20 changes: 20 additions & 0 deletions ripemd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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");
}

0 comments on commit 45e545b

Please sign in to comment.