diff --git a/Cargo.lock b/Cargo.lock index b6ba8363..d0863294 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,9 +40,9 @@ dependencies = [ [[package]] name = "cipher" -version = "0.5.0-pre.6" +version = "0.5.0-pre.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71c893d5a1e8257048dbb29954d2e1f85f091a150304f1defe4ca2806da5d3f" +checksum = "5b1425e6ce000f05a73096556cabcfb6a10a3ffe3bb4d75416ca8f00819c0b6a" dependencies = [ "blobby", "crypto-common", @@ -61,9 +61,9 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.2.0-rc.0" +version = "0.2.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c070b79a496dccd931229780ad5bbedd535ceff6c3565605a8e440e18e1aa2b" +checksum = "b0b8ce8218c97789f16356e7896b3714f26c2ee1079b79c0b7ae7064bb9089fa" dependencies = [ "getrandom", "hybrid-array", diff --git a/chacha20/Cargo.toml b/chacha20/Cargo.toml index d6642cd8..5d5328ad 100644 --- a/chacha20/Cargo.toml +++ b/chacha20/Cargo.toml @@ -20,7 +20,7 @@ categories = ["cryptography", "no-std"] [dependencies] cfg-if = "1" -cipher = { version = "=0.5.0-pre.6", optional = true } +cipher = { version = "=0.5.0-pre.7", optional = true } rand_core = { version = "0.9.0-alpha.1", optional = true, default-features = false } serde = { version = "1.0", features = ["derive"], optional = true } zeroize = { version = "1.8.1", optional = true } @@ -29,7 +29,7 @@ zeroize = { version = "1.8.1", optional = true } cpufeatures = "0.2" [dev-dependencies] -cipher = { version = "=0.5.0-pre.6", features = ["dev"] } +cipher = { version = "=0.5.0-pre.7", features = ["dev"] } hex-literal = "0.4" rand_chacha = "0.3.1" serde_json = "1.0" # Only to test serde1 diff --git a/chacha20/src/backends/avx2.rs b/chacha20/src/backends/avx2.rs index d0f05d12..2f2a7be5 100644 --- a/chacha20/src/backends/avx2.rs +++ b/chacha20/src/backends/avx2.rs @@ -5,19 +5,12 @@ use core::marker::PhantomData; use crate::{ChaChaCore, Variant}; #[cfg(feature = "cipher")] -use crate::{ - STATE_WORDS, - chacha::Block -}; +use crate::{chacha::Block, STATE_WORDS}; #[cfg(feature = "cipher")] use cipher::{ - StreamClosure, - consts::{U64, U4}, - BlockSizeUser, - ParBlocksSizeUser, - ParBlocks, - StreamBackend + consts::{U4, U64}, + BlockSizeUser, ParBlocks, ParBlocksSizeUser, StreamCipherBackend, StreamCipherClosure, }; #[cfg(target_arch = "x86")] @@ -36,7 +29,7 @@ const N: usize = PAR_BLOCKS / 2; pub(crate) unsafe fn inner(state: &mut [u32; STATE_WORDS], f: F) where R: Rounds, - F: StreamClosure, + F: StreamCipherClosure, { let state_ptr = state.as_ptr() as *const __m128i; let v = [ @@ -68,7 +61,7 @@ where pub(crate) unsafe fn rng_inner(core: &mut ChaChaCore, buffer: &mut [u32; 64]) where R: Rounds, - V: Variant + V: Variant, { let state_ptr = core.state.as_ptr() as *const __m128i; let v = [ @@ -111,7 +104,7 @@ impl ParBlocksSizeUser for Backend { } #[cfg(feature = "cipher")] -impl StreamBackend for Backend { +impl StreamCipherBackend for Backend { #[inline(always)] fn gen_ks_block(&mut self, block: &mut Block) { unsafe { diff --git a/chacha20/src/backends/neon.rs b/chacha20/src/backends/neon.rs index a4f0be5c..23c92075 100644 --- a/chacha20/src/backends/neon.rs +++ b/chacha20/src/backends/neon.rs @@ -15,7 +15,7 @@ use crate::chacha::Block; #[cfg(feature = "cipher")] use cipher::{ consts::{U4, U64}, - BlockSizeUser, ParBlocks, ParBlocksSizeUser, StreamBackend, StreamClosure, + BlockSizeUser, ParBlocks, ParBlocksSizeUser, StreamCipherBackend, StreamCipherClosure, }; struct Backend { @@ -53,7 +53,7 @@ impl Backend { pub(crate) unsafe fn inner(state: &mut [u32; STATE_WORDS], f: F) where R: Rounds, - F: StreamClosure, + F: StreamCipherClosure, { let mut backend = Backend::::new(state); @@ -105,7 +105,7 @@ macro_rules! add_assign_vec { } #[cfg(feature = "cipher")] -impl StreamBackend for Backend { +impl StreamCipherBackend for Backend { #[inline(always)] fn gen_ks_block(&mut self, block: &mut Block) { let state3 = self.state[3]; diff --git a/chacha20/src/backends/soft.rs b/chacha20/src/backends/soft.rs index 9cd4234f..68013c41 100644 --- a/chacha20/src/backends/soft.rs +++ b/chacha20/src/backends/soft.rs @@ -8,7 +8,7 @@ use crate::chacha::Block; #[cfg(feature = "cipher")] use cipher::{ consts::{U1, U64}, - BlockSizeUser, ParBlocksSizeUser, StreamBackend, + BlockSizeUser, ParBlocksSizeUser, StreamCipherBackend, }; pub(crate) struct Backend<'a, R: Rounds, V: Variant>(pub(crate) &'a mut ChaChaCore); @@ -24,7 +24,7 @@ impl<'a, R: Rounds, V: Variant> ParBlocksSizeUser for Backend<'a, R, V> { } #[cfg(feature = "cipher")] -impl<'a, R: Rounds, V: Variant> StreamBackend for Backend<'a, R, V> { +impl<'a, R: Rounds, V: Variant> StreamCipherBackend for Backend<'a, R, V> { #[inline(always)] fn gen_ks_block(&mut self, block: &mut Block) { let res = run_rounds::(&self.0.state); diff --git a/chacha20/src/backends/sse2.rs b/chacha20/src/backends/sse2.rs index 748c59c0..5238e38d 100644 --- a/chacha20/src/backends/sse2.rs +++ b/chacha20/src/backends/sse2.rs @@ -4,14 +4,11 @@ use crate::Rounds; use crate::{ChaChaCore, Variant}; #[cfg(feature = "cipher")] -use crate::{STATE_WORDS, chacha::Block}; +use crate::{chacha::Block, STATE_WORDS}; #[cfg(feature = "cipher")] use cipher::{ - StreamClosure, consts::{U1, U64}, - StreamBackend, - BlockSizeUser, - ParBlocksSizeUser + BlockSizeUser, ParBlocksSizeUser, StreamCipherBackend, StreamCipherClosure, }; use core::marker::PhantomData; @@ -26,7 +23,7 @@ use core::arch::x86_64::*; pub(crate) unsafe fn inner(state: &mut [u32; STATE_WORDS], f: F) where R: Rounds, - F: StreamClosure, + F: StreamCipherClosure, { let state_ptr = state.as_ptr() as *const __m128i; let mut backend = Backend:: { @@ -60,7 +57,7 @@ impl ParBlocksSizeUser for Backend { } #[cfg(feature = "cipher")] -impl StreamBackend for Backend { +impl StreamCipherBackend for Backend { #[inline(always)] fn gen_ks_block(&mut self, block: &mut Block) { unsafe { @@ -81,7 +78,7 @@ impl StreamBackend for Backend { pub(crate) unsafe fn rng_inner(core: &mut ChaChaCore, buffer: &mut [u32; 64]) where R: Rounds, - V: Variant + V: Variant, { let state_ptr = core.state.as_ptr() as *const __m128i; let mut backend = Backend:: { @@ -95,7 +92,7 @@ where }; for i in 0..4 { - backend.gen_ks_block(&mut buffer[i << 4..(i+1) << 4]); + backend.gen_ks_block(&mut buffer[i << 4..(i + 1) << 4]); } core.state[12] = _mm_cvtsi128_si32(backend.v[3]) as u32; diff --git a/chacha20/src/lib.rs b/chacha20/src/lib.rs index 60ec60a0..db67174e 100644 --- a/chacha20/src/lib.rs +++ b/chacha20/src/lib.rs @@ -286,7 +286,10 @@ impl StreamCipherCore for ChaChaCore { rem.try_into().ok() } - fn process_with_backend(&mut self, f: impl cipher::StreamClosure) { + fn process_with_backend( + &mut self, + f: impl cipher::StreamCipherClosure, + ) { cfg_if! { if #[cfg(chacha20_force_soft)] { f.call(&mut backends::soft::Backend(self)); diff --git a/chacha20/src/xchacha.rs b/chacha20/src/xchacha.rs index cc75416f..437808ea 100644 --- a/chacha20/src/xchacha.rs +++ b/chacha20/src/xchacha.rs @@ -3,8 +3,8 @@ use cipher::{ array::Array, consts::{U16, U24, U32, U64}, - BlockSizeUser, IvSizeUser, KeyIvInit, KeySizeUser, StreamCipherCore, StreamCipherCoreWrapper, - StreamCipherSeekCore, StreamClosure, + BlockSizeUser, IvSizeUser, KeyIvInit, KeySizeUser, StreamCipherClosure, StreamCipherCore, + StreamCipherCoreWrapper, StreamCipherSeekCore, }; use crate::{ @@ -75,7 +75,7 @@ impl StreamCipherCore for XChaChaCore { } #[inline(always)] - fn process_with_backend(&mut self, f: impl StreamClosure) { + fn process_with_backend(&mut self, f: impl StreamCipherClosure) { self.0.process_with_backend(f); } } diff --git a/hc-256/Cargo.toml b/hc-256/Cargo.toml index a18089af..ffc0d388 100644 --- a/hc-256/Cargo.toml +++ b/hc-256/Cargo.toml @@ -13,10 +13,10 @@ keywords = ["crypto", "stream-cipher", "trait"] categories = ["cryptography", "no-std"] [dependencies] -cipher = "=0.5.0-pre.6" +cipher = "=0.5.0-pre.7" [dev-dependencies] -cipher = { version = "=0.5.0-pre.6", features = ["dev"] } +cipher = { version = "=0.5.0-pre.7", features = ["dev"] } hex-literal = "0.4" [features] diff --git a/hc-256/src/lib.rs b/hc-256/src/lib.rs index d2511833..38ad0fd3 100644 --- a/hc-256/src/lib.rs +++ b/hc-256/src/lib.rs @@ -62,7 +62,8 @@ pub use cipher; use cipher::{ consts::{U1, U32, U4}, AlgorithmName, Block, BlockSizeUser, Iv, IvSizeUser, Key, KeyIvInit, KeySizeUser, - ParBlocksSizeUser, StreamBackend, StreamCipherCore, StreamCipherCoreWrapper, StreamClosure, + ParBlocksSizeUser, StreamCipherBackend, StreamCipherClosure, StreamCipherCore, + StreamCipherCoreWrapper, }; use core::fmt; @@ -157,7 +158,7 @@ impl StreamCipherCore for Hc256Core { None } - fn process_with_backend(&mut self, f: impl StreamClosure) { + fn process_with_backend(&mut self, f: impl StreamCipherClosure) { f.call(&mut Backend(self)); } } @@ -255,7 +256,7 @@ impl<'a> ParBlocksSizeUser for Backend<'a> { type ParBlocksSize = U1; } -impl<'a> StreamBackend for Backend<'a> { +impl<'a> StreamCipherBackend for Backend<'a> { #[inline(always)] fn gen_ks_block(&mut self, block: &mut Block) { block.copy_from_slice(&self.0.gen_word().to_le_bytes()); diff --git a/rabbit/Cargo.toml b/rabbit/Cargo.toml index 01767a7d..6d431dc6 100644 --- a/rabbit/Cargo.toml +++ b/rabbit/Cargo.toml @@ -13,10 +13,10 @@ keywords = ["crypto", "rabbit", "stream-cipher", "trait"] categories = ["cryptography", "no-std"] [dependencies] -cipher = "=0.5.0-pre.6" +cipher = "=0.5.0-pre.7" [dev-dependencies] -cipher = { version = "=0.5.0-pre.6", features = ["dev"] } +cipher = { version = "=0.5.0-pre.7", features = ["dev"] } hex-literal = "0.4" [features] diff --git a/rabbit/src/lib.rs b/rabbit/src/lib.rs index bab00d08..4c7f00ce 100644 --- a/rabbit/src/lib.rs +++ b/rabbit/src/lib.rs @@ -63,7 +63,7 @@ use cipher::{ consts::{U1, U16, U8}, crypto_common::InnerUser, Block, BlockSizeUser, InnerIvInit, IvSizeUser, KeyInit, KeySizeUser, ParBlocksSizeUser, - StreamBackend, StreamCipherCore, StreamCipherCoreWrapper, StreamClosure, + StreamCipherBackend, StreamCipherClosure, StreamCipherCore, StreamCipherCoreWrapper, }; #[cfg(feature = "zeroize")] @@ -290,7 +290,7 @@ impl StreamCipherCore for RabbitKeyOnlyCore { None } - fn process_with_backend(&mut self, f: impl StreamClosure) { + fn process_with_backend(&mut self, f: impl StreamCipherClosure) { f.call(&mut Backend(&mut self.state)); } } @@ -334,7 +334,7 @@ impl StreamCipherCore for RabbitCore { None } - fn process_with_backend(&mut self, f: impl StreamClosure) { + fn process_with_backend(&mut self, f: impl StreamCipherClosure) { f.call(&mut Backend(&mut self.state)); } } @@ -349,7 +349,7 @@ impl<'a> ParBlocksSizeUser for Backend<'a> { type ParBlocksSize = U1; } -impl<'a> StreamBackend for Backend<'a> { +impl<'a> StreamCipherBackend for Backend<'a> { #[inline(always)] fn gen_ks_block(&mut self, block: &mut Block) { block.copy_from_slice(&self.0.next_block()); diff --git a/rc4/Cargo.toml b/rc4/Cargo.toml index 8e06ba2a..c2d7e07a 100644 --- a/rc4/Cargo.toml +++ b/rc4/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["arc4", "arcfour", "crypto", "stream-cipher", "trait"] categories = ["cryptography", "no-std"] [dependencies] -cipher = "=0.5.0-pre.6" +cipher = "=0.5.0-pre.7" [dev-dependencies] hex-literal = "0.4" diff --git a/rc4/src/lib.rs b/rc4/src/lib.rs index c6097cea..7ee3a396 100644 --- a/rc4/src/lib.rs +++ b/rc4/src/lib.rs @@ -39,8 +39,8 @@ pub use cipher::{self, consts, KeyInit, StreamCipher}; use cipher::{ array::{Array, ArraySize}, - Block, BlockSizeUser, KeySizeUser, ParBlocksSizeUser, StreamBackend, StreamCipherCore, - StreamCipherCoreWrapper, StreamClosure, + Block, BlockSizeUser, KeySizeUser, ParBlocksSizeUser, StreamCipherBackend, StreamCipherClosure, + StreamCipherCore, StreamCipherCoreWrapper, }; use core::marker::PhantomData; @@ -94,7 +94,7 @@ impl StreamCipherCore for Rc4Core { None } - fn process_with_backend(&mut self, f: impl StreamClosure) { + fn process_with_backend(&mut self, f: impl StreamCipherClosure) { f.call(&mut Backend(&mut self.state)); } } @@ -113,7 +113,7 @@ impl<'a> ParBlocksSizeUser for Backend<'a> { type ParBlocksSize = consts::U1; } -impl<'a> StreamBackend for Backend<'a> { +impl<'a> StreamCipherBackend for Backend<'a> { #[inline(always)] fn gen_ks_block(&mut self, block: &mut Block) { block[0] = self.0.prga(); diff --git a/salsa20/Cargo.toml b/salsa20/Cargo.toml index 4e310a1c..675ef05b 100644 --- a/salsa20/Cargo.toml +++ b/salsa20/Cargo.toml @@ -14,10 +14,10 @@ categories = ["cryptography", "no-std"] [dependencies] cfg-if = "1" -cipher = "=0.5.0-pre.6" +cipher = "=0.5.0-pre.7" [dev-dependencies] -cipher = { version = "=0.5.0-pre.6", features = ["dev"] } +cipher = { version = "=0.5.0-pre.7", features = ["dev"] } hex-literal = "0.4" [features] diff --git a/salsa20/src/backends/soft.rs b/salsa20/src/backends/soft.rs index c7c2a91c..be8f9080 100644 --- a/salsa20/src/backends/soft.rs +++ b/salsa20/src/backends/soft.rs @@ -4,7 +4,7 @@ use crate::{Block, SalsaCore, Unsigned, STATE_WORDS}; use cipher::{ consts::{U1, U64}, - BlockSizeUser, ParBlocksSizeUser, StreamBackend, StreamCipherSeekCore, + BlockSizeUser, ParBlocksSizeUser, StreamCipherBackend, StreamCipherSeekCore, }; pub(crate) struct Backend<'a, R: Unsigned>(pub(crate) &'a mut SalsaCore); @@ -17,7 +17,7 @@ impl<'a, R: Unsigned> ParBlocksSizeUser for Backend<'a, R> { type ParBlocksSize = U1; } -impl<'a, R: Unsigned> StreamBackend for Backend<'a, R> { +impl<'a, R: Unsigned> StreamCipherBackend for Backend<'a, R> { #[inline(always)] fn gen_ks_block(&mut self, block: &mut Block) { let res = run_rounds::(&self.0.state); diff --git a/salsa20/src/backends/sse2.rs b/salsa20/src/backends/sse2.rs index 9ac21c30..7dcb0956 100644 --- a/salsa20/src/backends/sse2.rs +++ b/salsa20/src/backends/sse2.rs @@ -1,9 +1,10 @@ use crate::{ - backends::soft::Backend as SoftBackend, Block, SalsaCore, StreamClosure, Unsigned, STATE_WORDS, + backends::soft::Backend as SoftBackend, Block, SalsaCore, StreamCipherClosure, Unsigned, + STATE_WORDS, }; use cipher::{ consts::{U1, U64}, - BlockSizeUser, ParBlocksSizeUser, StreamBackend, + BlockSizeUser, ParBlocksSizeUser, StreamCipherBackend, }; use core::marker::PhantomData; @@ -17,7 +18,7 @@ use core::arch::x86_64::*; pub(crate) unsafe fn inner(state: &mut [u32; STATE_WORDS], f: F) where R: Unsigned, - F: StreamClosure, + F: StreamCipherClosure, { let state_ptr = state.as_ptr() as *const __m128i; let mut backend = Backend:: { @@ -55,7 +56,7 @@ impl ParBlocksSizeUser for Backend { type ParBlocksSize = U1; } -impl StreamBackend for Backend { +impl StreamCipherBackend for Backend { #[inline(always)] fn gen_ks_block(&mut self, block: &mut Block) { unsafe { diff --git a/salsa20/src/lib.rs b/salsa20/src/lib.rs index 2e3ad43d..c114c53f 100644 --- a/salsa20/src/lib.rs +++ b/salsa20/src/lib.rs @@ -80,8 +80,8 @@ pub use cipher; use cipher::{ array::{typenum::Unsigned, Array}, consts::{U10, U24, U32, U4, U6, U64, U8}, - Block, BlockSizeUser, IvSizeUser, KeyIvInit, KeySizeUser, StreamCipherCore, - StreamCipherCoreWrapper, StreamCipherSeekCore, StreamClosure, + Block, BlockSizeUser, IvSizeUser, KeyIvInit, KeySizeUser, StreamCipherClosure, + StreamCipherCore, StreamCipherCoreWrapper, StreamCipherSeekCore, }; use core::marker::PhantomData; @@ -202,7 +202,7 @@ impl StreamCipherCore for SalsaCore { let rem = u64::MAX - self.get_block_pos(); rem.try_into().ok() } - fn process_with_backend(&mut self, f: impl StreamClosure) { + fn process_with_backend(&mut self, f: impl StreamCipherClosure) { cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { unsafe { diff --git a/salsa20/src/xsalsa.rs b/salsa20/src/xsalsa.rs index 84505e72..a4795716 100644 --- a/salsa20/src/xsalsa.rs +++ b/salsa20/src/xsalsa.rs @@ -4,8 +4,8 @@ use super::{Key, Nonce, SalsaCore, Unsigned, XNonce, CONSTANTS}; use cipher::{ array::Array, consts::{U10, U16, U24, U32, U4, U6, U64}, - BlockSizeUser, IvSizeUser, KeyIvInit, KeySizeUser, StreamCipherCore, StreamCipherCoreWrapper, - StreamCipherSeekCore, StreamClosure, + BlockSizeUser, IvSizeUser, KeyIvInit, KeySizeUser, StreamCipherClosure, StreamCipherCore, + StreamCipherCoreWrapper, StreamCipherSeekCore, }; use crate::backends::soft::quarter_round; @@ -56,7 +56,7 @@ impl StreamCipherCore for XSalsaCore { } #[inline(always)] - fn process_with_backend(&mut self, f: impl StreamClosure) { + fn process_with_backend(&mut self, f: impl StreamCipherClosure) { self.0.process_with_backend(f); } }