Skip to content

Commit

Permalink
Use BlockCipherEncrypt/BlockCipherDecrypt trait names
Browse files Browse the repository at this point in the history
Updates the previous `BlockEncrypt`/`BlockEncrypt` trait names to use
the new ones introduced in RustCrypto/traits#1482
  • Loading branch information
tarcieri committed Jan 22, 2024
1 parent 6556a18 commit bdeaf6d
Show file tree
Hide file tree
Showing 26 changed files with 54 additions and 52 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ members = [

[profile.dev]
opt-level = 2

[patch.crates-io.cipher]
git = "https://github.com/RustCrypto/traits.git"
10 changes: 5 additions & 5 deletions aes/src/armv8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{Block, Block8};
use cipher::{
consts::{U16, U24, U32, U8},
inout::InOut,
AlgorithmName, BlockBackend, BlockCipher, BlockClosure, BlockDecrypt, BlockEncrypt,
AlgorithmName, BlockBackend, BlockCipher, BlockClosure, BlockCipherDecrypt, BlockCipherEncrypt,
BlockSizeUser, Key, KeyInit, KeySizeUser, ParBlocksSizeUser,
};
use core::arch::aarch64::*;
Expand Down Expand Up @@ -98,13 +98,13 @@ macro_rules! define_aes_impl {
type BlockSize = U16;
}

impl BlockEncrypt for $name {
impl BlockCipherEncrypt for $name {
fn encrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
self.encrypt.encrypt_with_backend(f)
}
}

impl BlockDecrypt for $name {
impl BlockCipherDecrypt for $name {
fn decrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
self.decrypt.decrypt_with_backend(f)
}
Expand Down Expand Up @@ -158,7 +158,7 @@ macro_rules! define_aes_impl {
type BlockSize = U16;
}

impl BlockEncrypt for $name_enc {
impl BlockCipherEncrypt for $name_enc {
fn encrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
f.call(&mut self.get_enc_backend())
}
Expand Down Expand Up @@ -233,7 +233,7 @@ macro_rules! define_aes_impl {
type BlockSize = U16;
}

impl BlockDecrypt for $name_dec {
impl BlockCipherDecrypt for $name_dec {
fn decrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
f.call(&mut self.get_dec_backend());
}
Expand Down
10 changes: 5 additions & 5 deletions aes/src/autodetect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::soft;
use cipher::{
consts::{U16, U24, U32},
AlgorithmName, BlockCipher, BlockClosure, BlockDecrypt, BlockEncrypt, BlockSizeUser, Key,
AlgorithmName, BlockCipher, BlockClosure, BlockCipherDecrypt, BlockCipherEncrypt, BlockSizeUser, Key,
KeyInit, KeySizeUser,
};
use core::fmt;
Expand Down Expand Up @@ -130,7 +130,7 @@ macro_rules! define_aes_impl {

impl BlockCipher for $name {}

impl BlockEncrypt for $name {
impl BlockCipherEncrypt for $name {
fn encrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
unsafe {
if self.token.get() {
Expand All @@ -149,7 +149,7 @@ macro_rules! define_aes_impl {
}
}

impl BlockDecrypt for $name {
impl BlockCipherDecrypt for $name {
fn decrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
unsafe {
if self.token.get() {
Expand Down Expand Up @@ -249,7 +249,7 @@ macro_rules! define_aes_impl {

impl BlockCipher for $name_enc {}

impl BlockEncrypt for $name_enc {
impl BlockCipherEncrypt for $name_enc {
fn encrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
unsafe {
if self.token.get() {
Expand Down Expand Up @@ -378,7 +378,7 @@ macro_rules! define_aes_impl {

impl BlockCipher for $name_dec {}

impl BlockDecrypt for $name_dec {
impl BlockCipherDecrypt for $name_dec {
fn decrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
unsafe {
if self.token.get() {
Expand Down
2 changes: 1 addition & 1 deletion aes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
//! ```
//! use aes::Aes128;
//! use aes::cipher::{
//! BlockCipher, BlockEncrypt, BlockDecrypt, KeyInit,
//! BlockCipher, BlockCipherEncrypt, BlockCipherDecrypt, KeyInit,
//! array::Array,
//! };
//!
Expand Down
10 changes: 5 additions & 5 deletions aes/src/ni.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::{Block, Block8};
use cipher::{
consts::{U16, U24, U32, U8},
inout::InOut,
AlgorithmName, BlockBackend, BlockCipher, BlockClosure, BlockDecrypt, BlockEncrypt,
AlgorithmName, BlockBackend, BlockCipher, BlockClosure, BlockCipherDecrypt, BlockCipherEncrypt,
BlockSizeUser, Key, KeyInit, KeySizeUser, ParBlocksSizeUser,
};
use core::fmt;
Expand Down Expand Up @@ -109,13 +109,13 @@ macro_rules! define_aes_impl {
type BlockSize = U16;
}

impl BlockEncrypt for $name {
impl BlockCipherEncrypt for $name {
fn encrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
self.encrypt.encrypt_with_backend(f)
}
}

impl BlockDecrypt for $name {
impl BlockCipherDecrypt for $name {
fn decrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
self.decrypt.decrypt_with_backend(f)
}
Expand Down Expand Up @@ -171,7 +171,7 @@ macro_rules! define_aes_impl {
type BlockSize = U16;
}

impl BlockEncrypt for $name_enc {
impl BlockCipherEncrypt for $name_enc {
fn encrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
f.call(&mut self.get_enc_backend())
}
Expand Down Expand Up @@ -246,7 +246,7 @@ macro_rules! define_aes_impl {
type BlockSize = U16;
}

impl BlockDecrypt for $name_dec {
impl BlockCipherDecrypt for $name_dec {
fn decrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
f.call(&mut self.get_dec_backend());
}
Expand Down
10 changes: 5 additions & 5 deletions aes/src/soft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::Block;
use cipher::{
consts::{U16, U24, U32},
inout::InOut,
AlgorithmName, BlockBackend, BlockCipher, BlockClosure, BlockDecrypt, BlockEncrypt,
AlgorithmName, BlockBackend, BlockCipher, BlockClosure, BlockCipherDecrypt, BlockCipherEncrypt,
BlockSizeUser, Key, KeyInit, KeySizeUser, ParBlocksSizeUser,
};
use core::fmt;
Expand Down Expand Up @@ -74,13 +74,13 @@ macro_rules! define_aes_impl {

impl BlockCipher for $name {}

impl BlockEncrypt for $name {
impl BlockCipherEncrypt for $name {
fn encrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
f.call(&mut self.get_enc_backend())
}
}

impl BlockDecrypt for $name {
impl BlockCipherDecrypt for $name {
fn decrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
f.call(&mut self.get_dec_backend())
}
Expand Down Expand Up @@ -155,7 +155,7 @@ macro_rules! define_aes_impl {
type BlockSize = U16;
}

impl BlockEncrypt for $name_enc {
impl BlockCipherEncrypt for $name_enc {
fn encrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
f.call(&mut self.get_enc_backend())
}
Expand Down Expand Up @@ -224,7 +224,7 @@ macro_rules! define_aes_impl {
type BlockSize = U16;
}

impl BlockDecrypt for $name_dec {
impl BlockCipherDecrypt for $name_dec {
fn decrypt_with_backend(&self, f: impl BlockClosure<BlockSize = U16>) {
f.call(&mut self.get_dec_backend());
}
Expand Down
2 changes: 1 addition & 1 deletion aria/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//! # Examples
//! ```
//! use aria::cipher::array::Array;
//! use aria::cipher::{Key, Block, BlockEncrypt, BlockDecrypt, KeyInit};
//! use aria::cipher::{Key, Block, BlockCipherEncrypt, BlockCipherDecrypt, KeyInit};
//! use aria::Aria128;
//!
//! let key = Array::from([0u8; 16]);
Expand Down
2 changes: 1 addition & 1 deletion aria/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use aria::{Aria128, Aria192, Aria256};
use cipher::{array::Array, BlockDecrypt, BlockEncrypt, KeyInit};
use cipher::{array::Array, BlockCipherDecrypt, BlockCipherEncrypt, KeyInit};
use hex_literal::hex;

/// Test vector from RFC 5794, Appendix A.1
Expand Down
2 changes: 1 addition & 1 deletion belt-block/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use belt_block::{belt_block_raw, belt_wblock_dec, belt_wblock_enc, to_u32};
#[cfg(feature = "cipher")]
use belt_block::{
cipher::{BlockDecrypt, BlockEncrypt, KeyInit},
cipher::{BlockCipherDecrypt, BlockCipherEncrypt, KeyInit},
BeltBlock,
};
use hex_literal::hex;
Expand Down
2 changes: 1 addition & 1 deletion camellia/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//! # Examples
//! ```
//! use camellia::cipher::array::Array;
//! use camellia::cipher::{BlockDecrypt, BlockEncrypt, KeyInit};
//! use camellia::cipher::{BlockCipherDecrypt, BlockCipherEncrypt, KeyInit};
//! use camellia::Camellia128;
//!
//! let key = Array::from([0_u8; 16]);
Expand Down
2 changes: 1 addition & 1 deletion cast5/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//! # Examples
//! ```
//! use cast5::cipher::array::Array;
//! use cast5::cipher::{Key, Block, BlockEncrypt, BlockDecrypt, KeyInit};
//! use cast5::cipher::{Key, Block, BlockCipherEncrypt, BlockCipherDecrypt, KeyInit};
//! use cast5::Cast5;
//!
//! let key = Array::from([0u8; 16]);
Expand Down
2 changes: 1 addition & 1 deletion cast5/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cast5::Cast5;
use cipher::{array::Array, BlockDecrypt, BlockEncrypt, KeyInit};
use cipher::{array::Array, BlockCipherDecrypt, BlockCipherEncrypt, KeyInit};
use hex_literal::hex;

/// Test vectors from RFC 2144 Appendix B.1
Expand Down
2 changes: 1 addition & 1 deletion cast6/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//! # Examples
//! ```
//! use cast6::cipher::array::Array;
//! use cast6::cipher::{Key, Block, BlockEncrypt, BlockDecrypt, KeyInit};
//! use cast6::cipher::{Key, Block, BlockCipherEncrypt, BlockCipherDecrypt, KeyInit};
//! use cast6::Cast6;
//!
//! let key = Array::from([0u8; 32]);
Expand Down
2 changes: 1 addition & 1 deletion cast6/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cast6::Cast6;
use cipher::{Block, BlockDecrypt, BlockEncrypt, KeyInit};
use cipher::{Block, BlockCipherDecrypt, BlockCipherEncrypt, KeyInit};
use hex_literal::hex;

/// Test vectors from RFC 2612 Appendix A
Expand Down
10 changes: 5 additions & 5 deletions kuznyechik/src/soft/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{BlockSize, Key, KeySize};
use cipher::{
AlgorithmName, BlockCipher, BlockClosure, BlockDecrypt, BlockEncrypt, BlockSizeUser, KeyInit,
AlgorithmName, BlockCipher, BlockClosure, BlockCipherDecrypt, BlockCipherEncrypt, BlockSizeUser, KeyInit,
KeySizeUser,
};
use core::fmt;
Expand Down Expand Up @@ -51,13 +51,13 @@ impl From<&KuznyechikEnc> for Kuznyechik {
}
}

impl BlockEncrypt for Kuznyechik {
impl BlockCipherEncrypt for Kuznyechik {
fn encrypt_with_backend(&self, f: impl BlockClosure<BlockSize = BlockSize>) {
f.call(&mut EncBackend(&self.keys));
}
}

impl BlockDecrypt for Kuznyechik {
impl BlockCipherDecrypt for Kuznyechik {
fn decrypt_with_backend(&self, f: impl BlockClosure<BlockSize = BlockSize>) {
f.call(&mut DecBackend(&self.keys));
}
Expand Down Expand Up @@ -111,7 +111,7 @@ impl KeyInit for KuznyechikEnc {
}
}

impl BlockEncrypt for KuznyechikEnc {
impl BlockCipherEncrypt for KuznyechikEnc {
fn encrypt_with_backend(&self, f: impl BlockClosure<BlockSize = BlockSize>) {
f.call(&mut EncBackend(&self.keys));
}
Expand Down Expand Up @@ -179,7 +179,7 @@ impl From<&KuznyechikEnc> for KuznyechikDec {
}
}

impl BlockDecrypt for KuznyechikDec {
impl BlockCipherDecrypt for KuznyechikDec {
fn decrypt_with_backend(&self, f: impl BlockClosure<BlockSize = BlockSize>) {
f.call(&mut DecBackend(&self.keys));
}
Expand Down
10 changes: 5 additions & 5 deletions kuznyechik/src/sse2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::{BlockSize, Key, KeySize};
use cipher::{
AlgorithmName, BlockCipher, BlockClosure, BlockDecrypt, BlockEncrypt, BlockSizeUser, KeyInit,
AlgorithmName, BlockCipher, BlockClosure, BlockCipherDecrypt, BlockCipherEncrypt, BlockSizeUser, KeyInit,
KeySizeUser,
};
use core::fmt;
Expand Down Expand Up @@ -60,13 +60,13 @@ impl From<&KuznyechikEnc> for Kuznyechik {
}
}

impl BlockEncrypt for Kuznyechik {
impl BlockCipherEncrypt for Kuznyechik {
fn encrypt_with_backend(&self, f: impl BlockClosure<BlockSize = BlockSize>) {
f.call(&mut EncBackend(&self.enc_keys));
}
}

impl BlockDecrypt for Kuznyechik {
impl BlockCipherDecrypt for Kuznyechik {
fn decrypt_with_backend(&self, f: impl BlockClosure<BlockSize = BlockSize>) {
f.call(&mut DecBackend(&self.dec_keys));
}
Expand Down Expand Up @@ -121,7 +121,7 @@ impl KeyInit for KuznyechikEnc {
}
}

impl BlockEncrypt for KuznyechikEnc {
impl BlockCipherEncrypt for KuznyechikEnc {
fn encrypt_with_backend(&self, f: impl BlockClosure<BlockSize = BlockSize>) {
f.call(&mut EncBackend(&self.keys));
}
Expand Down Expand Up @@ -194,7 +194,7 @@ impl From<&KuznyechikEnc> for KuznyechikDec {
}
}

impl BlockDecrypt for KuznyechikDec {
impl BlockCipherDecrypt for KuznyechikDec {
fn decrypt_with_backend(&self, f: impl BlockClosure<BlockSize = BlockSize>) {
f.call(&mut DecBackend(&self.keys));
}
Expand Down
2 changes: 1 addition & 1 deletion kuznyechik/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cipher::{Block, BlockDecrypt, BlockEncrypt, KeyInit};
use cipher::{Block, BlockCipherDecrypt, BlockCipherEncrypt, KeyInit};
use hex_literal::hex;
use kuznyechik::{Kuznyechik, KuznyechikDec, KuznyechikEnc};

Expand Down
2 changes: 1 addition & 1 deletion magma/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//! use magma::Magma;
//! use magma::cipher::{
//! array::Array,
//! BlockEncrypt, BlockDecrypt, KeyInit,
//! BlockCipherEncrypt, BlockCipherDecrypt, KeyInit,
//! };
//! use hex_literal::hex;
//!
Expand Down
2 changes: 1 addition & 1 deletion rc2/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cipher::array::Array;
use cipher::{BlockDecrypt, BlockEncrypt, KeyInit};
use cipher::{BlockCipherDecrypt, BlockCipherEncrypt, KeyInit};

struct Test {
key: &'static [u8],
Expand Down
6 changes: 3 additions & 3 deletions rc5/src/block_cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cipher::{
crypto_common::BlockSizes,
inout::InOut,
typenum::{Diff, IsLess, Le, NonZero, Sum, Unsigned, U1, U2, U256},
AlgorithmName, Block, BlockBackend, BlockCipher, BlockDecrypt, BlockEncrypt, BlockSizeUser,
AlgorithmName, Block, BlockBackend, BlockCipher, BlockCipherDecrypt, BlockCipherEncrypt, BlockSizeUser,
KeyInit, KeySizeUser, ParBlocksSizeUser,
};

Expand Down Expand Up @@ -95,7 +95,7 @@ where
type BlockSize = BlockSize<W>;
}

impl<W, R, B> BlockEncrypt for RC5<W, R, B>
impl<W, R, B> BlockCipherEncrypt for RC5<W, R, B>
where
W: Word,
// Block size
Expand Down Expand Up @@ -208,7 +208,7 @@ where
}
}

impl<W, R, B> BlockDecrypt for RC5<W, R, B>
impl<W, R, B> BlockCipherDecrypt for RC5<W, R, B>
where
W: Word,
// Block size
Expand Down
Loading

0 comments on commit bdeaf6d

Please sign in to comment.