diff options
Diffstat (limited to 'vendor/sha1')
-rw-r--r-- | vendor/sha1/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/sha1/CHANGELOG.md | 6 | ||||
-rw-r--r-- | vendor/sha1/Cargo.toml | 37 | ||||
-rw-r--r-- | vendor/sha1/README.md | 8 | ||||
-rw-r--r-- | vendor/sha1/src/compress.rs | 3 | ||||
-rw-r--r-- | vendor/sha1/src/compress/loongarch64_asm.rs | 255 | ||||
-rw-r--r-- | vendor/sha1/src/lib.rs | 4 |
7 files changed, 297 insertions, 18 deletions
diff --git a/vendor/sha1/.cargo-checksum.json b/vendor/sha1/.cargo-checksum.json index 138cc4425..7fa32e243 100644 --- a/vendor/sha1/.cargo-checksum.json +++ b/vendor/sha1/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"CHANGELOG.md":"f3930b8a16e5173aca294672a3f83d44949160073cb7b20ed8eadc475f602b13","Cargo.toml":"03465b24b6574f22f50d0f1f4d7c972dd1098c50c457bda1035e9a7b9fa5bccd","LICENSE-APACHE":"a9040321c3712d8fd0b09cf52b17445de04a23a10165049ae187cd39e5c86be5","LICENSE-MIT":"b4eb00df6e2a4d22518fcaa6a2b4646f249b3a3c9814509b22bd2091f1392ff1","README.md":"e3e967137d854fef6c4a8c9d018c93bf35640a325a825b6a404dd3183219206c","benches/mod.rs":"2765aec429270711235d6cd4911d0c21658e2fa3dfbe24559f24e21b056b507c","src/compress.rs":"3e401e6a4ac3699994cedf34ff66d12a828bbef3457e8e751a3147a03a70607e","src/compress/aarch64.rs":"b1e66c2df53eaf84ccf7466aed47c0718fc3dbe1d1c565b65abd60e84b6fc5d4","src/compress/soft.rs":"bc6dda22b15acd76d97e202a8b251d9c68441d426a71600b2a61c36dd6f3a08e","src/compress/x86.rs":"9d2b4f240a311a84b351c136cccdc4dc00a7fc35703146ad51ed2d6e0aaef2d0","src/lib.rs":"dea41278ae1d72c64925a1b417d343068edf0c92e87b9f2350f31d78ef1ef7cd","tests/data/sha1.blb":"b9c03b9e56e0a7b08a6d6867599a33cab1a55aec3f41fef910c133fc35dc2851","tests/mod.rs":"34bb42bf4679b3f23ffc2338356c8579c872026eef9989955a29ba44a432c3b5"},"package":"f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"}
\ No newline at end of file +{"files":{"CHANGELOG.md":"7e9245847760fa99eaab7e4864a199148387aaa6121ac3dfbe189f0b684cf7d2","Cargo.toml":"cbfdd2dcaf34776f686caf30420c0a32a13d032fdd62495a054e65c3b0769132","LICENSE-APACHE":"a9040321c3712d8fd0b09cf52b17445de04a23a10165049ae187cd39e5c86be5","LICENSE-MIT":"b4eb00df6e2a4d22518fcaa6a2b4646f249b3a3c9814509b22bd2091f1392ff1","README.md":"8028a4064be59cba366c1bafa682002b52891a3cc2d2169d8f38064ba69773d1","benches/mod.rs":"2765aec429270711235d6cd4911d0c21658e2fa3dfbe24559f24e21b056b507c","src/compress.rs":"fcd99dc9c137e1fc05e47d406adfeeafccb31bed981e7c8bf480d765fb36e877","src/compress/aarch64.rs":"b1e66c2df53eaf84ccf7466aed47c0718fc3dbe1d1c565b65abd60e84b6fc5d4","src/compress/loongarch64_asm.rs":"0fd7d61b5ca7d7bce40cd9ce9012eb787da9f9df87595bfe00f8d882267d182e","src/compress/soft.rs":"bc6dda22b15acd76d97e202a8b251d9c68441d426a71600b2a61c36dd6f3a08e","src/compress/x86.rs":"9d2b4f240a311a84b351c136cccdc4dc00a7fc35703146ad51ed2d6e0aaef2d0","src/lib.rs":"c3409d489833cf896d611baf0ca0e5958629fc9e5f91a1144e789dc1858c513c","tests/data/sha1.blb":"b9c03b9e56e0a7b08a6d6867599a33cab1a55aec3f41fef910c133fc35dc2851","tests/mod.rs":"34bb42bf4679b3f23ffc2338356c8579c872026eef9989955a29ba44a432c3b5"},"package":"e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"}
\ No newline at end of file diff --git a/vendor/sha1/CHANGELOG.md b/vendor/sha1/CHANGELOG.md index 78ffc6006..429e67727 100644 --- a/vendor/sha1/CHANGELOG.md +++ b/vendor/sha1/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.10.6 (2023-09-21) +### Added +- `asm!`-based backend for LoongArch64 targets gated behind `loongarch64_asm` feature [#504] + +[#504]: https://github.com/RustCrypto/hashes/pull/504 + ## 0.10.5 (2022-09-16) ### Added - Feature-gated OID support ([#405]) diff --git a/vendor/sha1/Cargo.toml b/vendor/sha1/Cargo.toml index 5addd541e..8ddd90973 100644 --- a/vendor/sha1/Cargo.toml +++ b/vendor/sha1/Cargo.toml @@ -3,35 +3,48 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "sha1" -version = "0.10.5" +version = "0.10.6" authors = ["RustCrypto Developers"] description = "SHA-1 hash function" documentation = "https://docs.rs/sha1" readme = "README.md" -keywords = ["crypto", "sha1", "hash", "digest"] -categories = ["cryptography", "no-std"] +keywords = [ + "crypto", + "sha1", + "hash", + "digest", +] +categories = [ + "cryptography", + "no-std", +] license = "MIT OR Apache-2.0" repository = "https://github.com/RustCrypto/hashes" + [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] +rustdoc-args = [ + "--cfg", + "docsrs", +] + [dependencies.cfg-if] version = "1.0" [dependencies.digest] -version = "0.10.4" +version = "0.10.7" + [dev-dependencies.digest] -version = "0.10.4" +version = "0.10.7" features = ["dev"] [dev-dependencies.hex-literal] @@ -42,8 +55,10 @@ asm = ["sha1-asm"] compress = [] default = ["std"] force-soft = [] +loongarch64_asm = [] oid = ["digest/oid"] std = ["digest/std"] + [target."cfg(any(target_arch = \"aarch64\", target_arch = \"x86\", target_arch = \"x86_64\"))".dependencies.cpufeatures] version = "0.2" diff --git a/vendor/sha1/README.md b/vendor/sha1/README.md index dc6102eb9..bd76f0973 100644 --- a/vendor/sha1/README.md +++ b/vendor/sha1/README.md @@ -48,10 +48,10 @@ dual licensed as above, without any additional terms or conditions. [//]: # (badges) -[crate-image]: https://img.shields.io/crates/v/sha-1.svg -[crate-link]: https://crates.io/crates/sha-1 -[docs-image]: https://docs.rs/sha-1/badge.svg -[docs-link]: https://docs.rs/sha-1/ +[crate-image]: https://img.shields.io/crates/v/sha1.svg +[crate-link]: https://crates.io/crates/sha1 +[docs-image]: https://docs.rs/sha1/badge.svg +[docs-link]: https://docs.rs/sha1/ [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg [rustc-image]: https://img.shields.io/badge/rustc-1.41+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg diff --git a/vendor/sha1/src/compress.rs b/vendor/sha1/src/compress.rs index da4a10a98..6f7e40c41 100644 --- a/vendor/sha1/src/compress.rs +++ b/vendor/sha1/src/compress.rs @@ -9,6 +9,9 @@ cfg_if::cfg_if! { mod soft; mod aarch64; use aarch64::compress as compress_inner; + } else if #[cfg(all(feature = "loongarch64_asm", target_arch = "loongarch64"))] { + mod loongarch64_asm; + use loongarch64_asm::compress as compress_inner; } else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { #[cfg(not(feature = "asm"))] mod soft; diff --git a/vendor/sha1/src/compress/loongarch64_asm.rs b/vendor/sha1/src/compress/loongarch64_asm.rs new file mode 100644 index 000000000..facef1b19 --- /dev/null +++ b/vendor/sha1/src/compress/loongarch64_asm.rs @@ -0,0 +1,255 @@ +//! LoongArch64 assembly backend + +use core::arch::asm; + +const K: [u32; 4] = [0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6]; + +macro_rules! c { + ($($l:expr)*) => { + concat!($($l ,)*) + }; +} + +macro_rules! round0a { + ($a:literal, $b:literal, $c:literal, $d:literal, $e:literal, $i:literal) => { + c!( + "ld.w $t5, $a1, (" $i " * 4);" + "revb.2h $t5, $t5;" + "rotri.w $t5, $t5, 16;" + "add.w " $e ", " $e ", $t5;" + "st.w $t5, $sp, (" $i " * 4);" + "xor $t5, " $c "," $d ";" + "and $t5, $t5, " $b ";" + "xor $t5, $t5, " $d ";" + roundtail!($a, $b, $e, $i, "$a4") + ) + }; +} + +macro_rules! scheldule { + ($i:literal, $e:literal) => { + c!( + "ld.w $t5, $sp, (((" $i " - 3) & 0xF) * 4);" + "ld.w $t6, $sp, (((" $i " - 8) & 0xF) * 4);" + "ld.w $t7, $sp, (((" $i " - 14) & 0xF) * 4);" + "ld.w $t8, $sp, (((" $i " - 16) & 0xF) * 4);" + "xor $t5, $t5, $t6;" + "xor $t5, $t5, $t7;" + "xor $t5, $t5, $t8;" + "rotri.w $t5, $t5, 31;" + "add.w " $e "," $e ", $t5;" + "st.w $t5, $sp, ((" $i " & 0xF) * 4);" + ) + }; +} + +macro_rules! round0b { + ($a:literal, $b:literal, $c:literal, $d:literal, $e:literal, $i:literal) => { + c!( + scheldule!($i, $e) + "xor $t5," $c "," $d ";" + "and $t5, $t5," $b ";" + "xor $t5, $t5," $d ";" + roundtail!($a, $b, $e, $i, "$a4") + ) + }; +} + +macro_rules! round1 { + ($a:literal, $b:literal, $c:literal, $d:literal, $e:literal, $i:literal) => { + c!( + scheldule!($i, $e) + "xor $t5," $b "," $c ";" + "xor $t5, $t5," $d ";" + roundtail!($a, $b, $e, $i, "$a5") + ) + }; +} + +macro_rules! round2 { + ($a:literal, $b:literal, $c:literal, $d:literal, $e:literal, $i:literal) => { + c!( + scheldule!($i, $e) + "or $t5," $c "," $d ";" + "and $t5, $t5, " $b ";" + "and $t7," $c "," $d ";" + "or $t5, $t5, $t7;" + roundtail!($a, $b, $e, $i, "$a6") + ) + }; +} + +macro_rules! round3 { + ($a:literal, $b:literal, $c:literal, $d:literal, $e:literal, $i:literal) => { + c!( + scheldule!($i, $e) + "xor $t5," $b "," $c ";" + "xor $t5, $t5," $d ";" + roundtail!($a, $b, $e, $i, "$a7") + ) + }; +} + +macro_rules! roundtail { + ($a:literal, $b:literal, $e:literal, $i:literal, $k:literal) => { + c!( + "rotri.w " $b "," $b ", 2;" + "add.w " $e "," $e ", $t5;" + "add.w " $e "," $e "," $k ";" + "rotri.w $t5," $a ", 27;" + "add.w " $e "," $e ", $t5;" + ) + }; +} + +pub fn compress(state: &mut [u32; 5], blocks: &[[u8; 64]]) { + if blocks.is_empty() { + return; + } + + unsafe { + asm!( + // Allocate scratch stack space + "addi.d $sp, $sp, -64;", + + // Load state + "ld.w $t0, $a0, 0", + "ld.w $t1, $a0, 4", + "ld.w $t2, $a0, 8", + "ld.w $t3, $a0, 12", + "ld.w $t4, $a0, 16", + + "42:", + + round0a!("$t0", "$t1", "$t2", "$t3", "$t4", 0), + round0a!("$t4", "$t0", "$t1", "$t2", "$t3", 1), + round0a!("$t3", "$t4", "$t0", "$t1", "$t2", 2), + round0a!("$t2", "$t3", "$t4", "$t0", "$t1", 3), + round0a!("$t1", "$t2", "$t3", "$t4", "$t0", 4), + round0a!("$t0", "$t1", "$t2", "$t3", "$t4", 5), + round0a!("$t4", "$t0", "$t1", "$t2", "$t3", 6), + round0a!("$t3", "$t4", "$t0", "$t1", "$t2", 7), + round0a!("$t2", "$t3", "$t4", "$t0", "$t1", 8), + round0a!("$t1", "$t2", "$t3", "$t4", "$t0", 9), + round0a!("$t0", "$t1", "$t2", "$t3", "$t4", 10), + round0a!("$t4", "$t0", "$t1", "$t2", "$t3", 11), + round0a!("$t3", "$t4", "$t0", "$t1", "$t2", 12), + round0a!("$t2", "$t3", "$t4", "$t0", "$t1", 13), + round0a!("$t1", "$t2", "$t3", "$t4", "$t0", 14), + round0a!("$t0", "$t1", "$t2", "$t3", "$t4", 15), + round0b!("$t4", "$t0", "$t1", "$t2", "$t3", 16), + round0b!("$t3", "$t4", "$t0", "$t1", "$t2", 17), + round0b!("$t2", "$t3", "$t4", "$t0", "$t1", 18), + round0b!("$t1", "$t2", "$t3", "$t4", "$t0", 19), + round1!("$t0", "$t1", "$t2", "$t3", "$t4", 20), + round1!("$t4", "$t0", "$t1", "$t2", "$t3", 21), + round1!("$t3", "$t4", "$t0", "$t1", "$t2", 22), + round1!("$t2", "$t3", "$t4", "$t0", "$t1", 23), + round1!("$t1", "$t2", "$t3", "$t4", "$t0", 24), + round1!("$t0", "$t1", "$t2", "$t3", "$t4", 25), + round1!("$t4", "$t0", "$t1", "$t2", "$t3", 26), + round1!("$t3", "$t4", "$t0", "$t1", "$t2", 27), + round1!("$t2", "$t3", "$t4", "$t0", "$t1", 28), + round1!("$t1", "$t2", "$t3", "$t4", "$t0", 29), + round1!("$t0", "$t1", "$t2", "$t3", "$t4", 30), + round1!("$t4", "$t0", "$t1", "$t2", "$t3", 31), + round1!("$t3", "$t4", "$t0", "$t1", "$t2", 32), + round1!("$t2", "$t3", "$t4", "$t0", "$t1", 33), + round1!("$t1", "$t2", "$t3", "$t4", "$t0", 34), + round1!("$t0", "$t1", "$t2", "$t3", "$t4", 35), + round1!("$t4", "$t0", "$t1", "$t2", "$t3", 36), + round1!("$t3", "$t4", "$t0", "$t1", "$t2", 37), + round1!("$t2", "$t3", "$t4", "$t0", "$t1", 38), + round1!("$t1", "$t2", "$t3", "$t4", "$t0", 39), + round2!("$t0", "$t1", "$t2", "$t3", "$t4", 40), + round2!("$t4", "$t0", "$t1", "$t2", "$t3", 41), + round2!("$t3", "$t4", "$t0", "$t1", "$t2", 42), + round2!("$t2", "$t3", "$t4", "$t0", "$t1", 43), + round2!("$t1", "$t2", "$t3", "$t4", "$t0", 44), + round2!("$t0", "$t1", "$t2", "$t3", "$t4", 45), + round2!("$t4", "$t0", "$t1", "$t2", "$t3", 46), + round2!("$t3", "$t4", "$t0", "$t1", "$t2", 47), + round2!("$t2", "$t3", "$t4", "$t0", "$t1", 48), + round2!("$t1", "$t2", "$t3", "$t4", "$t0", 49), + round2!("$t0", "$t1", "$t2", "$t3", "$t4", 50), + round2!("$t4", "$t0", "$t1", "$t2", "$t3", 51), + round2!("$t3", "$t4", "$t0", "$t1", "$t2", 52), + round2!("$t2", "$t3", "$t4", "$t0", "$t1", 53), + round2!("$t1", "$t2", "$t3", "$t4", "$t0", 54), + round2!("$t0", "$t1", "$t2", "$t3", "$t4", 55), + round2!("$t4", "$t0", "$t1", "$t2", "$t3", 56), + round2!("$t3", "$t4", "$t0", "$t1", "$t2", 57), + round2!("$t2", "$t3", "$t4", "$t0", "$t1", 58), + round2!("$t1", "$t2", "$t3", "$t4", "$t0", 59), + round3!("$t0", "$t1", "$t2", "$t3", "$t4", 60), + round3!("$t4", "$t0", "$t1", "$t2", "$t3", 61), + round3!("$t3", "$t4", "$t0", "$t1", "$t2", 62), + round3!("$t2", "$t3", "$t4", "$t0", "$t1", 63), + round3!("$t1", "$t2", "$t3", "$t4", "$t0", 64), + round3!("$t0", "$t1", "$t2", "$t3", "$t4", 65), + round3!("$t4", "$t0", "$t1", "$t2", "$t3", 66), + round3!("$t3", "$t4", "$t0", "$t1", "$t2", 67), + round3!("$t2", "$t3", "$t4", "$t0", "$t1", 68), + round3!("$t1", "$t2", "$t3", "$t4", "$t0", 69), + round3!("$t0", "$t1", "$t2", "$t3", "$t4", 70), + round3!("$t4", "$t0", "$t1", "$t2", "$t3", 71), + round3!("$t3", "$t4", "$t0", "$t1", "$t2", 72), + round3!("$t2", "$t3", "$t4", "$t0", "$t1", 73), + round3!("$t1", "$t2", "$t3", "$t4", "$t0", 74), + round3!("$t0", "$t1", "$t2", "$t3", "$t4", 75), + round3!("$t4", "$t0", "$t1", "$t2", "$t3", 76), + round3!("$t3", "$t4", "$t0", "$t1", "$t2", 77), + round3!("$t2", "$t3", "$t4", "$t0", "$t1", 78), + round3!("$t1", "$t2", "$t3", "$t4", "$t0", 79), + + // Update state registers + "ld.w $t5, $a0, 0", // a + "ld.w $t6, $a0, 4", // b + "ld.w $t7, $a0, 8", // c + "ld.w $t8, $a0, 12", // d + "add.w $t0, $t0, $t5", + "ld.w $t5, $a0, 16", // e + "add.w $t1, $t1, $t6", + "add.w $t2, $t2, $t7", + "add.w $t3, $t3, $t8", + "add.w $t4, $t4, $t5", + + // Save updated state + "st.w $t0, $a0, 0", + "st.w $t1, $a0, 4", + "st.w $t2, $a0, 8", + "st.w $t3, $a0, 12", + "st.w $t4, $a0, 16", + + // Looping over blocks + "addi.d $a1, $a1, 64", + "addi.d $a2, $a2, -1", + "bnez $a2, 42b", + + // Restore stack register + "addi.d $sp, $sp, 64", + + in("$a0") state, + inout("$a1") blocks.as_ptr() => _, + inout("$a2") blocks.len() => _, + + in("$a4") K[0], + in("$a5") K[1], + in("$a6") K[2], + in("$a7") K[3], + + // Clobbers + out("$t0") _, + out("$t1") _, + out("$t2") _, + out("$t3") _, + out("$t4") _, + out("$t5") _, + out("$t6") _, + out("$t7") _, + out("$t8") _, + + options(preserves_flags), + ); + } +} diff --git a/vendor/sha1/src/lib.rs b/vendor/sha1/src/lib.rs index e5fbf2a7b..38ddc4b51 100644 --- a/vendor/sha1/src/lib.rs +++ b/vendor/sha1/src/lib.rs @@ -33,12 +33,12 @@ //! //! This crate has been transferred to the RustCrypto organization and uses //! implementation previously published as the `sha-1` crate. The previous -//! zero dependencies version is now published as the [`sha1_smoll`] crate. +//! zero dependencies version is now published as the [`sha1_smol`] crate. //! //! [1]: https://en.wikipedia.org/wiki/SHA-1 //! [2]: https://sha-mbles.github.io/ //! [3]: https://github.com/RustCrypto/hashes -//! [`sha1_smoll`]: https://github.com/mitsuhiko/sha1-smol/ +//! [`sha1_smol`]: https://github.com/mitsuhiko/sha1-smol/ #![no_std] #![cfg_attr(docsrs, feature(doc_cfg))] |