Repository: RustCrypto/hashes (language: rust)

Issue:
[sha2] TODO: replace after sha2-asm rework
Is there an issue to track this TODO? Can some additional description be added?

https://github.com/RustCrypto/hashes/blob/39a55cf35a4282648298586193d6f8384f30869e/sha2/src/sha512.rs#L235-L236


Discussion / hints:
@newpavlov ?
The idea was to change signatures of the asm crates to accept `&[[u8; 128]]` instead of the current single-block `&[u8; 128]`. Effectively it's a workaround around the noalias LLVM bug, currently after each block was processed the state is saved needlessly, instead of staying in registers. The only workaround which I have found was to copy state to a local variable and work with it, thus the need for the multi-block compression.

The ASM crates currently have a low priority for us and potential performance improvements are quite small, so I probably simply will remove this comment.

Fix patch:
diff --git a/sha1/src/compress.rs b/sha1/src/compress.rs
index af35679be..c849c89e0 100644
--- a/sha1/src/compress.rs
+++ b/sha1/src/compress.rs
@@ -10,7 +10,6 @@ cfg_if::cfg_if! {
         mod aarch64;
         use aarch64::compress as compress_inner;
     } else if #[cfg(all(feature = "asm", any(target_arch = "x86", target_arch = "x86_64")))] {
-        // TODO: replace after sha1-asm rework
         fn compress_inner(state: &mut [u32; 5], blocks: &[[u8; 64]]) {
             for block in blocks {
                 sha1_asm::compress(state, block);
diff --git a/sha2/src/sha256.rs b/sha2/src/sha256.rs
index 8dade9f89..3eef74584 100644
--- a/sha2/src/sha256.rs
+++ b/sha2/src/sha256.rs
@@ -147,7 +147,6 @@ cfg_if::cfg_if! {
         mod aarch64;
         use aarch64::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 [u32; 8], blocks: &[[u8; 64]]) {
             for block in blocks {
                 sha2_asm::compress256(state, block);
diff --git a/sha2/src/sha256/aarch64.rs b/sha2/src/sha256/aarch64.rs
index 1b8b0c8b5..47796cf88 100644
--- a/sha2/src/sha256/aarch64.rs
+++ b/sha2/src/sha256/aarch64.rs
@@ -10,7 +10,6 @@ pub fn compress(state: &mut [u32; 8], blocks: &[[u8; 64]]) {
     // TODO: Replace with https://github.com/rust-lang/rfcs/pull/2725
     // after stabilization
     if sha2_supported() {
-        // TODO: replace after sha2-asm rework
         for block in blocks {
             sha2_asm::compress256(state, block);
         }
diff --git a/sha2/src/sha512.rs b/sha2/src/sha512.rs
index 3280c6d21..55ca80daf 100644
--- a/sha2/src/sha512.rs
+++ b/sha2/src/sha512.rs
@@ -232,7 +232,6 @@ cfg_if::cfg_if! {
         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 {
                 sha2_asm::compress512(state, block);


Test patch: