diff --git a/Cargo.lock b/Cargo.lock index ca5e1d309..52fcb644d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,9 +2,43 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ascon" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e716048a18530cce4684daf98a7563a499d710e1ed8ef35567fcb43a7c5f1" +dependencies = [ + "zeroize", +] + +[[package]] +name = "ascon-hash" +version = "0.3.0-pre" +dependencies = [ + "ascon", + "digest", + "hex", + "spectral", +] + +[[package]] +name = "belt-block" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9aa1eef3994e2ccd304a78fe3fea4a73e5792007f85f09b79bb82143ca5f82b" + +[[package]] +name = "belt-hash" +version = "0.2.0-pre" +dependencies = [ + "belt-block", + "digest", + "hex-literal", +] + [[package]] name = "blake2" -version = "0.10.6" +version = "0.11.0-pre" dependencies = [ "digest", "hex-literal", @@ -18,11 +52,11 @@ checksum = "847495c209977a90e8aad588b959d0ca9f5dc228096d29a6bd3defd53f35eaec" [[package]] name = "block-buffer" -version = "0.10.4" +version = "0.11.0-pre.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +checksum = "0a601d94c4c47c51a046b82b883fe236e5750c0da327dd1427c8b4416296418a" dependencies = [ - "generic-array", + "crypto-common", ] [[package]] @@ -57,19 +91,19 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.2.0-pre.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "102f7900795d54e3b8566857762a2977c267ab5952e4117283017ee1d5c9ae88" dependencies = [ - "generic-array", - "typenum", + "getrandom", + "hybrid-array", + "rand_core", ] [[package]] name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +version = "0.11.0-pre" +source = "git+https://github.com/RustCrypto/traits.git#6810dc1dcfe9949f2f2e8e6f3e077737b97c06f1" dependencies = [ "blobby", "block-buffer", @@ -80,7 +114,7 @@ dependencies = [ [[package]] name = "fsb" -version = "0.1.3" +version = "0.2.0-pre" dependencies = [ "digest", "hex-literal", @@ -88,18 +122,19 @@ dependencies = [ ] [[package]] -name = "generic-array" -version = "0.14.7" +name = "getrandom" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ - "typenum", - "version_check", + "cfg-if", + "libc", + "wasi", ] [[package]] name = "gost94" -version = "0.10.4" +version = "0.11.0-pre" dependencies = [ "digest", "hex-literal", @@ -107,29 +142,48 @@ dependencies = [ [[package]] name = "groestl" -version = "0.10.1" +version = "0.11.0-pre" dependencies = [ "digest", "hex-literal", ] +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "hex-literal" -version = "0.2.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d70693199b3cf4552f3fa720b54163927a3ebed2aef240efaf556033ab336a11" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "hybrid-array" +version = "0.2.0-pre.7" +source = "git+https://github.com/RustCrypto/utils.git#55a93f1163153b494b7c78d3a2fe2a8da5c48121" dependencies = [ - "hex-literal-impl", - "proc-macro-hack", + "typenum", ] [[package]] -name = "hex-literal-impl" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59448fc2f82a5fb6907f78c3d69d843e82ff5b051923313cc4438cb0c7b745a8" +name = "jh" +version = "0.2.0-pre" +dependencies = [ + "digest", + "hex-literal", + "ppv-lite86", +] + +[[package]] +name = "k12" +version = "0.4.0-pre" dependencies = [ - "proc-macro-hack", + "digest", + "hex-literal", + "sha3", ] [[package]] @@ -149,7 +203,7 @@ checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "md-5" -version = "0.10.6" +version = "0.11.0-pre" dependencies = [ "cfg-if", "digest", @@ -159,7 +213,7 @@ dependencies = [ [[package]] name = "md2" -version = "0.10.2" +version = "0.11.0-pre" dependencies = [ "digest", "hex-literal", @@ -167,7 +221,7 @@ dependencies = [ [[package]] name = "md4" -version = "0.10.2" +version = "0.11.0-pre" dependencies = [ "digest", "hex-literal", @@ -183,14 +237,23 @@ dependencies = [ ] [[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" +name = "ppv-lite86" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] [[package]] name = "ripemd" -version = "0.1.3" +version = "0.2.0-pre" dependencies = [ "digest", "hex-literal", @@ -198,7 +261,7 @@ dependencies = [ [[package]] name = "sha1" -version = "0.10.6" +version = "0.11.0-pre" dependencies = [ "cfg-if", "cpufeatures", @@ -218,7 +281,7 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.8" +version = "0.11.0-pre" dependencies = [ "cfg-if", "cpufeatures", @@ -238,7 +301,7 @@ dependencies = [ [[package]] name = "sha3" -version = "0.10.8" +version = "0.11.0-pre" dependencies = [ "digest", "hex-literal", @@ -248,23 +311,38 @@ dependencies = [ [[package]] name = "shabal" -version = "0.4.1" +version = "0.5.0-pre" +dependencies = [ + "digest", + "hex-literal", +] + +[[package]] +name = "skein" +version = "0.2.0-pre" dependencies = [ "digest", "hex-literal", + "threefish", ] [[package]] name = "sm3" -version = "0.4.2" +version = "0.5.0-pre" dependencies = [ "digest", "hex-literal", ] +[[package]] +name = "spectral" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3c15181f4b14e52eeaac3efaeec4d2764716ce9c86da0c934c3e318649c5ba" + [[package]] name = "streebog" -version = "0.10.2" +version = "0.11.0-pre" dependencies = [ "digest", "hex-literal", @@ -276,9 +354,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "threefish" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a693d0c8cf16973fac5a93fbe47b8c6452e7097d4fcac49f3d7a18e39c76e62e" + [[package]] name = "tiger" -version = "0.2.1" +version = "0.3.0-pre" dependencies = [ "digest", "hex-literal", @@ -291,14 +375,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] -name = "version_check" -version = "0.9.4" +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "whirlpool" -version = "0.10.4" +version = "0.11.0-pre" dependencies = [ "digest", "hex-literal", diff --git a/Cargo.toml b/Cargo.toml index 790a09c7f..fc511445a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,14 @@ [workspace] -# This causes issues like https://github.com/RustCrypto/hashes/issues/396 -# Do not uncomment it until MSRV is bumped to 1.51 or higher. -# resolver = "2" +resolver = "2" members = [ + "ascon-hash", + "belt-hash", "blake2", "fsb", "gost94", "groestl", + "jh", + "k12", "md2", "md4", "md5", @@ -15,18 +17,16 @@ members = [ "sha2", "sha3", "shabal", + "skein", "sm3", "streebog", "tiger", "whirlpool", ] -exclude = [ - "ascon-hash", - "belt-hash", - "jh", - "k12", - "skein", -] [profile.dev] opt-level = 2 + +[patch.crates-io] +digest = { git = "https://github.com/RustCrypto/traits.git" } +hybrid-array = { git = "https://github.com/RustCrypto/utils.git" } diff --git a/ascon-hash/Cargo.toml b/ascon-hash/Cargo.toml index cb3707cc7..bdb82154e 100644 --- a/ascon-hash/Cargo.toml +++ b/ascon-hash/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ascon-hash" -version = "0.2.0" +version = "0.3.0-pre" description = "Implementation of the Ascon and AsconA hashes and XOFs" authors = [ "Sebastian Ramacher ", @@ -13,12 +13,10 @@ documentation = "https://docs.rs/ascon-hash" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "hash", "ascon"] categories = ["cryptography", "no-std"] -rust-version = "1.56" - -[workspace] +rust-version = "1.65" [dependencies] -digest = { version = "0.10", default-features = false, features = ["core-api"] } +digest = { version = "=0.11.0-pre", default-features = false, features = ["core-api"] } ascon = { version = "0.4", default-features = false } [dev-dependencies] diff --git a/belt-hash/Cargo.toml b/belt-hash/Cargo.toml index a104a1810..e466d16c4 100644 --- a/belt-hash/Cargo.toml +++ b/belt-hash/Cargo.toml @@ -1,30 +1,26 @@ [package] name = "belt-hash" -version = "0.1.1" +version = "0.2.0-pre" description = "BelT hash function (STB 34.101.31-2020)" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" edition = "2021" -rust-version = "1.57" +rust-version = "1.65" documentation = "https://docs.rs/belt-hash" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "belt", "stb", "hash", "digest"] categories = ["cryptography", "no-std"] [dependencies] -digest = "0.10.4" +digest = "=0.11.0-pre" belt-block = { version = "0.1.1", default-features = false } [dev-dependencies] -digest = { version = "0.10.4", features = ["dev"] } -hex-literal = "0.3.3" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] std = ["digest/std"] oid = ["digest/oid"] - -# TODO: remove when crate will be part of the root workspace -[profile.dev] -opt-level = 2 diff --git a/belt-hash/src/lib.rs b/belt-hash/src/lib.rs index 29b9fbad8..e92dfc6bb 100644 --- a/belt-hash/src/lib.rs +++ b/belt-hash/src/lib.rs @@ -13,7 +13,7 @@ //! // process input message //! hasher.update(b"hello world"); //! -//! // acquire hash digest in the form of GenericArray, +//! // acquire hash digest in the form of Array, //! // which in this case is equivalent to [u8; 32] //! let result = hasher.finalize(); //! let expected = hex!( @@ -111,7 +111,7 @@ impl FixedOutputCore for BeltHashCore { let pos = buffer.get_pos(); if pos != 0 { let block = buffer.pad_with_zeros(); - self.compress_block(block); + self.compress_block(&block); } let bs = Self::BlockSize::USIZE as u128; let r = encode_r(8 * ((bs * self.r) + pos as u128)); diff --git a/blake2/Cargo.toml b/blake2/Cargo.toml index adb06e061..810a086b9 100644 --- a/blake2/Cargo.toml +++ b/blake2/Cargo.toml @@ -1,22 +1,23 @@ [package] name = "blake2" -version = "0.10.6" +version = "0.11.0-pre" description = "BLAKE2 hash functions" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/blake2" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "blake2", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = { version = "0.10.7", features = ["mac"] } +digest = { version = "=0.11.0-pre", features = ["mac"] } [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/blake2/src/lib.rs b/blake2/src/lib.rs index 85a6b1c28..783c27a2d 100644 --- a/blake2/src/lib.rs +++ b/blake2/src/lib.rs @@ -92,7 +92,7 @@ use digest::{ VariableOutputCore, }, crypto_common::{InvalidLength, Key, KeyInit, KeySizeUser}, - generic_array::{ArrayLength, GenericArray}, + array::{ArraySize, Array}, typenum::{IsLessOrEqual, LeEq, NonZero, Unsigned}, FixedOutput, HashMarker, InvalidOutputSize, MacMarker, Output, Update, }; diff --git a/blake2/src/macros.rs b/blake2/src/macros.rs index 917a212c8..bf92d5039 100644 --- a/blake2/src/macros.rs +++ b/blake2/src/macros.rs @@ -44,8 +44,7 @@ macro_rules! blake2_impl { // salt is two words long if salt.len() < length { - let mut padded_salt = - GenericArray::>::Output>::default(); + let mut padded_salt = Array::>::Output>::default(); for i in 0..salt.len() { padded_salt[i] = salt[i]; } @@ -63,8 +62,7 @@ macro_rules! blake2_impl { // persona is also two words long if persona.len() < length { - let mut padded_persona = - GenericArray::>::Output>::default(); + let mut padded_persona = Array::>::Output>::default(); for i in 0..persona.len() { padded_persona[i] = persona[i]; } @@ -95,7 +93,7 @@ macro_rules! blake2_impl { fn finalize_with_flag( &mut self, - final_block: &GenericArray, + final_block: &Array, flag: $word, out: &mut Output, ) { @@ -224,7 +222,7 @@ macro_rules! blake2_impl { ) { self.t += buffer.get_pos() as u64; let block = buffer.pad_with_zeros(); - self.finalize_with_flag(block, 0, out); + self.finalize_with_flag(&block, 0, out); } } @@ -259,7 +257,7 @@ macro_rules! blake2_mac_impl { #[doc=$doc] pub struct $name where - OutSize: ArrayLength + IsLessOrEqual<$max_size>, + OutSize: ArraySize + IsLessOrEqual<$max_size>, LeEq: NonZero, { core: $hash, @@ -271,7 +269,7 @@ macro_rules! blake2_mac_impl { impl $name where - OutSize: ArrayLength + IsLessOrEqual<$max_size>, + OutSize: ArraySize + IsLessOrEqual<$max_size>, LeEq: NonZero, { /// Create new instance using provided key, salt, and persona. @@ -309,7 +307,7 @@ macro_rules! blake2_mac_impl { impl KeySizeUser for $name where - OutSize: ArrayLength + IsLessOrEqual<$max_size>, + OutSize: ArraySize + IsLessOrEqual<$max_size>, LeEq: NonZero, { type KeySize = $max_size; @@ -317,7 +315,7 @@ macro_rules! blake2_mac_impl { impl KeyInit for $name where - OutSize: ArrayLength + IsLessOrEqual<$max_size>, + OutSize: ArraySize + IsLessOrEqual<$max_size>, LeEq: NonZero, { #[inline] @@ -349,7 +347,7 @@ macro_rules! blake2_mac_impl { impl Update for $name where - OutSize: ArrayLength + IsLessOrEqual<$max_size>, + OutSize: ArraySize + IsLessOrEqual<$max_size>, LeEq: NonZero, { #[inline] @@ -361,7 +359,7 @@ macro_rules! blake2_mac_impl { impl OutputSizeUser for $name where - OutSize: ArrayLength + IsLessOrEqual<$max_size> + 'static, + OutSize: ArraySize + IsLessOrEqual<$max_size> + 'static, LeEq: NonZero, { type OutputSize = OutSize; @@ -369,7 +367,7 @@ macro_rules! blake2_mac_impl { impl FixedOutput for $name where - OutSize: ArrayLength + IsLessOrEqual<$max_size> + 'static, + OutSize: ArraySize + IsLessOrEqual<$max_size> + 'static, LeEq: NonZero, { #[inline] @@ -384,7 +382,7 @@ macro_rules! blake2_mac_impl { #[cfg(feature = "reset")] impl Reset for $name where - OutSize: ArrayLength + IsLessOrEqual<$max_size>, + OutSize: ArraySize + IsLessOrEqual<$max_size>, LeEq: NonZero, { fn reset(&mut self) { @@ -399,7 +397,7 @@ macro_rules! blake2_mac_impl { #[cfg(feature = "reset")] impl FixedOutputReset for $name where - OutSize: ArrayLength + IsLessOrEqual<$max_size>, + OutSize: ArraySize + IsLessOrEqual<$max_size>, LeEq: NonZero, { #[inline] @@ -414,14 +412,14 @@ macro_rules! blake2_mac_impl { impl MacMarker for $name where - OutSize: ArrayLength + IsLessOrEqual<$max_size>, + OutSize: ArraySize + IsLessOrEqual<$max_size>, LeEq: NonZero, { } impl fmt::Debug for $name where - OutSize: ArrayLength + IsLessOrEqual<$max_size>, + OutSize: ArraySize + IsLessOrEqual<$max_size>, LeEq: NonZero, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/blake2/tests/mac.rs b/blake2/tests/mac.rs index dd75a5703..44c3244f3 100644 --- a/blake2/tests/mac.rs +++ b/blake2/tests/mac.rs @@ -8,15 +8,15 @@ new_test!(blake2s_mac, "blake2s/mac", blake2::Blake2sMac256); #[test] fn blake2b_new_test() { - use blake2::digest::{generic_array::GenericArray, KeyInit, Mac}; + use blake2::digest::{array::Array, KeyInit, Mac}; fn run(key: &[u8]) { const DATA: &[u8] = &[42; 300]; - let res1 = ::new(GenericArray::from_slice(key)) + let res1 = T::new(Array::ref_from_slice(key)) .chain_update(DATA) .finalize() .into_bytes(); - let res2 = ::new_from_slice(key) + let res2 = T::new_from_slice(key) .unwrap() .chain_update(DATA) .finalize() diff --git a/fsb/Cargo.toml b/fsb/Cargo.toml index 399cd970d..f57e88a7f 100644 --- a/fsb/Cargo.toml +++ b/fsb/Cargo.toml @@ -1,23 +1,24 @@ [package] name = "fsb" -version = "0.1.3" +version = "0.2.0-pre" description = "FSB hash function" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/fsb" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "fsb", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = "0.10.7" -whirlpool = { version = "0.10.1", path = "../whirlpool", default-features = false } +digest = "=0.11.0-pre" +whirlpool = { version = "=0.11.0-pre", path = "../whirlpool", default-features = false } [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/gost94/Cargo.toml b/gost94/Cargo.toml index 7fa75ab7f..d4885d410 100644 --- a/gost94/Cargo.toml +++ b/gost94/Cargo.toml @@ -1,22 +1,23 @@ [package] name = "gost94" -version = "0.10.4" +version = "0.11.0-pre" description = "GOST R 34.11-94 hash function" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/gost94" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "gost94", "gost", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = "0.10.7" +digest = "=0.11.0-pre" [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/gost94/src/lib.rs b/gost94/src/lib.rs index 1a55faa1e..f530a1bcc 100644 --- a/gost94/src/lib.rs +++ b/gost94/src/lib.rs @@ -11,7 +11,7 @@ //! // process input message //! hasher.update("The quick brown fox jumps over the lazy dog"); //! -//! // acquire hash digest in the form of GenericArray, +//! // acquire hash digest in the form of Array, //! // which in this case is equivalent to [u8; 32] //! let result = hasher.finalize(); //! assert_eq!(result[..], hex!(" diff --git a/groestl/Cargo.toml b/groestl/Cargo.toml index 87915c734..51b14260e 100644 --- a/groestl/Cargo.toml +++ b/groestl/Cargo.toml @@ -1,22 +1,23 @@ [package] name = "groestl" -version = "0.10.1" +version = "0.11.0-pre" description = "Grøstl hash function" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/groestl" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "groestl", "grostl", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = "0.10.7" +digest = "=0.11.0-pre" [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/groestl/src/lib.rs b/groestl/src/lib.rs index fce249751..730477f3d 100644 --- a/groestl/src/lib.rs +++ b/groestl/src/lib.rs @@ -12,7 +12,7 @@ //! // process input message //! hasher.update(b"my message"); //! -//! // acquire hash digest in the form of GenericArray, +//! // acquire hash digest in the form of Array, //! // which in this case is equivalent to [u8; 32] //! let result = hasher.finalize(); //! assert_eq!(result[..], hex!(" diff --git a/jh/Cargo.toml b/jh/Cargo.toml index 28e8f539d..5b0f8ead2 100644 --- a/jh/Cargo.toml +++ b/jh/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jh" -version = "0.1.0" +version = "0.2.0-pre" description = "Pure Rust implementation of the JH cryptographic hash function" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" @@ -13,9 +13,9 @@ keywords = ["crypto", "jh", "hash", "digest"] categories = ["cryptography", "no-std"] [dependencies] -digest = "0.10" +digest = "=0.11.0-pre" hex-literal = "0.4" simd = { package = "ppv-lite86", version = "0.2.6" } [dev-dependencies] -digest = { version = "0.10", features = ["dev"] } +digest = { version = "=0.11.0-pre", features = ["dev"] } diff --git a/jh/src/compressor.rs b/jh/src/compressor.rs index f75cde8a0..a1b2ea2ac 100644 --- a/jh/src/compressor.rs +++ b/jh/src/compressor.rs @@ -1,7 +1,7 @@ #![allow(non_upper_case_globals)] use core::ptr; -use digest::generic_array::{typenum::U64, GenericArray}; +use digest::array::{typenum::U64, Array}; use simd::{dispatch, vec128_storage, AndNot, Machine, Swap64, VZip, Vec2}; #[rustfmt::skip] @@ -167,7 +167,7 @@ impl Compressor { } #[inline] - pub(crate) fn update(&mut self, data: &GenericArray) { + pub(crate) fn update(&mut self, data: &Array) { f8(unsafe { &mut self.cv }, data.as_ptr()); } diff --git a/jh/src/lib.rs b/jh/src/lib.rs index 9dcea8940..8cc3aa1ec 100644 --- a/jh/src/lib.rs +++ b/jh/src/lib.rs @@ -55,7 +55,7 @@ use digest::{ TruncSide, UpdateCore, VariableOutputCore, }, crypto_common::{BlockSizeUser, OutputSizeUser}, - generic_array::typenum::{Unsigned, U28, U32, U48, U64}, + array::typenum::{Unsigned, U28, U32, U48, U64}, HashMarker, InvalidOutputSize, Output, }; diff --git a/k12/Cargo.toml b/k12/Cargo.toml index f0679ea53..1d800ccf1 100644 --- a/k12/Cargo.toml +++ b/k12/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "k12" -version = "0.3.0" +version = "0.4.0-pre" description = "Pure Rust implementation of the KangarooTwelve hash function" authors = ["RustCrypto Developers", "Diggory Hardy "] license = "Apache-2.0 OR MIT" @@ -10,20 +10,16 @@ documentation = "https://docs.rs/k12" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "hash", "digest"] categories = ["cryptography", "no-std"] -rust-version = "1.56" +rust-version = "1.65" [dependencies] -digest = { version = "0.10.7", default-features = false, features = ["core-api"] } -sha3 = { version = "0.10.8", default-features = false } +digest = { version = "=0.11.0-pre", default-features = false, features = ["core-api"] } +sha3 = { version = "=0.11.0-pre", default-features = false, path = "../sha3" } [dev-dependencies] -digest = { version = "0.10.7", features = ["alloc", "dev"] } -hex-literal = "0.3" +digest = { version = "=0.11.0-pre", features = ["alloc", "dev"] } +hex-literal = "0.4" [features] default = ["std"] std = ["digest/std"] - -# TODO: remove when crate will be part of the root workspace -[profile.dev] -opt-level = 2 diff --git a/md2/Cargo.toml b/md2/Cargo.toml index 679594a26..c6734234a 100644 --- a/md2/Cargo.toml +++ b/md2/Cargo.toml @@ -1,22 +1,23 @@ [package] name = "md2" -version = "0.10.2" +version = "0.11.0-pre" license = "MIT OR Apache-2.0" authors = ["RustCrypto Developers"] description = "MD2 hash function" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/md2" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "md2", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = "0.10.7" +digest = "=0.11.0-pre" [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/md2/src/lib.rs b/md2/src/lib.rs index 9ab2750b1..7beb7effe 100644 --- a/md2/src/lib.rs +++ b/md2/src/lib.rs @@ -12,7 +12,7 @@ //! // process input message //! hasher.update(b"hello world"); //! -//! // acquire hash digest in the form of GenericArray, +//! // acquire hash digest in the form of Array, //! // which in this case is equivalent to [u8; 16] //! let result = hasher.finalize(); //! assert_eq!(result[..], hex!("d9cce882ee690a5c1ce70beff3a78c77")); @@ -109,10 +109,10 @@ impl FixedOutputCore for Md2Core { fn finalize_fixed_core(&mut self, buffer: &mut Buffer, out: &mut Output) { let pos = buffer.get_pos(); let rem = buffer.remaining() as u8; - let block = buffer.pad_with_zeros(); + let mut block = buffer.pad_with_zeros(); block[pos..].iter_mut().for_each(|b| *b = rem); - self.compress(block); + self.compress(&block); let checksum = self.checksum; self.compress(&checksum); out.copy_from_slice(&self.x[0..16]); diff --git a/md4/Cargo.toml b/md4/Cargo.toml index b55aa5fd9..a5d1ec1e6 100644 --- a/md4/Cargo.toml +++ b/md4/Cargo.toml @@ -1,22 +1,23 @@ [package] name = "md4" -version = "0.10.2" +version = "0.11.0-pre" description = "MD4 hash function" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/md4" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "md4", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = "0.10.7" +digest = "=0.11.0-pre" [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/md4/src/lib.rs b/md4/src/lib.rs index 8ef33aee8..acceb0e32 100644 --- a/md4/src/lib.rs +++ b/md4/src/lib.rs @@ -12,7 +12,7 @@ //! // process input message //! hasher.update(b"hello world"); //! -//! // acquire hash digest in the form of GenericArray, +//! // acquire hash digest in the form of Array, //! // which in this case is equivalent to [u8; 16] //! let result = hasher.finalize(); //! assert_eq!(result[..], hex!("aa010fbc1d14c795d86ef98c95479d17")); diff --git a/md5/Cargo.toml b/md5/Cargo.toml index 8103cd8a4..1d1111ce3 100644 --- a/md5/Cargo.toml +++ b/md5/Cargo.toml @@ -1,29 +1,30 @@ [package] name = "md-5" -version = "0.10.6" +version = "0.11.0-pre" description = "MD5 hash function" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/md-5" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "md5", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [lib] name = "md5" [dependencies] -digest = "0.10.7" -cfg-if = "1.0" +digest = "=0.11.0-pre" +cfg-if = "1" [target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))'.dependencies] md5-asm = { version = "0.5", optional = true } [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/md5/src/lib.rs b/md5/src/lib.rs index a45de2f11..59f5b84d4 100644 --- a/md5/src/lib.rs +++ b/md5/src/lib.rs @@ -12,7 +12,7 @@ //! // process input message //! hasher.update(b"hello world"); //! -//! // acquire hash digest in the form of GenericArray, +//! // acquire hash digest in the form of Array, //! // which in this case is equivalent to [u8; 16] //! let result = hasher.finalize(); //! assert_eq!(result[..], hex!("5eb63bbbe01eeed093cb22bb8f5acdc3")); @@ -137,7 +137,7 @@ const BLOCK_SIZE: usize = ::BlockSize::USIZE; #[inline(always)] fn convert(blocks: &[Block]) -> &[[u8; BLOCK_SIZE]] { - // SAFETY: GenericArray and [u8; 64] have + // SAFETY: Array and [u8; 64] have // exactly the same memory layout let p = blocks.as_ptr() as *const [u8; BLOCK_SIZE]; unsafe { core::slice::from_raw_parts(p, blocks.len()) } diff --git a/ripemd/Cargo.toml b/ripemd/Cargo.toml index 88c69aa28..976758595 100644 --- a/ripemd/Cargo.toml +++ b/ripemd/Cargo.toml @@ -1,22 +1,23 @@ [package] name = "ripemd" -version = "0.1.3" +version = "0.2.0-pre" description = "Pure Rust implementation of the RIPEMD hash functions" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/ripemd" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "ripemd", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = "0.10.7" +digest = "=0.11.0-pre" [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/ripemd/src/lib.rs b/ripemd/src/lib.rs index 1a28ed76b..5bb19b977 100644 --- a/ripemd/src/lib.rs +++ b/ripemd/src/lib.rs @@ -18,7 +18,7 @@ //! // process input message //! hasher.update(b"Hello world!"); //! -//! // acquire hash digest in the form of GenericArray, +//! // acquire hash digest in the form of Array, //! // which in this case is equivalent to [u8; 20] //! let result = hasher.finalize(); //! assert_eq!(result[..], hex!("7f772647d88750add82d8e1a7a3e5c0902a346a3")); diff --git a/ripemd/tests/mod.rs b/ripemd/tests/mod.rs index 0dd16b0cf..96d3c0086 100644 --- a/ripemd/tests/mod.rs +++ b/ripemd/tests/mod.rs @@ -18,10 +18,7 @@ fn ripemd128_1mil_a() { for _ in 0..1000 { h.update(&buf[..]); } - assert_eq!( - h.finalize(), - hex!("4a7f5723f954eba1216c9d8f6320431f").into() - ); + assert_eq!(h.finalize(), hex!("4a7f5723f954eba1216c9d8f6320431f")); } #[test] @@ -43,7 +40,7 @@ fn ripemd160_1mil_a() { } assert_eq!( h.finalize(), - hex!("52783243c1697bdbe16d37f97f68f08325dc1528").into() + hex!("52783243c1697bdbe16d37f97f68f08325dc1528") ); } @@ -66,7 +63,7 @@ fn ripemd256_1mil_a() { } assert_eq!( h.finalize(), - hex!("ac953744e10e31514c150d4d8d7b677342e33399788296e43ae4850ce4f97978").into() + hex!("ac953744e10e31514c150d4d8d7b677342e33399788296e43ae4850ce4f97978") ); } @@ -93,7 +90,7 @@ fn ripemd320_1mil_a() { hex!(" bdee37f4371e20646b8b0d862dda16292ae36f40 965e8c8509e63d1dbddecc503e2b63eb9245bb66 - ").into() + ") ); } diff --git a/sha1/Cargo.toml b/sha1/Cargo.toml index 3f4b8d3ff..2de7c838e 100644 --- a/sha1/Cargo.toml +++ b/sha1/Cargo.toml @@ -1,18 +1,19 @@ [package] name = "sha1" -version = "0.10.6" +version = "0.11.0-pre" description = "SHA-1 hash function" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/sha1" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "sha1", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = "0.10.7" +digest = "=0.11.0-pre" cfg-if = "1.0" [target.'cfg(any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64"))'.dependencies] @@ -20,8 +21,8 @@ cpufeatures = "0.2" sha1-asm = { version = "0.5", optional = true } [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/sha1/src/compress.rs b/sha1/src/compress.rs index 6f7e40c41..f2bd14426 100644 --- a/sha1/src/compress.rs +++ b/sha1/src/compress.rs @@ -32,7 +32,7 @@ const BLOCK_SIZE: usize = ::BlockSize::USIZE; /// SHA-1 compression function #[cfg_attr(docsrs, doc(cfg(feature = "compress")))] pub fn compress(state: &mut [u32; 5], blocks: &[Block]) { - // SAFETY: GenericArray and [u8; 64] have + // SAFETY: Array and [u8; 64] have // exactly the same memory layout let blocks: &[[u8; BLOCK_SIZE]] = unsafe { &*(blocks as *const _ as *const [[u8; BLOCK_SIZE]]) }; diff --git a/sha1/src/lib.rs b/sha1/src/lib.rs index 25e867e0f..5ea8de75e 100644 --- a/sha1/src/lib.rs +++ b/sha1/src/lib.rs @@ -33,7 +33,7 @@ //! // process input message //! hasher.update(b"hello world"); //! -//! // acquire hash digest in the form of GenericArray, +//! // acquire hash digest in the form of Array, //! // which in this case is equivalent to [u8; 20] //! let result = hasher.finalize(); //! assert_eq!(result[..], hex!("2aae6c35c94fcfb415dbe95f408b9ce91ee846ed")); diff --git a/sha2/Cargo.toml b/sha2/Cargo.toml index a3dafeaa2..086a4966a 100644 --- a/sha2/Cargo.toml +++ b/sha2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sha2" -version = "0.10.8" +version = "0.11.0-pre" description = """ Pure Rust implementation of the SHA-2 hash function family including SHA-224, SHA-256, SHA-384, and SHA-512. @@ -8,23 +8,24 @@ including SHA-224, SHA-256, SHA-384, and SHA-512. authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/sha2" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "sha2", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = "0.10.7" -cfg-if = "1.0" +digest = "=0.11.0-pre" +cfg-if = "1" [target.'cfg(any(target_arch = "aarch64", target_arch = "x86_64", target_arch = "x86"))'.dependencies] cpufeatures = "0.2" sha2-asm = { version = "0.6.1", optional = true } [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/sha2/src/sha256.rs b/sha2/src/sha256.rs index 8f8287836..7266137f0 100644 --- a/sha2/src/sha256.rs +++ b/sha2/src/sha256.rs @@ -1,4 +1,4 @@ -use digest::{generic_array::GenericArray, typenum::U64}; +use digest::{array::Array, typenum::U64}; cfg_if::cfg_if! { if #[cfg(feature = "force-soft")] { @@ -31,8 +31,8 @@ cfg_if::cfg_if! { /// This is a low-level "hazmat" API which provides direct access to the core /// functionality of SHA-256. #[cfg_attr(docsrs, doc(cfg(feature = "compress")))] -pub fn compress256(state: &mut [u32; 8], blocks: &[GenericArray]) { - // SAFETY: GenericArray and [u8; 64] have +pub fn compress256(state: &mut [u32; 8], blocks: &[Array]) { + // SAFETY: Array and [u8; 64] have // exactly the same memory layout let p = blocks.as_ptr() as *const [u8; 64]; let blocks = unsafe { core::slice::from_raw_parts(p, blocks.len()) }; diff --git a/sha2/src/sha512.rs b/sha2/src/sha512.rs index dfe0b454f..5c3590cf3 100644 --- a/sha2/src/sha512.rs +++ b/sha2/src/sha512.rs @@ -1,4 +1,4 @@ -use digest::{generic_array::GenericArray, typenum::U128}; +use digest::{array::Array, typenum::U128}; cfg_if::cfg_if! { if #[cfg(feature = "force-soft")] { @@ -33,8 +33,8 @@ cfg_if::cfg_if! { /// This is a low-level "hazmat" API which provides direct access to the core /// functionality of SHA-512. #[cfg_attr(docsrs, doc(cfg(feature = "compress")))] -pub fn compress512(state: &mut [u64; 8], blocks: &[GenericArray]) { - // SAFETY: GenericArray and [u8; 64] have +pub fn compress512(state: &mut [u64; 8], blocks: &[Array]) { + // SAFETY: Array and [u8; 64] have // exactly the same memory layout let p = blocks.as_ptr() as *const [u8; 128]; let blocks = unsafe { core::slice::from_raw_parts(p, blocks.len()) }; diff --git a/sha3/Cargo.toml b/sha3/Cargo.toml index 652630b5d..ba1ad4d6f 100644 --- a/sha3/Cargo.toml +++ b/sha3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sha3" -version = "0.10.8" +version = "0.11.0-pre" description = """ Pure Rust implementation of SHA-3, a family of Keccak-based hash functions including the SHAKE family of eXtendable-Output Functions (XOFs), as well as @@ -9,20 +9,21 @@ the accelerated variant TurboSHAKE authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/sha3" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "sha3", "keccak", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = "0.10.7" +digest = "=0.11.0-pre" keccak = "0.1.4" zeroize = { version = "1.6.0", default-features = false, optional=true } # WARNING: Bumps MSRV to 1.56 [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/sha3/src/lib.rs b/sha3/src/lib.rs index 0f87ee580..e2ab2c8af 100644 --- a/sha3/src/lib.rs +++ b/sha3/src/lib.rs @@ -79,7 +79,7 @@ use digest::{ ExtendableOutputCore, FixedOutputCore, OutputSizeUser, Reset, UpdateCore, XofReaderCore, XofReaderCoreWrapper, }, - generic_array::typenum::Unsigned, + array::typenum::Unsigned, HashMarker, Output, }; diff --git a/sha3/src/macros.rs b/sha3/src/macros.rs index f26291305..b7e346c32 100644 --- a/sha3/src/macros.rs +++ b/sha3/src/macros.rs @@ -39,12 +39,12 @@ macro_rules! impl_sha3 { #[inline] fn finalize_fixed_core(&mut self, buffer: &mut Buffer, out: &mut Output) { let pos = buffer.get_pos(); - let block = buffer.pad_with_zeros(); + let mut block = buffer.pad_with_zeros(); block[pos] = $pad; let n = block.len(); block[n - 1] |= 0x80; - self.state.absorb_block(block); + self.state.absorb_block(&block); self.state.as_bytes(out); } @@ -135,12 +135,12 @@ macro_rules! impl_shake { #[inline] fn finalize_xof_core(&mut self, buffer: &mut Buffer) -> Self::ReaderCore { let pos = buffer.get_pos(); - let block = buffer.pad_with_zeros(); + let mut block = buffer.pad_with_zeros(); block[pos] = $pad; let n = block.len(); block[n - 1] |= 0x80; - self.state.absorb_block(block); + self.state.absorb_block(&block); $reader { state: self.state.clone(), } @@ -281,12 +281,12 @@ macro_rules! impl_turbo_shake { #[inline] fn finalize_xof_core(&mut self, buffer: &mut Buffer) -> Self::ReaderCore { let pos = buffer.get_pos(); - let block = buffer.pad_with_zeros(); + let mut block = buffer.pad_with_zeros(); block[pos] = self.domain_separation; let n = block.len(); block[n - 1] |= 0x80; - self.state.absorb_block(block); + self.state.absorb_block(&block); $reader { state: self.state.clone(), } @@ -424,10 +424,10 @@ macro_rules! impl_cshake { ); buffer.digest_blocks(customization, |blocks| { for block in blocks { - state.absorb_block(block); + state.absorb_block(&block); } }); - state.absorb_block(buffer.pad_with_zeros()); + state.absorb_block(&buffer.pad_with_zeros()); Self { padding: $cshake_pad, @@ -463,12 +463,12 @@ macro_rules! impl_cshake { #[inline] fn finalize_xof_core(&mut self, buffer: &mut Buffer) -> Self::ReaderCore { let pos = buffer.get_pos(); - let block = buffer.pad_with_zeros(); + let mut block = buffer.pad_with_zeros(); block[pos] = self.padding; let n = block.len(); block[n - 1] |= 0x80; - self.state.absorb_block(block); + self.state.absorb_block(&block); $reader { state: self.state.clone(), } diff --git a/shabal/Cargo.toml b/shabal/Cargo.toml index 87c0c3905..a1e4ba6d9 100644 --- a/shabal/Cargo.toml +++ b/shabal/Cargo.toml @@ -1,22 +1,23 @@ [package] name = "shabal" -version = "0.4.1" +version = "0.5.0-pre" description = "Shabal hash functions" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/shabal" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "shabal", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = "0.10.7" +digest = "=0.11.0-pre" [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/shabal/src/core_api.rs b/shabal/src/core_api.rs index 561117522..ce5df75df 100644 --- a/shabal/src/core_api.rs +++ b/shabal/src/core_api.rs @@ -1,18 +1,18 @@ use crate::consts; use core::{convert::TryInto, fmt, mem, num::Wrapping}; use digest::{ + array::Array, block_buffer::Eager, consts::U64, core_api::{ AlgorithmName, BlockSizeUser, Buffer, BufferKindUser, OutputSizeUser, TruncSide, UpdateCore, VariableOutputCore, }, - generic_array::GenericArray, HashMarker, InvalidOutputSize, Output, }; type BlockSize = U64; -type Block = GenericArray; +type Block = Array; type M = [Wrapping; 16]; /// Inner state of Shabal hash functions. @@ -216,10 +216,10 @@ impl VariableOutputCore for ShabalVarCore { #[inline] fn finalize_variable_core(&mut self, buffer: &mut Buffer, out: &mut Output) { let pos = buffer.get_pos(); - let block = buffer.pad_with_zeros(); + let mut block = buffer.pad_with_zeros(); block[pos] = 0x80; - let m = read_m(block); + let m = read_m(&block); self.add_m(&m); self.xor_w(); self.perm(&m); diff --git a/shabal/src/lib.rs b/shabal/src/lib.rs index 9329692bd..bb529aa4b 100644 --- a/shabal/src/lib.rs +++ b/shabal/src/lib.rs @@ -23,7 +23,7 @@ //! // process input message //! hasher.update(b"helloworld"); //! -//! // acquire hash digest in the form of GenericArray, +//! // acquire hash digest in the form of Array, //! // which in this case is equivalent to [u8; 32] //! let result = hasher.finalize(); //! assert_eq!(result[..], hex!(" diff --git a/skein/Cargo.toml b/skein/Cargo.toml index 5f1d59871..5e6e26be3 100644 --- a/skein/Cargo.toml +++ b/skein/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "skein" -version = "0.1.0" +version = "0.2.0-pre" description = "Skein hash functions" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.57" +rust-version = "1.65" readme = "README.md" documentation = "https://docs.rs/skein" repository = "https://github.com/RustCrypto/hashes" @@ -13,9 +13,9 @@ keywords = ["crypto", "skein", "hash", "digest"] categories = ["cryptography", "no-std"] [dependencies] -digest = "0.10" +digest = "=0.11.0-pre" threefish = { version = "0.5.2", default-features = false } [dev-dependencies] -digest = { version = "0.10", features = ["dev"] } +digest = { version = "=0.11.0-pre", features = ["dev"] } hex-literal = "0.4" diff --git a/skein/benches/skein1024.rs b/skein/benches/skein1024.rs index 2101cdb34..0baf12a6d 100644 --- a/skein/benches/skein1024.rs +++ b/skein/benches/skein1024.rs @@ -1,7 +1,7 @@ #![feature(test)] extern crate test; -use digest::{bench_update, generic_array::typenum::U128}; +use digest::{bench_update, array::typenum::U128}; use skein::Skein1024; use test::Bencher; diff --git a/skein/benches/skein256.rs b/skein/benches/skein256.rs index c2646fc79..0125dba6c 100644 --- a/skein/benches/skein256.rs +++ b/skein/benches/skein256.rs @@ -1,7 +1,7 @@ #![feature(test)] extern crate test; -use digest::{bench_update, generic_array::typenum::U32}; +use digest::{bench_update, array::typenum::U32}; use skein::Skein256; use test::Bencher; diff --git a/skein/benches/skein512.rs b/skein/benches/skein512.rs index 727db6989..99c20fbcf 100644 --- a/skein/benches/skein512.rs +++ b/skein/benches/skein512.rs @@ -1,7 +1,7 @@ #![feature(test)] extern crate test; -use digest::{bench_update, generic_array::typenum::U64}; +use digest::{bench_update, array::typenum::U64}; use skein::Skein512; use test::Bencher; diff --git a/skein/src/lib.rs b/skein/src/lib.rs index 6f6bcf76e..57a489034 100644 --- a/skein/src/lib.rs +++ b/skein/src/lib.rs @@ -46,13 +46,13 @@ pub use digest::{self, consts, Digest}; use core::{fmt, marker::PhantomData}; use digest::{ + array::{typenum::Unsigned, Array, ArraySize}, block_buffer::Lazy, consts::{U128, U32, U64}, core_api::{ AlgorithmName, Block, BlockSizeUser, Buffer, BufferKindUser, CoreWrapper, FixedOutputCore, OutputSizeUser, Reset, UpdateCore, }, - generic_array::{typenum::Unsigned, ArrayLength, GenericArray}, HashMarker, Output, }; use threefish::{Threefish1024, Threefish256, Threefish512}; @@ -76,13 +76,13 @@ macro_rules! define_hasher { #[doc = $alg_name] #[doc = " core hasher state"] #[derive(Clone)] - pub struct $name + 'static> { + pub struct $name { t: [u64; 2], x: [u64; <$state_bytes>::USIZE / 8], _pd: PhantomData, } - impl + 'static> $name { + impl $name { fn blank_state(t1: u64, x: [u64; <$state_bytes>::USIZE / 8]) -> Self { Self { t: [0, t1], @@ -91,11 +91,7 @@ macro_rules! define_hasher { } } - fn process_block( - &mut self, - block: &GenericArray, - byte_count_add: usize, - ) { + fn process_block(&mut self, block: &Array, byte_count_add: usize) { const STATE_WORDS: usize = <$state_bytes>::USIZE / 8; self.t[0] += byte_count_add as u64; @@ -116,21 +112,21 @@ macro_rules! define_hasher { } } - impl HashMarker for $name where N: ArrayLength + 'static {} + impl HashMarker for $name where N: ArraySize + 'static {} - impl + 'static> BlockSizeUser for $name { + impl BlockSizeUser for $name { type BlockSize = $state_bytes; } - impl + 'static> BufferKindUser for $name { + impl BufferKindUser for $name { type BufferKind = Lazy; } - impl + 'static> OutputSizeUser for $name { + impl OutputSizeUser for $name { type OutputSize = N; } - impl + 'static> UpdateCore for $name { + impl UpdateCore for $name { #[inline] fn update_blocks(&mut self, blocks: &[Block]) { for block in blocks { @@ -139,17 +135,17 @@ macro_rules! define_hasher { } } - impl + 'static> FixedOutputCore for $name { + impl FixedOutputCore for $name { #[inline] fn finalize_fixed_core(&mut self, buffer: &mut Buffer, out: &mut Output) { self.t[1] |= T1_FLAG_FINAL; let pos = buffer.get_pos(); let final_block = buffer.pad_with_zeros(); - self.process_block(final_block, pos); + self.process_block(&final_block, pos); // run Threefish in "counter mode" to generate output let flag = T1_FLAG_FIRST | T1_BLK_TYPE_OUT | T1_FLAG_FINAL; - let mut block = GenericArray::::default(); + let mut block = Array::::default(); for (i, chunk) in out.chunks_mut(<$state_bytes>::USIZE).enumerate() { let mut ctr = Self::blank_state(flag, self.x); @@ -163,7 +159,7 @@ macro_rules! define_hasher { } } - impl + 'static> Default for $name { + impl Default for $name { fn default() -> Self { // build and process config block let mut state = Self::blank_state( @@ -171,7 +167,7 @@ macro_rules! define_hasher { Default::default(), ); - let mut cfg = GenericArray::::default(); + let mut cfg = Array::::default(); cfg[..8].copy_from_slice(&SCHEMA_VER.to_le_bytes()); cfg[8..16].copy_from_slice(&(N::to_u64() * 8).to_le_bytes()); cfg[16..24].copy_from_slice(&CFG_TREE_INFO_SEQUENTIAL.to_le_bytes()); @@ -185,20 +181,20 @@ macro_rules! define_hasher { } } - impl + 'static> Reset for $name { + impl Reset for $name { #[inline] fn reset(&mut self) { *self = Default::default(); } } - impl + 'static> AlgorithmName for $name { + impl AlgorithmName for $name { fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(stringify!($full_name)) } } - impl + 'static> fmt::Debug for $name { + impl fmt::Debug for $name { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { write!(f, "{}<{}> {{ .. }}", stringify!($name), N::USIZE) } diff --git a/sm3/Cargo.toml b/sm3/Cargo.toml index c1d46567b..3b930848d 100644 --- a/sm3/Cargo.toml +++ b/sm3/Cargo.toml @@ -1,22 +1,23 @@ [package] name = "sm3" -version = "0.4.2" +version = "0.5.0-pre" description = "SM3 (OSCCA GM/T 0004-2012) hash function" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/sm3" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "sm3", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = "0.10.7" +digest = "=0.11.0-pre" [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/streebog/Cargo.toml b/streebog/Cargo.toml index bc5bddc54..850c0da43 100644 --- a/streebog/Cargo.toml +++ b/streebog/Cargo.toml @@ -1,22 +1,23 @@ [package] name = "streebog" -version = "0.10.2" +version = "0.11.0-pre" description = "Streebog (GOST R 34.11-2012) hash function" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/streebog" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "streebog", "gost", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = "0.10.7" +digest = "=0.11.0-pre" [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/streebog/src/core_api.rs b/streebog/src/core_api.rs index a9bd09b06..d143aedcf 100644 --- a/streebog/src/core_api.rs +++ b/streebog/src/core_api.rs @@ -140,7 +140,7 @@ impl VariableOutputCore for StreebogVarCore { #[inline] fn finalize_variable_core(&mut self, buffer: &mut Buffer, out: &mut Output) { let pos = buffer.get_pos(); - let block = buffer.pad_with_zeros(); + let mut block = buffer.pad_with_zeros(); block[pos] = 1; self.compress(block.as_ref(), pos as u64); self.g(&[0u8; 64], &to_bytes(&self.n)); diff --git a/tiger/Cargo.toml b/tiger/Cargo.toml index a8f59a4c7..95b8d5267 100644 --- a/tiger/Cargo.toml +++ b/tiger/Cargo.toml @@ -1,22 +1,23 @@ [package] name = "tiger" -version = "0.2.1" +version = "0.3.0-pre" description = "Tiger hash function" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/tiger" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "hash", "tiger", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = "0.10.7" +digest = "=0.11.0-pre" [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/tiger/src/lib.rs b/tiger/src/lib.rs index ed2830a7d..e288b252e 100644 --- a/tiger/src/lib.rs +++ b/tiger/src/lib.rs @@ -14,7 +14,7 @@ //! // process input message //! hasher.update(b"hello world"); //! -//! // acquire hash digest in the form of GenericArray, +//! // acquire hash digest in the form of Array, //! // which in this case is equivalent to [u8; 24] //! let result = hasher.finalize(); //! assert_eq!(result[..], hex!("4c8fbddae0b6f25832af45e7c62811bb64ec3e43691e9cc3")); diff --git a/whirlpool/Cargo.toml b/whirlpool/Cargo.toml index ee3e53bfd..f1c7f534e 100644 --- a/whirlpool/Cargo.toml +++ b/whirlpool/Cargo.toml @@ -1,25 +1,26 @@ [package] name = "whirlpool" -version = "0.10.4" +version = "0.11.0-pre" description = "Whirlpool hash function" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" readme = "README.md" -edition = "2018" +edition = "2021" documentation = "https://docs.rs/whirlpool" repository = "https://github.com/RustCrypto/hashes" keywords = ["crypto", "whirlpool", "hash", "digest"] categories = ["cryptography", "no-std"] +rust-version = "1.65" [dependencies] -digest = "0.10.7" +digest = "=0.11.0-pre" [target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))'.dependencies] whirlpool-asm = { version = "0.6", optional = true} [dev-dependencies] -digest = { version = "0.10.7", features = ["dev"] } -hex-literal = "0.2.2" +digest = { version = "=0.11.0-pre", features = ["dev"] } +hex-literal = "0.4" [features] default = ["std"] diff --git a/whirlpool/src/lib.rs b/whirlpool/src/lib.rs index b5f0ff32f..6e1293cd2 100644 --- a/whirlpool/src/lib.rs +++ b/whirlpool/src/lib.rs @@ -170,7 +170,7 @@ const BLOCK_SIZE: usize = ::BlockSize::USIZE; #[inline(always)] fn convert(blocks: &[Block]) -> &[[u8; BLOCK_SIZE]] { - // SAFETY: GenericArray and [u8; 64] have + // SAFETY: Array and [u8; 64] have // exactly the same memory layout let p = blocks.as_ptr() as *const [u8; BLOCK_SIZE]; unsafe { core::slice::from_raw_parts(p, blocks.len()) }