Skip to content

Commit 079b4ab

Browse files
authored
cipher: use block_buffer::ReadBuffer in StreamCipherCoreWrapper (#1959)
This simplifies the wrapper code and allows to mark the `cipher` crate with `#![forbid(unsafe_code)]`.
1 parent 441824a commit 079b4ab

File tree

7 files changed

+63
-181
lines changed

7 files changed

+63
-181
lines changed

Cargo.lock

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ signature = { path = "signature" }
2121
blobby = { git = "https://github.com/RustCrypto/utils" }
2222
# https://github.com/RustCrypto/utils/pull/1192
2323
# https://github.com/RustCrypto/utils/pull/1200
24-
block-buffer = { git = "https://github.com/RustCrypto/utils" }
24+
# https://github.com/RustCrypto/utils/pull/1201
25+
block-buffer = { git = "https://github.com/RustCrypto/utils", branch = "block-buffer/read-buf" }

cipher/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ inout = "0.2.0-rc.4"
1818

1919
# optional dependencies
2020
blobby = { version = "0.4.0-pre.0", optional = true }
21+
block-buffer = { version = "0.11.0-rc.4", optional = true}
2122
zeroize = { version = "1.8", optional = true, default-features = false }
2223

2324
[features]
2425
alloc = []
2526
block-padding = ["inout/block-padding"]
27+
stream-wrapper = ["block-buffer"]
2628
# Enable random key and IV generation methods
2729
rand_core = ["crypto-common/rand_core"]
2830
os_rng = ["crypto-common/os_rng", "rand_core"]
2931
dev = ["blobby"]
30-
zeroize = ["dep:zeroize", "crypto-common/zeroize"]
32+
zeroize = ["dep:zeroize", "crypto-common/zeroize", "block-buffer?/zeroize"]
3133

3234
[package.metadata.docs.rs]
3335
all-features = true

cipher/src/dev/stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ macro_rules! stream_cipher_test {
5757
);
5858

5959
for (i, tv) in TEST_VECTORS.iter().enumerate() {
60-
let res = $crate::dev::stream::stream_cipher_test(tv);
61-
if Err(reason) = res {
60+
let res = $crate::dev::stream::stream_cipher_test::<$cipher>(tv);
61+
if let Err(reason) = res {
6262
panic!(
6363
"\n\
6464
Failed test #{i}\n\

cipher/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
unused_lifetimes,
1818
missing_debug_implementations
1919
)]
20+
#![forbid(unsafe_code)]
2021

2122
#[cfg(feature = "alloc")]
2223
extern crate alloc;

cipher/src/stream.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ use inout::{InOutBuf, NotEqualError};
99

1010
mod core_api;
1111
mod errors;
12+
#[cfg(feature = "stream-wrapper")]
1213
mod wrapper;
1314

1415
pub use core_api::{
1516
StreamCipherBackend, StreamCipherClosure, StreamCipherCore, StreamCipherCounter,
1617
StreamCipherSeekCore,
1718
};
1819
pub use errors::{OverflowError, StreamCipherError};
20+
#[cfg(feature = "stream-wrapper")]
1921
pub use wrapper::StreamCipherCoreWrapper;
2022

2123
/// Marker trait for block-level asynchronous stream ciphers

0 commit comments

Comments
 (0)