Skip to content

Commit

Permalink
Replace block-cipher/stream-cipher with cipher crate
Browse files Browse the repository at this point in the history
This PR replaces all previous usages of the `block-cipher` and
`stream-cipher` crates with the new unified `cipher` crate.

See also: RustCrypto/traits#337
  • Loading branch information
tarcieri committed Oct 16, 2020
1 parent 7a44a86 commit 0e1efd5
Show file tree
Hide file tree
Showing 51 changed files with 252 additions and 281 deletions.
104 changes: 36 additions & 68 deletions Cargo.lock

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

7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ done with a minor version bump.

## Usage

Crates functionality is expressed in terms of traits defined in the
[`stream-cipher`][2] crate.
Crates functionality is expressed in terms of traits defined in the [`cipher`][2] crate.

Let's use AES-128-OFB to demonstrate usage of synchronous stream cipher:

Expand All @@ -44,7 +43,7 @@ use aes::Aes128;
use ofb::Ofb;

// import relevant traits
use ofb::stream_cipher::{NewStreamCipher, SyncStreamCipher};
use ofb::cipher::{NewStreamCipher, SyncStreamCipher};

// OFB mode implementation is generic over block ciphers
// we will create a type alias for convenience
Expand Down Expand Up @@ -98,7 +97,7 @@ dual licensed as above, without any additional terms or conditions.
[//]: # (footnotes)

[1]: https://en.wikipedia.org/wiki/Stream_cipher
[2]: https://docs.rs/stream-cipher
[2]: https://docs.rs/cipher

[//]: # (crates)

Expand Down
10 changes: 5 additions & 5 deletions aes-ctr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aes-ctr"
version = "0.5.0"
version = "0.6.0-pre"
description = "AES-CTR stream ciphers"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
Expand All @@ -12,14 +12,14 @@ readme = "README.md"
edition = "2018"

[dependencies]
stream-cipher = "0.8.0-pre"
cipher = "0.2"

[target.'cfg(not(all(target_feature = "aes", target_feature = "sse2", target_feature = "ssse3", any(target_arch = "x86_64", target_arch = "x86"))))'.dependencies]
ctr = { version = "0.6.0-pre", path = "../ctr" }
aes-soft = "0.5"
aes-soft = "0.6"

[target.'cfg(all(target_feature = "aes", target_feature = "sse2", target_feature = "ssse3", any(target_arch = "x86_64", target_arch = "x86")))'.dependencies]
aesni = "0.9"
aesni = "0.10"

[dev-dependencies]
stream-cipher = { version = "0.8.0-pre", features = ["dev"] }
cipher = { version = "0.2", features = ["dev"] }
2 changes: 1 addition & 1 deletion aes-ctr/benches/aes128_ctr.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#![feature(test)]

stream_cipher::bench_sync!(aes_ctr::Aes128Ctr);
cipher::bench_sync!(aes_ctr::Aes128Ctr);
2 changes: 1 addition & 1 deletion aes-ctr/benches/aes192_ctr.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#![feature(test)]

stream_cipher::bench_sync!(aes_ctr::Aes192Ctr);
cipher::bench_sync!(aes_ctr::Aes192Ctr);
2 changes: 1 addition & 1 deletion aes-ctr/benches/aes256_ctr.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#![feature(test)]

stream_cipher::bench_sync!(aes_ctr::Aes128Ctr);
cipher::bench_sync!(aes_ctr::Aes128Ctr);
12 changes: 7 additions & 5 deletions aes-ctr/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! AES-CTR ciphers implementation.
//!
//! Cipher functionality is accessed using traits from re-exported
//! [`stream-cipher`](https://docs.rs/stream-cipher) crate.
//! [`cipher`](https://docs.rs/cipher) crate.
//!
//! This crate will select appropriate implementation at compile time depending
//! on target architecture and enabled target features. For the best performance
Expand All @@ -16,9 +16,11 @@
//! # Usage example
//! ```
//! use aes_ctr::Aes128Ctr;
//! use aes_ctr::stream_cipher::generic_array::GenericArray;
//! use aes_ctr::stream_cipher::{
//! NewStreamCipher, SyncStreamCipher, SyncStreamCipherSeek
//! use aes_ctr::cipher::{
//! generic_array::GenericArray,
//! stream::{
//! NewStreamCipher, SyncStreamCipher, SyncStreamCipherSeek
//! }
//! };
//!
//! let mut data = [1, 2, 3, 4, 5, 6, 7];
Expand All @@ -45,7 +47,7 @@
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]
#![warn(missing_docs, rust_2018_idioms)]

pub use stream_cipher;
pub use cipher;

#[cfg(not(all(
target_feature = "aes",
Expand Down
9 changes: 4 additions & 5 deletions aes-ctr/tests/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#![no_std]

use aes_ctr::{Aes128Ctr, Aes256Ctr};
use stream_cipher::{new_seek_test, new_sync_test};

new_sync_test!(aes128_ctr_core, Aes128Ctr, "aes128-ctr");
new_sync_test!(aes256_ctr_core, Aes256Ctr, "aes256-ctr");
new_seek_test!(aes128_ctr_seek, Aes128Ctr);
new_seek_test!(aes256_ctr_seek, Aes256Ctr);
cipher::new_sync_test!(aes128_ctr_core, Aes128Ctr, "aes128-ctr");
cipher::new_sync_test!(aes256_ctr_core, Aes256Ctr, "aes256-ctr");
cipher::new_seek_test!(aes128_ctr_seek, Aes128Ctr);
cipher::new_seek_test!(aes256_ctr_seek, Aes256Ctr);
2 changes: 1 addition & 1 deletion benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ publish = false
[dev-dependencies]
criterion = "0.3"
criterion-cycles-per-byte = "0.1"
chacha20 = { path = "../chacha20/", features = ["stream-cipher"] }
chacha20 = { path = "../chacha20/", features = ["cipher"] }

[[bench]]
name = "chacha20"
Expand Down
4 changes: 2 additions & 2 deletions benches/src/chacha20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Through
use criterion_cycles_per_byte::CyclesPerByte;

use chacha20::{
stream_cipher::{NewStreamCipher, SyncStreamCipher},
cipher::{NewStreamCipher, SyncStreamCipher},
ChaCha20,
};

Expand Down Expand Up @@ -34,4 +34,4 @@ criterion_group!(
config = Criterion::default().with_measurement(CyclesPerByte);
targets = bench
);
criterion_main!(benches);
criterion_main!(benches);
8 changes: 4 additions & 4 deletions cfb-mode/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cfb-mode"
version = "0.5.0"
version = "0.6.0-pre"
description = "Generic Cipher Feedback (CFB) mode implementation."
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
Expand All @@ -12,9 +12,9 @@ readme = "README.md"
edition = "2018"

[dependencies]
stream-cipher = { version = "0.7", features = ["block-cipher"] }
cipher = "0.2"

[dev-dependencies]
aes = "0.5"
stream-cipher = { version = "0.7", features = ["dev"] }
aes = "0.6"
cipher = { version = "0.2", features = ["dev"] }
hex-literal = "0.2"
2 changes: 1 addition & 1 deletion cfb-mode/benches/cfb-mode.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#![feature(test)]

stream_cipher::bench_async!(cfb_mode::Cfb<aes::Aes128>);
cipher::bench_async!(cfb_mode::Cfb<aes::Aes128>);
Loading

0 comments on commit 0e1efd5

Please sign in to comment.