Skip to content

Commit

Permalink
Add bytes feature passthrough (#631)
Browse files Browse the repository at this point in the history
This allows you to use a `BytesMut` as a `Buffer` with
`chacha20poly1305` (or other AEADs) by only including `chacha20poly1305`
in your Cargo.toml and not also having to include `aead` in your
Cargo.toml. This is similar to how `heapless` and `arrayvec` currently
have feature passthroughs.

Fixes #600
  • Loading branch information
davepollack authored Sep 27, 2024
1 parent 142027a commit add6b76
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 7 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions aes-gcm-siv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ default = ["aes", "alloc", "getrandom"]
std = ["aead/std", "alloc"]
alloc = ["aead/alloc"]
arrayvec = ["aead/arrayvec"]
bytes = ["aead/bytes"]
getrandom = ["aead/getrandom", "rand_core"]
heapless = ["aead/heapless"]
rand_core = ["aead/rand_core"]
Expand Down
4 changes: 3 additions & 1 deletion aes-gcm-siv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@
//!
//! Similarly, enabling the `arrayvec` feature of this crate will provide an impl of
//! [`aead::Buffer`] for `arrayvec::ArrayVec` (re-exported from the [`aead`] crate as
//! [`aead::arrayvec::ArrayVec`]).
//! [`aead::arrayvec::ArrayVec`]), and enabling the `bytes` feature of this crate will
//! provide an impl of [`aead::Buffer`] for `bytes::BytesMut` (re-exported from the
//! [`aead`] crate as [`aead::bytes::BytesMut`]).

pub use aead::{self, AeadCore, AeadInPlace, Error, Key, KeyInit, KeySizeUser};

Expand Down
1 change: 1 addition & 0 deletions aes-gcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ default = ["aes", "alloc", "getrandom"]
std = ["aead/std", "cipher/std", "alloc"]
alloc = ["aead/alloc"]
arrayvec = ["aead/arrayvec"]
bytes = ["aead/bytes"]
getrandom = ["aead/getrandom", "rand_core"]
heapless = ["aead/heapless"]
rand_core = ["aead/rand_core"]
Expand Down
4 changes: 3 additions & 1 deletion aes-gcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@
//!
//! Similarly, enabling the `arrayvec` feature of this crate will provide an impl of
//! [`aead::Buffer`] for `arrayvec::ArrayVec` (re-exported from the [`aead`] crate as
//! [`aead::arrayvec::ArrayVec`]).
//! [`aead::arrayvec::ArrayVec`]), and enabling the `bytes` feature of this crate will
//! provide an impl of [`aead::Buffer`] for `bytes::BytesMut` (re-exported from the
//! [`aead`] crate as [`aead::bytes::BytesMut`]).

pub use aead::{self, AeadCore, AeadInPlace, Error, Key, KeyInit, KeySizeUser};

Expand Down
1 change: 1 addition & 0 deletions aes-siv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ default = ["alloc", "getrandom"]
std = ["aead/std", "alloc"]
alloc = ["aead/alloc"]
arrayvec = ["aead/arrayvec"]
bytes = ["aead/bytes"]
getrandom = ["aead/getrandom", "rand_core"]
heapless = ["aead/heapless"]
rand_core = ["aead/rand_core"]
Expand Down
4 changes: 3 additions & 1 deletion aes-siv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@
//!
//! Similarly, enabling the `arrayvec` feature of this crate will provide an impl of
//! [`aead::Buffer`] for `arrayvec::ArrayVec` (re-exported from the [`aead`] crate as
//! [`aead::arrayvec::ArrayVec`]).
//! [`aead::arrayvec::ArrayVec`]), and enabling the `bytes` feature of this crate will
//! provide an impl of [`aead::Buffer`] for `bytes::BytesMut` (re-exported from the
//! [`aead`] crate as [`aead::bytes::BytesMut`]).

#[cfg(feature = "alloc")]
extern crate alloc;
Expand Down
1 change: 1 addition & 0 deletions ascon-aead/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ default = ["alloc", "getrandom"]
std = ["aead/std", "alloc"]
alloc = ["aead/alloc"]
arrayvec = ["aead/arrayvec"]
bytes = ["aead/bytes"]
getrandom = ["aead/getrandom", "rand_core"]
heapless = ["aead/heapless"]
rand_core = ["aead/rand_core"]
Expand Down
5 changes: 4 additions & 1 deletion ascon-aead/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@
//! ```
//!
//! Similarly, enabling the `arrayvec` feature of this crate will provide an impl of
//! [`aead::Buffer`] for `arrayvec::ArrayVec`.
//! [`aead::Buffer`] for `arrayvec::ArrayVec` (re-exported from the [`aead`] crate as
//! [`aead::arrayvec::ArrayVec`]), and enabling the `bytes` feature of this crate will
//! provide an impl of [`aead::Buffer`] for `bytes::BytesMut` (re-exported from the
//! [`aead`] crate as [`aead::bytes::BytesMut`]).

#[cfg(feature = "zeroize")]
pub use zeroize;
Expand Down
1 change: 1 addition & 0 deletions ccm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ default = ["alloc", "getrandom"]
std = ["aead/std", "alloc"]
alloc = ["aead/alloc"]
arrayvec = ["aead/arrayvec"]
bytes = ["aead/bytes"]
getrandom = ["aead/getrandom", "rand_core"]
heapless = ["aead/heapless"]
rand_core = ["aead/rand_core"]
Expand Down
1 change: 1 addition & 0 deletions chacha20poly1305/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ default = ["alloc", "getrandom"]
std = ["aead/std", "alloc"]
alloc = ["aead/alloc"]
arrayvec = ["aead/arrayvec"]
bytes = ["aead/bytes"]
getrandom = ["aead/getrandom", "rand_core"]
heapless = ["aead/heapless"]
rand_core = ["aead/rand_core"]
Expand Down
4 changes: 3 additions & 1 deletion chacha20poly1305/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@
//!
//! Similarly, enabling the `arrayvec` feature of this crate will provide an impl of
//! [`aead::Buffer`] for `arrayvec::ArrayVec` (re-exported from the [`aead`] crate as
//! [`aead::arrayvec::ArrayVec`]).
//! [`aead::arrayvec::ArrayVec`]), and enabling the `bytes` feature of this crate will
//! provide an impl of [`aead::Buffer`] for `bytes::BytesMut` (re-exported from the
//! [`aead`] crate as [`aead::bytes::BytesMut`]).
//!
//! ## [`XChaCha20Poly1305`]
//!
Expand Down
1 change: 1 addition & 0 deletions deoxys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ default = ["alloc", "getrandom"]
std = ["aead/std", "alloc"]
alloc = ["aead/alloc"]
arrayvec = ["aead/arrayvec"]
bytes = ["aead/bytes"]
getrandom = ["aead/getrandom", "rand_core"]
heapless = ["aead/heapless"]
rand_core = ["aead/rand_core"]
Expand Down
4 changes: 3 additions & 1 deletion deoxys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@
//!
//! Similarly, enabling the `arrayvec` feature of this crate will provide an impl of
//! [`aead::Buffer`] for `arrayvec::ArrayVec` (re-exported from the [`aead`] crate as
//! [`aead::arrayvec::ArrayVec`]).
//! [`aead::arrayvec::ArrayVec`]), and enabling the `bytes` feature of this crate will
//! provide an impl of [`aead::Buffer`] for `bytes::BytesMut` (re-exported from the
//! [`aead`] crate as [`aead::bytes::BytesMut`]).

/// Deoxys-BC implementations.
mod deoxys_bc;
Expand Down
1 change: 1 addition & 0 deletions eax/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ default = ["alloc", "getrandom"]
std = ["aead/std", "alloc"]
alloc = ["aead/alloc"]
arrayvec = ["aead/arrayvec"]
bytes = ["aead/bytes"]
getrandom = ["aead/getrandom", "rand_core"]
heapless = ["aead/heapless"]
rand_core = ["aead/rand_core"]
Expand Down
4 changes: 3 additions & 1 deletion eax/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@
//!
//! Similarly, enabling the `arrayvec` feature of this crate will provide an impl of
//! [`aead::Buffer`] for `arrayvec::ArrayVec` (re-exported from the [`aead`] crate as
//! [`aead::arrayvec::ArrayVec`]).
//! [`aead::arrayvec::ArrayVec`]), and enabling the `bytes` feature of this crate will
//! provide an impl of [`aead::Buffer`] for `bytes::BytesMut` (re-exported from the
//! [`aead`] crate as [`aead::bytes::BytesMut`]).
//!
//! ## Custom Tag Length
//!
Expand Down
7 changes: 7 additions & 0 deletions mgm/Cargo.lock

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

1 change: 1 addition & 0 deletions mgm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ default = ["alloc", "getrandom"]
std = ["aead/std", "alloc"]
alloc = ["aead/alloc"]
arrayvec = ["aead/arrayvec"]
bytes = ["aead/bytes"]
getrandom = ["aead/getrandom", "rand_core"]
heapless = ["aead/heapless"]
rand_core = ["aead/rand_core"]
Expand Down
1 change: 1 addition & 0 deletions ocb3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ default = ["alloc", "getrandom"]
std = ["aead/std", "alloc"]
alloc = ["aead/alloc"]
arrayvec = ["aead/arrayvec"]
bytes = ["aead/bytes"]
getrandom = ["aead/getrandom", "rand_core"]
heapless = ["aead/heapless"]
rand_core = ["aead/rand_core"]
Expand Down

0 comments on commit add6b76

Please sign in to comment.