From b44e790c119a1c2afd3e91efc3b17a2c2900d16a Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Fri, 26 Jul 2024 18:39:46 -0600 Subject: [PATCH] Bump `hybrid-array` to v0.2.0-pre.9 Fixes deprecation warnings --- Cargo.lock | 4 ++-- ecdsa/src/lib.rs | 6 +++--- slh-dsa/src/fors.rs | 1 + slh-dsa/src/hashes/sha2.rs | 3 +++ slh-dsa/src/signature_encoding.rs | 1 + slh-dsa/src/signing_key.rs | 2 ++ slh-dsa/src/util.rs | 1 + slh-dsa/src/verifying_key.rs | 3 +++ 8 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 478c274d..7ffb9c65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -559,9 +559,9 @@ dependencies = [ [[package]] name = "hybrid-array" -version = "0.2.0-rc.8" +version = "0.2.0-rc.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53668f5da5a41d9eaf4bf7064be46d1ebe6a4e1ceed817f387587b18f2b51047" +checksum = "4d306b679262030ad8813a82d4915fc04efff97776e4db7f8eb5137039d56400" dependencies = [ "typenum", "zeroize", diff --git a/ecdsa/src/lib.rs b/ecdsa/src/lib.rs index ef97e618..5c10e46b 100644 --- a/ecdsa/src/lib.rs +++ b/ecdsa/src/lib.rs @@ -223,9 +223,9 @@ where /// - `Err(err)` if the `r` and/or `s` component of the signature is /// out-of-range when interpreted as a big endian integer. pub fn from_bytes(bytes: &SignatureBytes) -> Result { - let (r_bytes, s_bytes) = bytes.split_at(C::FieldBytesSize::USIZE); - let r = FieldBytes::::clone_from_slice(r_bytes); - let s = FieldBytes::::clone_from_slice(s_bytes); + let chunks = FieldBytes::::slice_as_chunks(bytes).0; + let r = chunks[0].clone(); + let s = chunks[1].clone(); Self::from_scalars(r, s) } diff --git a/slh-dsa/src/fors.rs b/slh-dsa/src/fors.rs index ebe8ec71..f8544038 100644 --- a/slh-dsa/src/fors.rs +++ b/slh-dsa/src/fors.rs @@ -52,6 +52,7 @@ impl TryFrom<&[u8]> for ForsMTSig

{ if slice.len() != ForsMTSig::

::SIZE { return Err(()); } + #[allow(deprecated)] let sk = Array::clone_from_slice(&slice[..P::N::USIZE]); let mut auth: Array, P::A> = Array::default(); for i in 0..P::A::USIZE { diff --git a/slh-dsa/src/hashes/sha2.rs b/slh-dsa/src/hashes/sha2.rs index 4865bb97..4ef85824 100644 --- a/slh-dsa/src/hashes/sha2.rs +++ b/slh-dsa/src/hashes/sha2.rs @@ -1,3 +1,6 @@ +// TODO(tarcieri): fix `hybrid-array` deprecation warnings +#![allow(deprecated)] + use core::fmt::Debug; use crate::hashes::HashSuite; diff --git a/slh-dsa/src/signature_encoding.rs b/slh-dsa/src/signature_encoding.rs index fbaf63fe..3d84f3c1 100644 --- a/slh-dsa/src/signature_encoding.rs +++ b/slh-dsa/src/signature_encoding.rs @@ -59,6 +59,7 @@ impl TryFrom<&[u8]> for Signature

{ } let (rand_bytes, rest) = bytes.split_at(P::N::USIZE); + #[allow(deprecated)] let randomizer = Array::clone_from_slice(rand_bytes); let (fors_bytes, ht_bytes) = rest.split_at(ForsSignature::

::SIZE); diff --git a/slh-dsa/src/signing_key.rs b/slh-dsa/src/signing_key.rs index 28f272c4..50545efe 100644 --- a/slh-dsa/src/signing_key.rs +++ b/slh-dsa/src/signing_key.rs @@ -17,6 +17,7 @@ impl AsRef<[u8]> for SkSeed { } impl From<&[u8]> for SkSeed { fn from(slice: &[u8]) -> Self { + #[allow(deprecated)] Self(Array::clone_from_slice(slice)) } } @@ -37,6 +38,7 @@ impl AsRef<[u8]> for SkPrf { } impl From<&[u8]> for SkPrf { fn from(slice: &[u8]) -> Self { + #[allow(deprecated)] Self(Array::clone_from_slice(slice)) } } diff --git a/slh-dsa/src/util.rs b/slh-dsa/src/util.rs index a2efdef8..0445a8b0 100644 --- a/slh-dsa/src/util.rs +++ b/slh-dsa/src/util.rs @@ -25,6 +25,7 @@ pub fn base_2b(x: &[u8]) -> Array { /// Separates the digest into the FORS message, the Xmss tree index, and the Xmss leaf index. pub fn split_digest(digest: &Array) -> (&Array, u64, u32) { + #[allow(deprecated)] let m = Array::from_slice(&digest[..P::MD::USIZE]); let idx_tree_size = (P::H::USIZE - P::HPrime::USIZE).div_ceil(8); let idx_leaf_size = P::HPrime::USIZE.div_ceil(8); diff --git a/slh-dsa/src/verifying_key.rs b/slh-dsa/src/verifying_key.rs index 2eddd07f..ef3dd293 100644 --- a/slh-dsa/src/verifying_key.rs +++ b/slh-dsa/src/verifying_key.rs @@ -24,6 +24,7 @@ impl AsRef<[u8]> for PkSeed { } impl From<&[u8]> for PkSeed { fn from(slice: &[u8]) -> Self { + #[allow(deprecated)] Self(Array::clone_from_slice(slice)) } } @@ -79,6 +80,7 @@ impl From<&VerifyingKey

> for Array { } impl From> for VerifyingKey

{ + #[allow(deprecated)] // clone_from_slice fn from(bytes: Array) -> VerifyingKey

{ debug_assert!(P::VkLen::USIZE == 2 * P::N::USIZE); let pk_seed = PkSeed(Array::clone_from_slice(&bytes[..P::N::USIZE])); @@ -90,6 +92,7 @@ impl From> for VerifyingKey

{ impl TryFrom<&[u8]> for VerifyingKey

{ type Error = Error; + #[allow(deprecated)] // clone_from_slice fn try_from(bytes: &[u8]) -> Result { if bytes.len() != P::N::USIZE * 2 { return Err(Error::new());