From fd0ecda2e8b6c503f3cfe41b1508a46532f70f20 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sat, 25 Oct 2025 12:38:36 -0600 Subject: [PATCH] rc6: 2024 edition; upgrade to `cipher` v0.5.0-rc.1 Updates `rc6` to use the latest Rust version and version of `cipher` that all of the other crates are using --- .github/workflows/rc6.yml | 6 ++--- Cargo.lock | 2 +- rc6/Cargo.toml | 9 ++++--- rc6/src/block_cipher.rs | 54 +++++++++++++++------------------------ rc6/src/core/backend.rs | 2 +- rc6/tests/mod.rs | 2 +- 6 files changed, 31 insertions(+), 44 deletions(-) diff --git a/.github/workflows/rc6.yml b/.github/workflows/rc6.yml index fbdf9035..f7101cc2 100644 --- a/.github/workflows/rc6.yml +++ b/.github/workflows/rc6.yml @@ -21,7 +21,7 @@ jobs: strategy: matrix: rust: - - 1.65.0 # MSRVs + - 1.85.0 # MSRVs - stable target: - thumbv7em-none-eabi @@ -38,14 +38,14 @@ jobs: minimal-versions: uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master with: - working-directory: ${{ github.workflow }} + working-directory: ${{ github.workflow }} test: runs-on: ubuntu-latest strategy: matrix: rust: - - 1.65.0 # MSRVs + - 1.85.0 # MSRVs - stable steps: - uses: actions/checkout@v3 diff --git a/Cargo.lock b/Cargo.lock index 9c064628..cf15f474 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "rc6" -version = "0.1.0" +version = "0.0.0" dependencies = [ "cipher", ] diff --git a/rc6/Cargo.toml b/rc6/Cargo.toml index 1e6a880d..b5971463 100644 --- a/rc6/Cargo.toml +++ b/rc6/Cargo.toml @@ -1,9 +1,10 @@ [package] name = "rc6" -version = "0.1.0" +version = "0.0.0" description = "RC6 block cipher" authors = ["RustCrypto Developers"] -edition = "2021" +edition = "2024" +rust-version = "1.85" license = "MIT OR Apache-2.0" readme = "README.md" repository = "https://github.com/RustCrypto/block-ciphers" @@ -11,10 +12,10 @@ keywords = ["crypto", "rc6", "block-cipher"] categories = ["cryptography"] [dependencies] -cipher = { version = "0.5.0-pre.6", features = ["zeroize"] } +cipher = { version = "0.5.0-rc.1", features = ["zeroize"] } [dev-dependencies] -cipher = { version = "0.5.0-pre.6", features = ["dev"] } +cipher = { version = "0.5.0-rc.1", features = ["dev"] } [features] zeroize = [] diff --git a/rc6/src/block_cipher.rs b/rc6/src/block_cipher.rs index e5ea04a3..6f92430a 100644 --- a/rc6/src/block_cipher.rs +++ b/rc6/src/block_cipher.rs @@ -1,15 +1,18 @@ use core::ops::{Add, Div, Mul, Sub}; use cipher::{ + AlgorithmName, Block, BlockSizeUser, KeyInit, KeySizeUser, ParBlocksSizeUser, array::ArraySize, + block::{ + BlockCipherDecBackend, BlockCipherDecClosure, BlockCipherDecrypt, BlockCipherEncBackend, + BlockCipherEncClosure, BlockCipherEncrypt, + }, 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, BlockCipherDecrypt, BlockCipherEncrypt, - BlockSizeUser, KeyInit, KeySizeUser, ParBlocksSizeUser, + typenum::{Diff, IsLess, Le, NonZero, Sum, U1, U2, U4, U8, U12, U16, U20, U24, U256, Unsigned}, }; -use crate::core::{BlockSize, ExpandedKeyTableSize, KeyAsWordsSize, Word, RC6}; +use crate::core::{BlockSize, ExpandedKeyTableSize, KeyAsWordsSize, RC6, Word}; impl KeyInit for RC6 where @@ -59,23 +62,6 @@ where type KeySize = B; } -impl BlockCipher for RC6 -where - W: Word, - // Block size - W::Bytes: Mul, - BlockSize: BlockSizes, - // Rounds range - R: Unsigned, - R: IsLess, - Le: NonZero, - // ExpandedKeyTableSize - R: Add, - Sum: Mul, - ExpandedKeyTableSize: ArraySize, -{ -} - impl BlockSizeUser for RC6 where W: Word, @@ -118,8 +104,8 @@ where Diff, U1>: Div, KeyAsWordsSize: ArraySize, { - fn encrypt_with_backend(&self, f: impl cipher::BlockClosure) { - f.call(&mut RC6EncryptBackend { enc_dec: self }) + fn encrypt_with_backend(&self, f: impl BlockCipherEncClosure) { + f.call(&RC6EncryptBackend { enc_dec: self }) } } @@ -140,7 +126,7 @@ where { enc_dec: &'a RC6, } -impl<'a, W, R, B> BlockSizeUser for RC6EncryptBackend<'a, W, R, B> +impl BlockSizeUser for RC6EncryptBackend<'_, W, R, B> where W: Word, // Block size @@ -158,7 +144,7 @@ where type BlockSize = BlockSize; } -impl<'a, W, R, B> ParBlocksSizeUser for RC6EncryptBackend<'a, W, R, B> +impl ParBlocksSizeUser for RC6EncryptBackend<'_, W, R, B> where W: Word, // Block size @@ -176,7 +162,7 @@ where type ParBlocksSize = U1; } -impl<'a, W, R, B> BlockBackend for RC6EncryptBackend<'a, W, R, B> +impl BlockCipherEncBackend for RC6EncryptBackend<'_, W, R, B> where W: Word, // Block size @@ -191,7 +177,7 @@ where Sum: Mul, ExpandedKeyTableSize: ArraySize, // Key range - B: BlockSizes, + B: ArraySize, B: IsLess, Le: NonZero, // KeyAsWordsSize @@ -201,7 +187,7 @@ where KeyAsWordsSize: ArraySize, { #[inline(always)] - fn proc_block(&mut self, block: InOut<'_, '_, Block>) { + fn encrypt_block(&self, block: InOut<'_, '_, Block>) { let backend = self.enc_dec; backend.encrypt(block) } @@ -231,8 +217,8 @@ where Diff, U1>: Div, KeyAsWordsSize: ArraySize, { - fn decrypt_with_backend(&self, f: impl cipher::BlockClosure) { - f.call(&mut RC6DecryptBackend { enc_dec: self }) + fn decrypt_with_backend(&self, f: impl BlockCipherDecClosure) { + f.call(&RC6DecryptBackend { enc_dec: self }) } } @@ -253,7 +239,7 @@ where { enc_dec: &'a RC6, } -impl<'a, W, R, B> BlockSizeUser for RC6DecryptBackend<'a, W, R, B> +impl BlockSizeUser for RC6DecryptBackend<'_, W, R, B> where W: Word, // Block size @@ -271,7 +257,7 @@ where type BlockSize = BlockSize; } -impl<'a, W, R, B> ParBlocksSizeUser for RC6DecryptBackend<'a, W, R, B> +impl ParBlocksSizeUser for RC6DecryptBackend<'_, W, R, B> where W: Word, // Block size @@ -289,7 +275,7 @@ where type ParBlocksSize = U1; } -impl<'a, W, R, B> BlockBackend for RC6DecryptBackend<'a, W, R, B> +impl BlockCipherDecBackend for RC6DecryptBackend<'_, W, R, B> where W: Word, // Block size @@ -314,7 +300,7 @@ where KeyAsWordsSize: ArraySize, { #[inline(always)] - fn proc_block(&mut self, block: InOut<'_, '_, Block>) { + fn decrypt_block(&self, block: InOut<'_, '_, Block>) { let backend = self.enc_dec; backend.decrypt(block) } diff --git a/rc6/src/core/backend.rs b/rc6/src/core/backend.rs index 7bfbc785..56b65fda 100644 --- a/rc6/src/core/backend.rs +++ b/rc6/src/core/backend.rs @@ -8,7 +8,7 @@ use cipher::{ array::{Array, ArraySize}, crypto_common::BlockSizes, inout::InOut, - typenum::{Diff, IsLess, Le, NonZero, Sum, Unsigned, U1, U2, U256, U4}, + typenum::{Diff, IsLess, Le, NonZero, Sum, U1, U2, U4, U256, Unsigned}, }; use super::{ diff --git a/rc6/tests/mod.rs b/rc6/tests/mod.rs index af61f44a..df5d10ba 100644 --- a/rc6/tests/mod.rs +++ b/rc6/tests/mod.rs @@ -3,7 +3,7 @@ #[allow(deprecated)] // uses `clone_from_slice` mod tests { use cipher::consts::*; - use cipher::{array::Array, BlockCipherDecrypt, BlockCipherEncrypt, KeyInit}; + use cipher::{BlockCipherDecrypt, BlockCipherEncrypt, KeyInit, array::Array}; use rc6::RC6; #[test]