diff --git a/Cargo.lock b/Cargo.lock index b24ef832..981fc718 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ name = "ascon-hash" version = "0.3.0-pre" dependencies = [ "ascon", - "digest", + "digest 0.11.0-pre.8", "hex", "hex-literal", "spectral", @@ -33,7 +33,7 @@ name = "belt-hash" version = "0.2.0-pre.3" dependencies = [ "belt-block", - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] @@ -41,7 +41,7 @@ dependencies = [ name = "blake2" version = "0.11.0-pre.3" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] @@ -51,13 +51,22 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "847495c209977a90e8aad588b959d0ca9f5dc228096d29a6bd3defd53f35eaec" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "block-buffer" version = "0.11.0-pre.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ded684142010808eb980d9974ef794da2bcf97d13396143b1515e9f0fb4a10e" dependencies = [ - "crypto-common", + "crypto-common 0.2.0-pre.5", "zeroize", ] @@ -67,6 +76,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "const-oid" version = "0.10.0-pre.2" @@ -82,6 +97,16 @@ dependencies = [ "libc", ] +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "crypto-common" version = "0.2.0-pre.5" @@ -93,6 +118,18 @@ dependencies = [ "rand_core", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "blobby", + "block-buffer 0.10.4", + "const-oid 0.9.6", + "crypto-common 0.1.6", +] + [[package]] name = "digest" version = "0.11.0-pre.8" @@ -100,9 +137,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "065d93ead7c220b85d5b4be4795d8398eac4ff68b5ee63895de0a3c1fb6edf25" dependencies = [ "blobby", - "block-buffer", - "const-oid", - "crypto-common", + "block-buffer 0.11.0-pre.5", + "const-oid 0.10.0-pre.2", + "crypto-common 0.2.0-pre.5", "subtle", "zeroize", ] @@ -111,11 +148,21 @@ dependencies = [ name = "fsb" version = "0.2.0-pre" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", "whirlpool", ] +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.12" @@ -131,7 +178,7 @@ dependencies = [ name = "gost94" version = "0.11.0-pre" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] @@ -139,7 +186,7 @@ dependencies = [ name = "groestl" version = "0.11.0-pre" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] @@ -168,7 +215,7 @@ dependencies = [ name = "jh" version = "0.2.0-pre" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", "ppv-lite86", ] @@ -177,7 +224,7 @@ dependencies = [ name = "k12" version = "0.4.0-pre" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", "sha3", ] @@ -202,7 +249,7 @@ name = "md-5" version = "0.11.0-pre.3" dependencies = [ "cfg-if", - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] @@ -210,7 +257,7 @@ dependencies = [ name = "md2" version = "0.11.0-pre" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] @@ -218,7 +265,7 @@ dependencies = [ name = "md4" version = "0.11.0-pre" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] @@ -241,27 +288,38 @@ dependencies = [ name = "ripemd" version = "0.2.0-pre" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + [[package]] name = "sha1" version = "0.11.0-pre.3" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] [[package]] name = "sha1-checked" -version = "0.11.0" +version = "0.10.0" dependencies = [ - "digest", + "digest 0.10.7", "hex-literal", - "sha1", + "sha1 0.10.6", ] [[package]] @@ -270,7 +328,7 @@ version = "0.11.0-pre.3" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] @@ -278,7 +336,7 @@ dependencies = [ name = "sha3" version = "0.11.0-pre.3" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", "keccak", ] @@ -287,7 +345,7 @@ dependencies = [ name = "shabal" version = "0.5.0-pre" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] @@ -295,7 +353,7 @@ dependencies = [ name = "skein" version = "0.2.0-pre" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", "threefish", ] @@ -304,7 +362,7 @@ dependencies = [ name = "sm3" version = "0.5.0-pre.3" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] @@ -318,7 +376,7 @@ checksum = "ae3c15181f4b14e52eeaac3efaeec4d2764716ce9c86da0c934c3e318649c5ba" name = "streebog" version = "0.11.0-pre.3" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] @@ -341,7 +399,7 @@ dependencies = [ name = "tiger" version = "0.3.0-pre" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] @@ -351,6 +409,12 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -361,7 +425,7 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" name = "whirlpool" version = "0.11.0-pre.2" dependencies = [ - "digest", + "digest 0.11.0-pre.8", "hex-literal", ] diff --git a/sha1-checked/Cargo.toml b/sha1-checked/Cargo.toml index 2387b124..800dbc52 100644 --- a/sha1-checked/Cargo.toml +++ b/sha1-checked/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sha1-checked" -version = "0.11.0" +version = "0.10.0" description = "SHA-1 hash function with collision detection" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" @@ -13,18 +13,18 @@ categories = ["cryptography", "no-std"] rust-version = "1.72" [dependencies] -digest = "=0.11.0-pre.8" -sha1 = { version = "=0.11.0-pre.3", default-features = false, path = "../sha1" } +digest = "0.10.7" +sha1 = { version = "0.10.6", default-features = false, features = ["compress"] } [dev-dependencies] -digest = { version = "=0.11.0-pre.8", features = ["dev"] } +digest = { version = "0.10.7", features = ["dev"] } hex-literal = "0.4" [features] default = ["oid", "std"] std = ["digest/std", "sha1/std"] oid = ["digest/oid", "sha1/oid"] # Enable OID support -zeroize = ["digest/zeroize", "sha1/zeroize"] +zeroize = [] [package.metadata.docs.rs] diff --git a/sha1-checked/src/lib.rs b/sha1-checked/src/lib.rs index 0ba048d3..39e11965 100644 --- a/sha1-checked/src/lib.rs +++ b/sha1-checked/src/lib.rs @@ -29,7 +29,6 @@ extern crate std; #[cfg(feature = "zeroize")] use digest::zeroize::{Zeroize, ZeroizeOnDrop}; use digest::{ - array::Array, block_buffer::{BlockBuffer, Eager}, core_api::BlockSizeUser, typenum::{Unsigned, U20, U64}, @@ -115,7 +114,7 @@ impl Sha1 { compress::finalize(h, bs * self.block_len, last_block, ctx); } else { let bit_len = 8 * (buffer.get_pos() as u64 + bs * self.block_len); - buffer.len64_padding_be(bit_len, |b| sha1::compress(h, from_ref(&b.0))); + buffer.len64_padding_be(bit_len, |b| sha1::compress(h, from_ref(b))); } for (chunk, v) in out.chunks_exact_mut(4).zip(h.iter()) { @@ -181,9 +180,11 @@ impl Update for Sha1 { } = self; buffer.digest_blocks(input, |blocks| { self.block_len += blocks.len() as u64; - let blocks = Array::cast_slice_to_core(blocks); - if let Some(ref mut ctx) = detection { + // SAFETY: GenericArray and [u8; 64] have + // exactly the same memory layout + let blocks: &[[u8; BLOCK_SIZE]] = + unsafe { &*(blocks as *const _ as *const [[u8; BLOCK_SIZE]]) }; compress::compress(h, ctx, blocks); } else { sha1::compress(h, blocks); diff --git a/sha1-checked/tests/mod.rs b/sha1-checked/tests/mod.rs index 7ee0a57f..bd31f12e 100644 --- a/sha1-checked/tests/mod.rs +++ b/sha1-checked/tests/mod.rs @@ -9,7 +9,7 @@ fn sha1_rand() { let mut h = Sha1::new(); feed_rand_16mib(&mut h); assert_eq!( - h.finalize(), + &h.finalize()[..], hex!("7e565a25a8b123e9881addbcedcd927b23377a78"), ); } @@ -19,7 +19,7 @@ fn sha1_collision_rand() { let mut h = Sha1::new(); feed_rand_16mib(&mut h); assert_eq!( - h.finalize(), + &h.finalize()[..], hex!("7e565a25a8b123e9881addbcedcd927b23377a78"), ); }