From c77dcc2cae1b3fc1853938a1cb6102e8dfea2c83 Mon Sep 17 00:00:00 2001 From: Noah Stiltner Date: Thu, 2 Nov 2023 19:48:31 -0500 Subject: [PATCH] fix unused mut variable warning when zeroize isn't enabled --- chacha20/src/rng.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/chacha20/src/rng.rs b/chacha20/src/rng.rs index 9c41ee10..c3a29f08 100644 --- a/chacha20/src/rng.rs +++ b/chacha20/src/rng.rs @@ -321,13 +321,21 @@ macro_rules! impl_chacha_rng { /// 28 bits. #[inline] pub fn set_word_pos_bytes(&mut self, word_offset: &[u8; 8]) { - let mut original_word_offset = u64::from_le_bytes(*word_offset); - let mut block = original_word_offset >> 4; - self.rng.core.block.set_block_pos(block as u32); - self.rng - .generate_and_set((original_word_offset - block) as usize); + #[cfg(not(feature = "zeroize"))] + { + let original_word_offset = u64::from_le_bytes(*word_offset); + let block = original_word_offset >> 4; + self.rng.core.block.set_block_pos(block as u32); + self.rng + .generate_and_set((original_word_offset - block) as usize); + } #[cfg(feature = "zeroize")] { + let mut original_word_offset = u64::from_le_bytes(*word_offset); + let mut block = original_word_offset >> 4; + self.rng.core.block.set_block_pos(block as u32); + self.rng + .generate_and_set((original_word_offset - block) as usize); original_word_offset.zeroize(); block.zeroize(); }