From 5572b524065bdd68009170a731a8fdc10781a5ed Mon Sep 17 00:00:00 2001 From: ashWhiteHat Date: Sun, 4 Aug 2024 11:34:40 +0900 Subject: [PATCH] rc6: fix test --- Cargo.lock | 114 ------------------------------------- rc6/Cargo.toml | 1 - rc6/src/block_cipher.rs | 93 +++++++++++++++--------------- rc6/src/core/backend.rs | 50 ++++------------ rc6/src/core/primitives.rs | 32 +++++------ rc6/src/lib.rs | 1 + rc6/tests/mod.rs | 23 ++++---- 7 files changed, 88 insertions(+), 226 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 990445d6..7fc01f51 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,17 +116,6 @@ dependencies = [ "cipher", ] -[[package]] -name = "getrandom" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - [[package]] name = "gift-cipher" version = "0.0.0" @@ -187,64 +176,6 @@ dependencies = [ "hex-literal", ] -[[package]] -name = "ppv-lite86" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2288c0e17cc8d342c712bb43a257a80ebffce59cdb33d5000d8348f3ec02528b" -dependencies = [ - "zerocopy", - "zerocopy-derive", -] - -[[package]] -name = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - [[package]] name = "rc2" version = "0.9.0-pre" @@ -264,7 +195,6 @@ name = "rc6" version = "0.1.0" dependencies = [ "cipher", - "rand", ] [[package]] @@ -291,17 +221,6 @@ dependencies = [ "hex-literal", ] -[[package]] -name = "syn" -version = "2.0.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "threefish" version = "0.6.0-pre" @@ -325,18 +244,6 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - [[package]] name = "xtea" version = "0.0.0" @@ -344,27 +251,6 @@ dependencies = [ "cipher", ] -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "byteorder", - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "zeroize" version = "1.8.1" diff --git a/rc6/Cargo.toml b/rc6/Cargo.toml index 15678496..1e6a880d 100644 --- a/rc6/Cargo.toml +++ b/rc6/Cargo.toml @@ -15,7 +15,6 @@ cipher = { version = "0.5.0-pre.6", features = ["zeroize"] } [dev-dependencies] cipher = { version = "0.5.0-pre.6", features = ["dev"] } -rand = { version = "0.8.5" } [features] zeroize = [] diff --git a/rc6/src/block_cipher.rs b/rc6/src/block_cipher.rs index 57e4e816..e5ea04a3 100644 --- a/rc6/src/block_cipher.rs +++ b/rc6/src/block_cipher.rs @@ -1,11 +1,12 @@ use core::ops::{Add, Div, Mul, Sub}; use cipher::{ - generic_array::ArrayLength, + array::ArraySize, + crypto_common::BlockSizes, inout::InOut, typenum::{Diff, IsLess, Le, NonZero, Sum, Unsigned, U1, U12, U16, U2, U20, U24, U256, U4, U8}, - AlgorithmName, Block, BlockBackend, BlockCipher, BlockDecrypt, BlockEncrypt, BlockSizeUser, - KeyInit, KeySizeUser, ParBlocksSizeUser, + AlgorithmName, Block, BlockBackend, BlockCipher, BlockCipherDecrypt, BlockCipherEncrypt, + BlockSizeUser, KeyInit, KeySizeUser, ParBlocksSizeUser, }; use crate::core::{BlockSize, ExpandedKeyTableSize, KeyAsWordsSize, Word, RC6}; @@ -15,7 +16,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -23,16 +24,16 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, // Key range - B: ArrayLength, + B: ArraySize, B: IsLess, Le: NonZero, // KeyAsWordsSize B: Add, Sum: Sub, Diff, U1>: Div, - KeyAsWordsSize: ArrayLength, + KeyAsWordsSize: ArraySize, { fn new(key: &cipher::Key) -> Self { Self::new(key) @@ -44,7 +45,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -52,8 +53,8 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, - B: ArrayLength, + ExpandedKeyTableSize: ArraySize, + B: ArraySize, { type KeySize = B; } @@ -63,7 +64,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -71,7 +72,7 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, { } @@ -80,7 +81,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -88,17 +89,17 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, { type BlockSize = BlockSize; } -impl BlockEncrypt for RC6 +impl BlockCipherEncrypt for RC6 where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -106,16 +107,16 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, // Key range - B: ArrayLength, + B: BlockSizes, B: IsLess, Le: NonZero, // KeyAsWordsSize B: Add, Sum: Sub, Diff, U1>: Div, - KeyAsWordsSize: ArrayLength, + KeyAsWordsSize: ArraySize, { fn encrypt_with_backend(&self, f: impl cipher::BlockClosure) { f.call(&mut RC6EncryptBackend { enc_dec: self }) @@ -127,7 +128,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -135,7 +136,7 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, { enc_dec: &'a RC6, } @@ -144,7 +145,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -152,7 +153,7 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, { type BlockSize = BlockSize; } @@ -162,7 +163,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -170,7 +171,7 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, { type ParBlocksSize = U1; } @@ -180,7 +181,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -188,16 +189,16 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, // Key range - B: ArrayLength, + B: BlockSizes, B: IsLess, Le: NonZero, // KeyAsWordsSize B: Add, Sum: Sub, Diff, U1>: Div, - KeyAsWordsSize: ArrayLength, + KeyAsWordsSize: ArraySize, { #[inline(always)] fn proc_block(&mut self, block: InOut<'_, '_, Block>) { @@ -206,12 +207,12 @@ where } } -impl BlockDecrypt for RC6 +impl BlockCipherDecrypt for RC6 where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -219,16 +220,16 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, // Key range - B: ArrayLength, + B: BlockSizes, B: IsLess, Le: NonZero, // KeyAsWordsSize B: Add, Sum: Sub, Diff, U1>: Div, - KeyAsWordsSize: ArrayLength, + KeyAsWordsSize: ArraySize, { fn decrypt_with_backend(&self, f: impl cipher::BlockClosure) { f.call(&mut RC6DecryptBackend { enc_dec: self }) @@ -240,7 +241,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -248,7 +249,7 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, { enc_dec: &'a RC6, } @@ -257,7 +258,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -265,7 +266,7 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, { type BlockSize = BlockSize; } @@ -275,7 +276,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -283,7 +284,7 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, { type ParBlocksSize = U1; } @@ -293,7 +294,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -301,16 +302,16 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, // Key range - B: ArrayLength, + B: ArraySize, B: IsLess, Le: NonZero, // KeyAsWordsSize B: Add, Sum: Sub, Diff, U1>: Div, - KeyAsWordsSize: ArrayLength, + KeyAsWordsSize: ArraySize, { #[inline(always)] fn proc_block(&mut self, block: InOut<'_, '_, Block>) { @@ -324,7 +325,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -332,7 +333,7 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, { fn write_alg_name(f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!( diff --git a/rc6/src/core/backend.rs b/rc6/src/core/backend.rs index 675d9d86..7bfbc785 100644 --- a/rc6/src/core/backend.rs +++ b/rc6/src/core/backend.rs @@ -5,7 +5,8 @@ use core::{ }; use cipher::{ - generic_array::{sequence::GenericSequence, ArrayLength, GenericArray}, + array::{Array, ArraySize}, + crypto_common::BlockSizes, inout::InOut, typenum::{Diff, IsLess, Le, NonZero, Sum, Unsigned, U1, U2, U256, U4}, }; @@ -22,7 +23,7 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, { key_table: ExpandedKeyTable, _key_size: PhantomData, @@ -33,7 +34,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -41,16 +42,16 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, // Key range - B: ArrayLength, + B: ArraySize, B: IsLess, Le: NonZero, // KeyAsWordsSize B: Add, Sum: Sub, Diff, U1>: Div, - KeyAsWordsSize: ArrayLength, + KeyAsWordsSize: ArraySize, { pub fn new(key: &Key) -> RC6 { Self { @@ -68,7 +69,7 @@ where fn key_into_words(key: &Key) -> KeyAsWords { // can be uninitialized - let mut key_as_words: GenericArray> = GenericArray::default(); + let mut key_as_words: Array> = Array::default(); for i in (0..B::USIZE).rev() { key_as_words[i / W::Bytes::USIZE] = @@ -81,8 +82,7 @@ where fn initialize_expanded_key_table() -> ExpandedKeyTable { // must be zero initialized - let mut expanded_key_table: GenericArray> = - GenericArray::generate(|_| W::ZERO); + let mut expanded_key_table: Array> = Array::from_fn(|_| W::ZERO); expanded_key_table[0] = W::P; for i in 1..expanded_key_table.len() { @@ -127,7 +127,7 @@ where W: Word, // Block size W::Bytes: Mul, - BlockSize: ArrayLength, + BlockSize: BlockSizes, // Rounds range R: Unsigned, R: IsLess, @@ -135,7 +135,7 @@ where // ExpandedKeyTableSize R: Add, Sum: Mul, - ExpandedKeyTableSize: ArrayLength, + ExpandedKeyTableSize: ArraySize, { pub fn encrypt(&self, mut block: InOut<'_, '_, Block>) { let (mut a, mut b, mut c, mut d) = Self::words_from_block(block.get_in()); @@ -230,31 +230,3 @@ where r_h.copy_from_slice(&d.to_le_bytes()); } } - -#[cfg(test)] -mod tests { - use crate::block_cipher::{RC6_16_16_8, RC6_32_20_16, RC6_64_24_24, RC6_8_12_4}; - use crate::core::backend::GenericArray; - use rand::{thread_rng, Rng}; - - #[macro_export] - macro_rules! words_block_conv { - ($rc_tyoe:ident, $key_size:expr) => { - let mut pt = [0u8; $key_size]; - thread_rng().fill(&mut pt[..]); - let block = GenericArray::clone_from_slice(&pt); - let mut after_block = block.clone(); - let (a, b, c, d) = $rc_tyoe::words_from_block(&block); - $rc_tyoe::block_from_words(a, b, c, d, &mut after_block); - assert_eq!(block, after_block); - }; - } - - #[test] - fn words_block_test() { - words_block_conv!(RC6_16_16_8, 8); - words_block_conv!(RC6_32_20_16, 16); - words_block_conv!(RC6_64_24_24, 32); - words_block_conv!(RC6_8_12_4, 4); - } -} diff --git a/rc6/src/core/primitives.rs b/rc6/src/core/primitives.rs index da8d2be1..99044949 100644 --- a/rc6/src/core/primitives.rs +++ b/rc6/src/core/primitives.rs @@ -1,23 +1,23 @@ use cipher::{ - generic_array::{ArrayLength, GenericArray}, + array::{Array, ArraySize}, typenum::{Diff, Prod, Quot, Sum, U1, U2, U4, U8}, zeroize::DefaultIsZeroes, }; use core::ops::{Add, BitXor}; pub type BlockSize = Prod<::Bytes, U4>; -pub type Block = GenericArray>; +pub type Block = Array>; -pub type Key = GenericArray; +pub type Key = Array; -pub type ExpandedKeyTable = GenericArray>; +pub type ExpandedKeyTable = Array>; pub type ExpandedKeyTableSize = Prod, U2>; -pub type KeyAsWords = GenericArray>; +pub type KeyAsWords = Array>; pub type KeyAsWordsSize = Quot::Bytes>, U1>, ::Bytes>; pub trait Word: Default + Copy + From + Add + DefaultIsZeroes { - type Bytes: ArrayLength; + type Bytes: ArraySize; const ZERO: Self; const THREE: Self; @@ -33,8 +33,8 @@ pub trait Word: Default + Copy + From + Add + DefaultIsZeroes fn rotate_left(self, n: Self) -> Self; fn rotate_right(self, n: Self) -> Self; - fn from_le_bytes(bytes: &GenericArray) -> Self; - fn to_le_bytes(self) -> GenericArray; + fn from_le_bytes(bytes: &Array) -> Self; + fn to_le_bytes(self) -> Array; fn bitxor(self, other: Self) -> Self; } @@ -75,12 +75,12 @@ impl Word for u8 { } #[inline(always)] - fn from_le_bytes(bytes: &GenericArray) -> Self { + fn from_le_bytes(bytes: &Array) -> Self { u8::from_le_bytes(bytes.as_slice().try_into().unwrap()) } #[inline(always)] - fn to_le_bytes(self) -> GenericArray { + fn to_le_bytes(self) -> Array { u8::to_le_bytes(self).into() } @@ -126,12 +126,12 @@ impl Word for u16 { } #[inline(always)] - fn from_le_bytes(bytes: &GenericArray) -> Self { + fn from_le_bytes(bytes: &Array) -> Self { u16::from_le_bytes(bytes.as_slice().try_into().unwrap()) } #[inline(always)] - fn to_le_bytes(self) -> GenericArray { + fn to_le_bytes(self) -> Array { u16::to_le_bytes(self).into() } @@ -177,12 +177,12 @@ impl Word for u32 { } #[inline(always)] - fn from_le_bytes(bytes: &GenericArray) -> Self { + fn from_le_bytes(bytes: &Array) -> Self { u32::from_le_bytes(bytes.as_slice().try_into().unwrap()) } #[inline(always)] - fn to_le_bytes(self) -> GenericArray { + fn to_le_bytes(self) -> Array { u32::to_le_bytes(self).into() } @@ -230,12 +230,12 @@ impl Word for u64 { } #[inline(always)] - fn from_le_bytes(bytes: &GenericArray) -> Self { + fn from_le_bytes(bytes: &Array) -> Self { u64::from_le_bytes(bytes.as_slice().try_into().unwrap()) } #[inline(always)] - fn to_le_bytes(self) -> GenericArray { + fn to_le_bytes(self) -> Array { u64::to_le_bytes(self).into() } diff --git a/rc6/src/lib.rs b/rc6/src/lib.rs index b2d584b0..14f2f735 100644 --- a/rc6/src/lib.rs +++ b/rc6/src/lib.rs @@ -3,4 +3,5 @@ mod block_cipher; mod core; +pub use crate::core::RC6; pub use block_cipher::*; diff --git a/rc6/tests/mod.rs b/rc6/tests/mod.rs index 526e1618..af61f44a 100644 --- a/rc6/tests/mod.rs +++ b/rc6/tests/mod.rs @@ -1,8 +1,10 @@ /// generated using the code in: https://www.ietf.org/archive/id/draft-krovetz-rc6-rc5-vectors-00.txt #[cfg(test)] +#[allow(deprecated)] // uses `clone_from_slice` mod tests { - use cipher::{generic_array::GenericArray, BlockDecrypt, BlockEncrypt, KeyInit}; - use rc6::{RC6_16_16_8, RC6_32_20_16, RC6_64_24_24, RC6_8_12_4}; + use cipher::consts::*; + use cipher::{array::Array, BlockCipherDecrypt, BlockCipherEncrypt, KeyInit}; + use rc6::RC6; #[test] fn enc_dec_8_12_4() { @@ -11,8 +13,9 @@ mod tests { let pt = [0x00, 0x01, 0x02, 0x03]; let ct = [0xAE, 0xFC, 0x46, 0x12]; - let rc6 = ::new_from_slice(&key).unwrap(); - let mut block = GenericArray::clone_from_slice(&pt); + let rc6 = as KeyInit>::new_from_slice(&key).unwrap(); + + let mut block = Array::clone_from_slice(&pt); rc6.encrypt_block(&mut block); assert_eq!(ct, block[..]); @@ -28,8 +31,8 @@ mod tests { let pt = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]; let ct = [0x2F, 0xF0, 0xB6, 0x8E, 0xAE, 0xFF, 0xAD, 0x5B]; - let rc6 = ::new_from_slice(&key).unwrap(); - let mut block = GenericArray::clone_from_slice(&pt); + let rc6 = as KeyInit>::new_from_slice(&key).unwrap(); + let mut block = Array::clone_from_slice(&pt); rc6.encrypt_block(&mut block); assert_eq!(ct, block[..]); @@ -54,8 +57,8 @@ mod tests { 0x2A, 0x3C, ]; - let rc6 = ::new_from_slice(&key).unwrap(); - let mut block = GenericArray::clone_from_slice(&pt); + let rc6 = as KeyInit>::new_from_slice(&key).unwrap(); + let mut block = Array::clone_from_slice(&pt); rc6.encrypt_block(&mut block); assert_eq!(ct, block[..]); @@ -82,8 +85,8 @@ mod tests { 0x67, 0x88, 0x66, 0x17, ]; - let rc6 = ::new_from_slice(&key).unwrap(); - let mut block = GenericArray::clone_from_slice(&pt); + let rc6 = as KeyInit>::new_from_slice(&key).unwrap(); + let mut block = Array::clone_from_slice(&pt); rc6.encrypt_block(&mut block); assert_eq!(ct, block[..]);