Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/rc6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
matrix:
rust:
- 1.65.0 # MSRVs
- 1.85.0 # MSRVs
- stable
target:
- thumbv7em-none-eabi
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions rc6/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
[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"
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 = []
54 changes: 20 additions & 34 deletions rc6/src/block_cipher.rs
Original file line number Diff line number Diff line change
@@ -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<W, R, B> KeyInit for RC6<W, R, B>
where
Expand Down Expand Up @@ -59,23 +62,6 @@ where
type KeySize = B;
}

impl<W, R, B> BlockCipher for RC6<W, R, B>
where
W: Word,
// Block size
W::Bytes: Mul<U4>,
BlockSize<W>: BlockSizes,
// Rounds range
R: Unsigned,
R: IsLess<U256>,
Le<R, U256>: NonZero,
// ExpandedKeyTableSize
R: Add<U2>,
Sum<R, U2>: Mul<U2>,
ExpandedKeyTableSize<R>: ArraySize,
{
}

impl<W, R, B> BlockSizeUser for RC6<W, R, B>
where
W: Word,
Expand Down Expand Up @@ -118,8 +104,8 @@ where
Diff<Sum<B, W::Bytes>, U1>: Div<W::Bytes>,
KeyAsWordsSize<W, B>: ArraySize,
{
fn encrypt_with_backend(&self, f: impl cipher::BlockClosure<BlockSize = Self::BlockSize>) {
f.call(&mut RC6EncryptBackend { enc_dec: self })
fn encrypt_with_backend(&self, f: impl BlockCipherEncClosure<BlockSize = Self::BlockSize>) {
f.call(&RC6EncryptBackend { enc_dec: self })
}
}

Expand All @@ -140,7 +126,7 @@ where
{
enc_dec: &'a RC6<W, R, B>,
}
impl<'a, W, R, B> BlockSizeUser for RC6EncryptBackend<'a, W, R, B>
impl<W, R, B> BlockSizeUser for RC6EncryptBackend<'_, W, R, B>
where
W: Word,
// Block size
Expand All @@ -158,7 +144,7 @@ where
type BlockSize = BlockSize<W>;
}

impl<'a, W, R, B> ParBlocksSizeUser for RC6EncryptBackend<'a, W, R, B>
impl<W, R, B> ParBlocksSizeUser for RC6EncryptBackend<'_, W, R, B>
where
W: Word,
// Block size
Expand All @@ -176,7 +162,7 @@ where
type ParBlocksSize = U1;
}

impl<'a, W, R, B> BlockBackend for RC6EncryptBackend<'a, W, R, B>
impl<W, R, B> BlockCipherEncBackend for RC6EncryptBackend<'_, W, R, B>
where
W: Word,
// Block size
Expand All @@ -191,7 +177,7 @@ where
Sum<R, U2>: Mul<U2>,
ExpandedKeyTableSize<R>: ArraySize,
// Key range
B: BlockSizes,
B: ArraySize,
B: IsLess<U256>,
Le<B, U256>: NonZero,
// KeyAsWordsSize
Expand All @@ -201,7 +187,7 @@ where
KeyAsWordsSize<W, B>: ArraySize,
{
#[inline(always)]
fn proc_block(&mut self, block: InOut<'_, '_, Block<Self>>) {
fn encrypt_block(&self, block: InOut<'_, '_, Block<Self>>) {
let backend = self.enc_dec;
backend.encrypt(block)
}
Expand Down Expand Up @@ -231,8 +217,8 @@ where
Diff<Sum<B, W::Bytes>, U1>: Div<W::Bytes>,
KeyAsWordsSize<W, B>: ArraySize,
{
fn decrypt_with_backend(&self, f: impl cipher::BlockClosure<BlockSize = Self::BlockSize>) {
f.call(&mut RC6DecryptBackend { enc_dec: self })
fn decrypt_with_backend(&self, f: impl BlockCipherDecClosure<BlockSize = Self::BlockSize>) {
f.call(&RC6DecryptBackend { enc_dec: self })
}
}

Expand All @@ -253,7 +239,7 @@ where
{
enc_dec: &'a RC6<W, R, B>,
}
impl<'a, W, R, B> BlockSizeUser for RC6DecryptBackend<'a, W, R, B>
impl<W, R, B> BlockSizeUser for RC6DecryptBackend<'_, W, R, B>
where
W: Word,
// Block size
Expand All @@ -271,7 +257,7 @@ where
type BlockSize = BlockSize<W>;
}

impl<'a, W, R, B> ParBlocksSizeUser for RC6DecryptBackend<'a, W, R, B>
impl<W, R, B> ParBlocksSizeUser for RC6DecryptBackend<'_, W, R, B>
where
W: Word,
// Block size
Expand All @@ -289,7 +275,7 @@ where
type ParBlocksSize = U1;
}

impl<'a, W, R, B> BlockBackend for RC6DecryptBackend<'a, W, R, B>
impl<W, R, B> BlockCipherDecBackend for RC6DecryptBackend<'_, W, R, B>
where
W: Word,
// Block size
Expand All @@ -314,7 +300,7 @@ where
KeyAsWordsSize<W, B>: ArraySize,
{
#[inline(always)]
fn proc_block(&mut self, block: InOut<'_, '_, Block<Self>>) {
fn decrypt_block(&self, block: InOut<'_, '_, Block<Self>>) {
let backend = self.enc_dec;
backend.decrypt(block)
}
Expand Down
2 changes: 1 addition & 1 deletion rc6/src/core/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
2 changes: 1 addition & 1 deletion rc6/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down