Skip to content

Commit 789825f

Browse files
authored
cipher: remove AsyncStreamCipher trait (#2280)
This trait is used only by the CFB mode. It either should be reworked (see #2083) or replaced with inherent methods in the `cfb-mode` crate. To not block the v0.5 release, it's worth to simply remove it for now.
1 parent 8e54074 commit 789825f

2 files changed

Lines changed: 2 additions & 74 deletions

File tree

cipher/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
### Removed
1717
- `BlockCipherEncrypt::encrypt_padded*` and `BlockCipherDecrypt::decrypt_padded*` methods.
1818
Users of the ECB mode should use the `ecb-mode` crate instead. ([#2245])
19+
- `AsyncStreamCipher` trait ([#2280])
1920

2021
[#1759]: https://github.com/RustCrypto/traits/pull/1759
2122
[#2052]: https://github.com/RustCrypto/traits/pull/2052
2223
[#2237]: https://github.com/RustCrypto/traits/pull/2237
2324
[#2245]: https://github.com/RustCrypto/traits/pull/2245
25+
[#2280]: https://github.com/RustCrypto/traits/pull/2280
2426

2527
## 0.4.4 (2022-03-09)
2628
### Changed

cipher/src/stream.rs

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
//! See the [RustCrypto/stream-ciphers](https://github.com/RustCrypto/stream-ciphers) repository
44
//! for ciphers implementation.
55
6-
use crate::block::{BlockModeDecrypt, BlockModeEncrypt};
7-
use common::Block;
86
use inout::{InOutBuf, NotEqualError};
97

108
mod core_api;
@@ -20,78 +18,6 @@ pub use errors::{OverflowError, StreamCipherError};
2018
#[cfg(feature = "stream-wrapper")]
2119
pub use wrapper::StreamCipherCoreWrapper;
2220

23-
/// Asynchronous stream cipher trait.
24-
pub trait AsyncStreamCipher: Sized {
25-
/// Encrypt data using `InOutBuf`.
26-
fn encrypt_inout(mut self, data: InOutBuf<'_, '_, u8>)
27-
where
28-
Self: BlockModeEncrypt,
29-
{
30-
let (blocks, mut tail) = data.into_chunks();
31-
self.encrypt_blocks_inout(blocks);
32-
let n = tail.len();
33-
if n != 0 {
34-
let mut block = Block::<Self>::default();
35-
block[..n].copy_from_slice(tail.get_in());
36-
self.encrypt_block(&mut block);
37-
tail.get_out().copy_from_slice(&block[..n]);
38-
}
39-
}
40-
41-
/// Decrypt data using `InOutBuf`.
42-
fn decrypt_inout(mut self, data: InOutBuf<'_, '_, u8>)
43-
where
44-
Self: BlockModeDecrypt,
45-
{
46-
let (blocks, mut tail) = data.into_chunks();
47-
self.decrypt_blocks_inout(blocks);
48-
let n = tail.len();
49-
if n != 0 {
50-
let mut block = Block::<Self>::default();
51-
block[..n].copy_from_slice(tail.get_in());
52-
self.decrypt_block(&mut block);
53-
tail.get_out().copy_from_slice(&block[..n]);
54-
}
55-
}
56-
/// Encrypt data in place.
57-
fn encrypt(self, buf: &mut [u8])
58-
where
59-
Self: BlockModeEncrypt,
60-
{
61-
self.encrypt_inout(buf.into());
62-
}
63-
64-
/// Decrypt data in place.
65-
fn decrypt(self, buf: &mut [u8])
66-
where
67-
Self: BlockModeDecrypt,
68-
{
69-
self.decrypt_inout(buf.into());
70-
}
71-
72-
/// Encrypt data from buffer to buffer.
73-
///
74-
/// # Errors
75-
/// Returns [`NotEqualError`] if provided `in_buf` and `out_buf` have different lengths.
76-
fn encrypt_b2b(self, in_buf: &[u8], out_buf: &mut [u8]) -> Result<(), NotEqualError>
77-
where
78-
Self: BlockModeEncrypt,
79-
{
80-
InOutBuf::new(in_buf, out_buf).map(|b| self.encrypt_inout(b))
81-
}
82-
83-
/// Decrypt data from buffer to buffer.
84-
///
85-
/// # Errors
86-
/// Returns [`NotEqualError`] if provided `in_buf` and `out_buf` have different lengths.
87-
fn decrypt_b2b(self, in_buf: &[u8], out_buf: &mut [u8]) -> Result<(), NotEqualError>
88-
where
89-
Self: BlockModeDecrypt,
90-
{
91-
InOutBuf::new(in_buf, out_buf).map(|b| self.decrypt_inout(b))
92-
}
93-
}
94-
9521
/// Stream cipher trait.
9622
///
9723
/// This trait applies only to synchronous stream ciphers, which generate a keystream and

0 commit comments

Comments
 (0)