Skip to content

Commit

Permalink
Use BlockCipherEncrypt/BlockCipherDecrypt trait names (RustCrypto…
Browse files Browse the repository at this point in the history
…#400)

Updates the previous `BlockEncrypt`/`BlockEncrypt` trait names to use
the new ones introduced in RustCrypto/traits#1482
  • Loading branch information
tarcieri authored Jan 22, 2024
1 parent 6556a18 commit 801e36b
Show file tree
Hide file tree
Showing 27 changed files with 59 additions and 56 deletions.
1 change: 1 addition & 0 deletions .github/workflows/speck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
- run: cargo build --no-default-features --release --target ${{ matrix.target }}

minimal-versions:
if: false # TODO: temp disabled due to unpublished prerelease dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
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, BlockCipherDecrypt, BlockCipherEncrypt, BlockClosure,
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
12 changes: 6 additions & 6 deletions aes/src/autodetect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use crate::soft;
use cipher::{
consts::{U16, U24, U32},
AlgorithmName, BlockCipher, BlockClosure, BlockDecrypt, BlockEncrypt, BlockSizeUser, Key,
KeyInit, KeySizeUser,
AlgorithmName, BlockCipher, BlockCipherDecrypt, BlockCipherEncrypt, BlockClosure,
BlockSizeUser, Key, KeyInit, KeySizeUser,
};
use core::fmt;
use core::mem::ManuallyDrop;
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, BlockCipherDecrypt, BlockCipherEncrypt, BlockClosure,
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, BlockCipherDecrypt, BlockCipherEncrypt, BlockClosure,
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
12 changes: 6 additions & 6 deletions kuznyechik/src/soft/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{BlockSize, Key, KeySize};
use cipher::{
AlgorithmName, BlockCipher, BlockClosure, BlockDecrypt, BlockEncrypt, BlockSizeUser, KeyInit,
KeySizeUser,
AlgorithmName, BlockCipher, BlockCipherDecrypt, BlockCipherEncrypt, BlockClosure,
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
12 changes: 6 additions & 6 deletions kuznyechik/src/sse2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use crate::{BlockSize, Key, KeySize};
use cipher::{
AlgorithmName, BlockCipher, BlockClosure, BlockDecrypt, BlockEncrypt, BlockSizeUser, KeyInit,
KeySizeUser,
AlgorithmName, BlockCipher, BlockCipherDecrypt, BlockCipherEncrypt, BlockClosure,
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
Loading

0 comments on commit 801e36b

Please sign in to comment.