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 enforce-soft feature to sha1 and sha2 #203

Merged
merged 1 commit into from
Nov 3, 2020
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
4 changes: 2 additions & 2 deletions Cargo.lock

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

10 changes: 10 additions & 0 deletions sha1/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ 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.9.2 (2020-11-04)
### Added
- `force-soft` feature to enforce use of software implementation. ([#203])

### Changed
- `cfg-if` dependency updated to v1.0. ([#197])

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

## 0.9.1 (2020-06-24)
### Added
- x86 hardware acceleration via SHA extension instrinsics. ([#167])
Expand Down
4 changes: 3 additions & 1 deletion sha1/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sha-1"
version = "0.9.1"
version = "0.9.2"
description = "SHA-1 hash function"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
Expand Down Expand Up @@ -35,6 +35,8 @@ hex-literal = "0.2"
default = ["std"]
std = ["digest/std"]
asm = ["sha1-asm", "libc"]
# Force software implementation
force-soft = []

# DEPRECATED: use `asm` instead
asm-aarch64 = ["asm"]
5 changes: 4 additions & 1 deletion sha1/src/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use digest::consts::U64;
use digest::generic_array::GenericArray;

cfg_if::cfg_if! {
if #[cfg(all(feature = "asm", target_arch = "aarch64", target_os = "linux"))] {
if #[cfg(feature = "force-soft")] {
mod soft;
use soft::compress as compress_inner;
} else if #[cfg(all(feature = "asm", target_arch = "aarch64", target_os = "linux"))] {
mod soft;
mod aarch64;
use aarch64::compress as compress_inner;
Expand Down
10 changes: 10 additions & 0 deletions sha2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ 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.9.2 (2020-11-04)
### Added
- `force-soft` feature to enforce use of software implementation. ([#203])

### Changed
- `cfg-if` dependency updated to v1.0. ([#197])

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

## 0.9.1 (2020-06-24)
### Added
- x86 hardware acceleration of SHA-256 via SHA extension instrinsics. ([#167])
Expand Down
5 changes: 4 additions & 1 deletion sha2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sha2"
version = "0.9.1"
version = "0.9.2"
description = """
Pure Rust implementation of the SHA-2 hash function family
including SHA-224, SHA-256, SHA-384, and SHA-512.
Expand Down Expand Up @@ -35,7 +35,10 @@ hex-literal = "0.2"
default = ["std"]
std = ["digest/std"]
asm = ["sha2-asm", "libc"]
# Expose compress function
compress = []
# Force software implementation
force-soft = []

# DEPRECATED: use `asm` instead
asm-aarch64 = ["asm"]
5 changes: 4 additions & 1 deletion sha2/src/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ digest::impl_write!(Sha224);
digest::impl_write!(Sha256);

cfg_if::cfg_if! {
if #[cfg(all(feature = "asm", target_arch = "aarch64", target_os = "linux"))] {
if #[cfg(feature = "force-soft")] {
mod soft;
use soft::compress;
} else if #[cfg(all(feature = "asm", target_arch = "aarch64", target_os = "linux"))] {
mod soft;
mod aarch64;
use aarch64::compress;
Expand Down
5 changes: 4 additions & 1 deletion sha2/src/sha512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ digest::impl_write!(Sha512Trunc224);
digest::impl_write!(Sha512Trunc256);

cfg_if::cfg_if! {
if #[cfg(all(feature = "asm", any(target_arch = "x86", target_arch = "x86_64")))] {
if #[cfg(feature = "force-soft")] {
mod soft;
use soft::compress;
} else if #[cfg(all(feature = "asm", any(target_arch = "x86", target_arch = "x86_64")))] {
// TODO: replace after sha2-asm rework
fn compress(state: &mut [u64; 8], blocks: &[[u8; 128]]) {
for block in blocks {
Expand Down