From 894cf78d058736950cc46d0e4ac134a2791d7b91 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Wed, 28 Feb 2024 23:50:27 -0800 Subject: [PATCH] bump `universal-hash` to `0.6.0-pre` --- .github/workflows/ghash.yml | 4 +-- .github/workflows/poly1305.yml | 14 ++++----- .github/workflows/polyval.yml | 14 ++++----- Cargo.lock | 55 +++++++++++++++++++++++----------- Cargo.toml | 3 ++ ghash/Cargo.toml | 6 ++-- poly1305/Cargo.toml | 6 ++-- poly1305/src/backend/avx2.rs | 4 +-- poly1305/src/fuzz.rs | 6 ++-- poly1305/src/lib.rs | 4 +-- poly1305/tests/lib.rs | 14 ++++----- polyval/Cargo.toml | 6 ++-- 12 files changed, 79 insertions(+), 57 deletions(-) diff --git a/.github/workflows/ghash.yml b/.github/workflows/ghash.yml index 1621f9a..e00f045 100644 --- a/.github/workflows/ghash.yml +++ b/.github/workflows/ghash.yml @@ -26,7 +26,7 @@ jobs: strategy: matrix: rust: - - 1.56.1 # MSRV + - 1.65.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -53,7 +53,7 @@ jobs: strategy: matrix: rust: - - 1.56.1 # MSRV + - 1.65.0 # MSRV - stable steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/poly1305.yml b/.github/workflows/poly1305.yml index d00e808..538ff24 100644 --- a/.github/workflows/poly1305.yml +++ b/.github/workflows/poly1305.yml @@ -26,7 +26,7 @@ jobs: strategy: matrix: rust: - - 1.56.1 # MSRV + - 1.65.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -48,7 +48,7 @@ jobs: include: # 32-bit Linux - target: i686-unknown-linux-gnu - rust: 1.56.1 # MSRV + rust: 1.65.0 # MSRV deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu rust: stable @@ -56,7 +56,7 @@ jobs: # 64-bit Linux - target: x86_64-unknown-linux-gnu - rust: 1.56.1 # MSRV + rust: 1.65.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable steps: @@ -82,7 +82,7 @@ jobs: include: # 32-bit Linux - target: i686-unknown-linux-gnu - rust: 1.56.1 # MSRV + rust: 1.65.0 # MSRV deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu rust: stable @@ -90,7 +90,7 @@ jobs: # 64-bit Linux - target: x86_64-unknown-linux-gnu - rust: 1.56.1 # MSRV + rust: 1.65.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable steps: @@ -116,7 +116,7 @@ jobs: include: # 32-bit Linux - target: i686-unknown-linux-gnu - rust: 1.56.1 # MSRV + rust: 1.65.0 # MSRV deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu rust: stable @@ -124,7 +124,7 @@ jobs: # 64-bit Linux - target: x86_64-unknown-linux-gnu - rust: 1.56.1 # MSRV + rust: 1.65.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable steps: diff --git a/.github/workflows/polyval.yml b/.github/workflows/polyval.yml index 230bd48..3ce482b 100644 --- a/.github/workflows/polyval.yml +++ b/.github/workflows/polyval.yml @@ -26,7 +26,7 @@ jobs: strategy: matrix: rust: - - 1.56.1 # MSRV + - 1.65.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -48,7 +48,7 @@ jobs: include: # 32-bit Linux - target: i686-unknown-linux-gnu - rust: 1.56.1 # MSRV + rust: 1.65.0 # MSRV deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu rust: stable @@ -56,7 +56,7 @@ jobs: # 64-bit Linux - target: x86_64-unknown-linux-gnu - rust: 1.56.1 # MSRV + rust: 1.65.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable steps: @@ -82,7 +82,7 @@ jobs: include: # 32-bit Linux - target: i686-unknown-linux-gnu - rust: 1.56.1 # MSRV + rust: 1.65.0 # MSRV deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu rust: stable @@ -90,7 +90,7 @@ jobs: # 64-bit Linux - target: x86_64-unknown-linux-gnu - rust: 1.56.1 # MSRV + rust: 1.65.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable steps: @@ -116,7 +116,7 @@ jobs: include: # 32-bit Linux - target: i686-unknown-linux-gnu - rust: 1.56.1 # MSRV + rust: 1.65.0 # MSRV deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu rust: stable @@ -124,7 +124,7 @@ jobs: # 64-bit Linux - target: x86_64-unknown-linux-gnu - rust: 1.56.1 # MSRV + rust: 1.65.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable steps: diff --git a/Cargo.lock b/Cargo.lock index 7921dfb..e8f9dbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,27 +19,29 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.2.0-pre.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "b7aa2ec04f5120b830272a481e8d9d8ba4dda140d2cda59b0f1110d5eb93c38e" dependencies = [ - "generic-array", - "typenum", + "getrandom", + "hybrid-array", + "rand_core", ] [[package]] -name = "generic-array" -version = "0.14.7" +name = "getrandom" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ - "typenum", - "version_check", + "cfg-if", + "libc", + "wasi", ] [[package]] name = "ghash" -version = "0.5.1" +version = "0.6.0-pre" dependencies = [ "hex-literal", "opaque-debug", @@ -53,6 +55,15 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" +[[package]] +name = "hybrid-array" +version = "0.2.0-rc.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c2311a0adecbffff284aabcf1249b1485193b16e685f9ef171b1ba82979cff" +dependencies = [ + "typenum", +] + [[package]] name = "libc" version = "0.2.149" @@ -67,7 +78,7 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "poly1305" -version = "0.8.0" +version = "0.9.0-pre" dependencies = [ "cpufeatures", "hex-literal", @@ -78,7 +89,7 @@ dependencies = [ [[package]] name = "polyval" -version = "0.6.2" +version = "0.7.0-pre" dependencies = [ "cfg-if", "cpufeatures", @@ -88,6 +99,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "subtle" version = "2.5.0" @@ -102,19 +122,18 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "universal-hash" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +version = "0.6.0-pre" +source = "git+https://github.com/RustCrypto/traits.git?branch=master#b2e31d8df293026390b6315c10844eed8b54a185" dependencies = [ "crypto-common", "subtle", ] [[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 = "zeroize" diff --git a/Cargo.toml b/Cargo.toml index 3464997..6c82d8a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,3 +5,6 @@ members = [ "polyval" ] resolver = "2" + +[patch.crates-io] +universal-hash = { git = "https://github.com/RustCrypto/traits.git", branch = "master" } diff --git a/ghash/Cargo.toml b/ghash/Cargo.toml index b9e5e9b..b8ff3ae 100644 --- a/ghash/Cargo.toml +++ b/ghash/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ghash" -version = "0.5.1" +version = "0.6.0-pre" authors = ["RustCrypto Developers"] license = "Apache-2.0 OR MIT" description = """ @@ -12,12 +12,12 @@ repository = "https://github.com/RustCrypto/universal-hashes" readme = "README.md" keywords = ["aes-gcm", "crypto", "universal-hashing"] categories = ["cryptography", "no-std"] -rust-version = "1.56" +rust-version = "1.65" edition = "2021" [dependencies] opaque-debug = "0.3" -polyval = { version = "0.6.2", path = "../polyval" } +polyval = { version = "=0.7.0-pre", path = "../polyval" } # optional dependencies zeroize = { version = "1", optional = true, default-features = false } diff --git a/poly1305/Cargo.toml b/poly1305/Cargo.toml index 7345d01..dad50fd 100644 --- a/poly1305/Cargo.toml +++ b/poly1305/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poly1305" -version = "0.8.0" +version = "0.9.0-pre" authors = ["RustCrypto Developers"] license = "Apache-2.0 OR MIT" description = "The Poly1305 universal hash function and message authentication code" @@ -9,12 +9,12 @@ repository = "https://github.com/RustCrypto/universal-hashes" keywords = ["crypto", "chacha20", "mac", "salsa20", "universal-hashing"] categories = ["cryptography", "no-std"] readme = "README.md" -rust-version = "1.56" +rust-version = "1.65" edition = "2021" [dependencies] opaque-debug = "0.3" -universal-hash = { version = "0.5", default-features = false } +universal-hash = { version = "=0.6.0-pre", default-features = false } zeroize = { version = "1", optional = true, default-features = false } [target.'cfg(any(target_arch = "x86_64", target_arch = "x86"))'.dependencies] diff --git a/poly1305/src/backend/avx2.rs b/poly1305/src/backend/avx2.rs index a9b8191..726714c 100644 --- a/poly1305/src/backend/avx2.rs +++ b/poly1305/src/backend/avx2.rs @@ -16,9 +16,9 @@ // length to be known, which is incompatible with the streaming API of UniversalHash. use universal_hash::{ + array::Array, consts::{U16, U4}, crypto_common::{BlockSizeUser, ParBlocksSizeUser}, - generic_array::GenericArray, UhfBackend, }; @@ -160,7 +160,7 @@ impl State { } // Compute tag: p + k mod 2^128 - let mut tag = GenericArray::::default(); + let mut tag = Array::::default(); let tag_int = if let Some(p) = p { self.k + p } else { diff --git a/poly1305/src/fuzz.rs b/poly1305/src/fuzz.rs index f4ee91e..57f6259 100644 --- a/poly1305/src/fuzz.rs +++ b/poly1305/src/fuzz.rs @@ -1,4 +1,4 @@ -use universal_hash::{generic_array::GenericArray, UniversalHash}; +use universal_hash::{array::Array, UniversalHash}; use crate::{backend, Block, Key, BLOCK_SIZE}; @@ -9,7 +9,7 @@ pub fn fuzz_avx2(key: &Key, data: &[u8]) { for (_i, chunk) in data.chunks(BLOCK_SIZE).enumerate() { if chunk.len() == BLOCK_SIZE { - let block = GenericArray::from_slice(chunk); + let block = Array::from_slice(chunk); unsafe { avx2.compute_block(block, false); } @@ -38,7 +38,7 @@ pub fn fuzz_avx2(key: &Key, data: &[u8]) { } fn avx2_fuzzer_test_case(data: &[u8]) { - fuzz_avx2(data[0..32].into(), &data[32..]); + fuzz_avx2(Array::from_slice(&data[0..32]).into(), &data[32..]); } #[test] diff --git a/poly1305/src/lib.rs b/poly1305/src/lib.rs index 62c9781..b3cbbad 100644 --- a/poly1305/src/lib.rs +++ b/poly1305/src/lib.rs @@ -54,9 +54,9 @@ extern crate std; pub use universal_hash; use universal_hash::{ + array::Array, consts::{U16, U32}, crypto_common::{BlockSizeUser, KeySizeUser}, - generic_array::GenericArray, KeyInit, UniversalHash, }; @@ -146,7 +146,7 @@ impl Poly1305 { pub fn compute_unpadded(mut self, data: &[u8]) -> Tag { for chunk in data.chunks(BLOCK_SIZE) { if chunk.len() == BLOCK_SIZE { - let block = GenericArray::from_slice(chunk); + let block = Array::from_slice(chunk); self.state.compute_block(block, false); } else { let mut block = Block::default(); diff --git a/poly1305/tests/lib.rs b/poly1305/tests/lib.rs index b656707..96e65fc 100644 --- a/poly1305/tests/lib.rs +++ b/poly1305/tests/lib.rs @@ -23,7 +23,7 @@ fn test_nacl_vector() { let expected = hex!("f3ffc7703f9400e52a7dfb4b3d3305d9"); - let result1 = Poly1305::new(key.as_ref().into()).compute_unpadded(&msg); + let result1 = Poly1305::new(key.as_ref()).compute_unpadded(&msg); assert_eq!(&expected[..], result1.as_slice()); } @@ -42,7 +42,7 @@ fn donna_self_test1() { // = 3 let expected = hex!("03000000000000000000000000000000"); - let mut poly = Poly1305::new(key.as_ref().into()); + let mut poly = Poly1305::new(key.as_ref()); poly.update(&[Block::clone_from_slice(msg.as_ref())]); assert_eq!(&expected[..], poly.finalize().as_slice()); } @@ -52,14 +52,14 @@ fn donna_self_test2() { let total_key = hex!("01020304050607fffefdfcfbfaf9ffffffffffffffffffffffffffff00000000"); let total_mac = hex!("64afe2e8d6ad7bbdd287f97c44623d39"); - let mut tpoly = Poly1305::new(total_key.as_ref().into()); + let mut tpoly = Poly1305::new(total_key.as_ref()); for i in 0..256 { let mut key = [0u8; KEY_SIZE]; key.copy_from_slice(&repeat(i as u8).take(KEY_SIZE).collect::>()); let msg: Vec = repeat(i as u8).take(256).collect(); - let tag = Poly1305::new(key.as_ref().into()).compute_unpadded(&msg[..i]); + let tag = Poly1305::new(key.as_ref()).compute_unpadded(&msg[..i]); tpoly.update(&[tag]); } @@ -73,7 +73,7 @@ fn test_tls_vectors() { let msg = [0u8; 32]; let expected = hex!("49ec78090e481ec6c26b33b91ccc0307"); - let mut poly = Poly1305::new(key.as_ref().into()); + let mut poly = Poly1305::new(key.as_ref()); let blocks = msg .chunks(BLOCK_SIZE) @@ -91,7 +91,7 @@ fn test_rfc7539_vector() { let msg = hex!("43727970746f6772617068696320466f72756d2052657365617263682047726f7570"); let expected = hex!("a8061dc1305136c6c22b8baf0c0127a9"); - let result = Poly1305::new(key.as_ref().into()).compute_unpadded(&msg); + let result = Poly1305::new(key.as_ref()).compute_unpadded(&msg); assert_eq!(&expected[..], result.as_slice()); } @@ -102,7 +102,7 @@ fn padded_input() { let msg = hex!("50515253c0c1c2c3c4c5c6c7"); let expected = hex!("ada56caa480fe6f5067039244a3d76ba"); - let mut poly = Poly1305::new(key.as_ref().into()); + let mut poly = Poly1305::new(key.as_ref()); poly.update_padded(&msg); assert_eq!(&expected[..], poly.finalize().as_slice()); } diff --git a/polyval/Cargo.toml b/polyval/Cargo.toml index 45c7d0c..33ca61d 100644 --- a/polyval/Cargo.toml +++ b/polyval/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polyval" -version = "0.6.2" +version = "0.7.0-pre" authors = ["RustCrypto Developers"] license = "Apache-2.0 OR MIT" description = """ @@ -12,13 +12,13 @@ repository = "https://github.com/RustCrypto/universal-hashes" readme = "README.md" keywords = ["aes-gcm", "aes-gcm-siv", "crypto", "ghash", "universal-hashing"] categories = ["cryptography", "no-std"] -rust-version = "1.56" +rust-version = "1.65" edition = "2021" [dependencies] cfg-if = "1" opaque-debug = "0.3" -universal-hash = { version = "0.5", default-features = false } +universal-hash = { version = "=0.6.0-pre", default-features = false } zeroize = { version = "1", optional = true, default-features = false } [target.'cfg(any(target_arch = "aarch64", target_arch = "x86_64", target_arch = "x86"))'.dependencies]