Skip to content

Commit 7bd9889

Browse files
authored
sha2: fix SHA-512 backend selection (#935)
The SHA-512 backend selector checks `sha2_256_backend` instead of `sha2_512_backend` for the `soft` and `riscv-zknh` branches. This ignores the corresponding SHA-512 overrides and allows SHA-256 overrides to unintentionally affect SHA-512.
1 parent 2b15987 commit 7bd9889

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎sha2/CHANGELOG.md‎

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

8+
## 0.11.2 (UNRELEASED)
9+
### Fixed
10+
- SHA-512 `riscv-zknh` backend selection ([#935])
11+
12+
[#935]: https://github.com/RustCrypto/hashes/pull/935
13+
814
## 0.11.1 (2026-10-12)
915
### Changed
1016
- Removed workaround for unaligned loads in `riscv-zknh` backend ([#879])

‎sha2/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
any(
1111
sha2_backend = "riscv-zknh",
1212
sha2_256_backend = "riscv-zknh",
13-
sha2_256_backend = "riscv-zknh",
13+
sha2_512_backend = "riscv-zknh",
1414
),
1515
feature(riscv_ext_intrinsics)
1616
)]

‎sha2/src/sha512.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
cfg_if::cfg_if! {
2-
if #[cfg(any(sha2_backend = "soft", sha2_256_backend = "soft"))] {
2+
if #[cfg(any(sha2_backend = "soft", sha2_512_backend = "soft"))] {
33
mod soft;
44
use soft::compress;
5-
} else if #[cfg(any(sha2_backend = "riscv-zknh", sha2_256_backend = "riscv-zknh"))] {
5+
} else if #[cfg(any(sha2_backend = "riscv-zknh", sha2_512_backend = "riscv-zknh"))] {
66
mod riscv_zknh;
77

88
#[cfg(not(target_feature = "zknh"))]

0 commit comments

Comments
 (0)