diff --git a/.github/workflows/belt-dwp.yml b/.github/workflows/belt-dwp.yml index 1c43e249..7f5a17f5 100644 --- a/.github/workflows/belt-dwp.yml +++ b/.github/workflows/belt-dwp.yml @@ -78,5 +78,4 @@ jobs: - run: ${{ matrix.deps }} - run: cargo test --target ${{ matrix.target }} --release --no-default-features --lib - run: cargo test --target ${{ matrix.target }} --release - - run: cargo test --target ${{ matrix.target }} --release --features heapless - run: cargo test --target ${{ matrix.target }} --release --all-features diff --git a/Cargo.lock b/Cargo.lock index 5c4f9882..818b157b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,14 +6,12 @@ version = 4 [[package]] name = "aead" version = "0.6.0-rc.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac8202ab55fcbf46ca829833f347a82a2a4ce0596f0304ac322c2d100030cd56" +source = "git+https://github.com/RustCrypto/traits.git#219861dfcde81d2410dec55e64065e4c573c7be6" dependencies = [ "arrayvec", "blobby", "bytes", "crypto-common", - "heapless", "inout", ] @@ -145,8 +143,9 @@ checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "blobby" -version = "0.4.0-pre.0" -source = "git+https://github.com/RustCrypto/utils#a7e36d36cfc6ae0d804605b91731c7359eb43a95" +version = "0.4.0-pre.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4db6eec520c1f3d3b060c5b67527c3d1d4122d9f0ff47edf0149a7ffa34cebb" [[package]] name = "block-buffer" @@ -158,12 +157,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "bytes" version = "1.10.1" @@ -246,8 +239,7 @@ dependencies = [ [[package]] name = "crypto-common" version = "0.2.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8235645834fbc6832939736ce2f2d08192652269e11010a6240f61b908a1c6" +source = "git+https://github.com/RustCrypto/traits.git#219861dfcde81d2410dec55e64065e4c573c7be6" dependencies = [ "hybrid-array", "rand_core", @@ -326,25 +318,6 @@ dependencies = [ "polyval", ] -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - [[package]] name = "hex-literal" version = "0.4.1" @@ -462,12 +435,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "subtle" version = "2.6.1" diff --git a/Cargo.toml b/Cargo.toml index 544febda..052013a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,5 +19,5 @@ members = [ aead-stream = { path = "aead-stream" } aes-gcm = { path = "aes-gcm" } -# https://github.com/RustCrypto/utils/pull/1187 -blobby = { git = "https://github.com/RustCrypto/utils" } +aead = { git = "https://github.com/RustCrypto/traits.git" } +crypto-common = { git = "https://github.com/RustCrypto/traits.git" } diff --git a/aes-gcm-siv/Cargo.toml b/aes-gcm-siv/Cargo.toml index a5a873bd..9645a828 100644 --- a/aes-gcm-siv/Cargo.toml +++ b/aes-gcm-siv/Cargo.toml @@ -34,7 +34,6 @@ alloc = ["aead/alloc"] arrayvec = ["aead/arrayvec"] bytes = ["aead/bytes"] os_rng = ["aead/os_rng", "rand_core"] -heapless = ["aead/heapless"] rand_core = ["aead/rand_core"] [package.metadata.docs.rs] diff --git a/aes-gcm-siv/src/lib.rs b/aes-gcm-siv/src/lib.rs index 070f8e5d..d183642f 100644 --- a/aes-gcm-siv/src/lib.rs +++ b/aes-gcm-siv/src/lib.rs @@ -38,17 +38,20 @@ //! methods accept any type that impls the [`aead::Buffer`] trait which //! contains the plaintext for encryption or ciphertext for decryption. //! -//! Note that if you enable the `heapless` feature of this crate, -//! you will receive an impl of [`aead::Buffer`] for `heapless::Vec` -//! (re-exported from the [`aead`] crate as [`aead::heapless::Vec`]), -//! which can then be passed as the `buffer` parameter to the in-place encrypt +//! 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`]), 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`]). +//! +//! It can then be passed as the `buffer` parameter to the in-place encrypt //! and decrypt methods: //! -#![cfg_attr(all(feature = "os_rng", feature = "heapless"), doc = "```")] -#![cfg_attr(not(all(feature = "os_rng", feature = "heapless")), doc = "```ignore")] +#![cfg_attr(all(feature = "os_rng", feature = "arrayvec"), doc = "```")] +#![cfg_attr(not(all(feature = "os_rng", feature = "arrayvec")), doc = "```ignore")] //! # fn main() -> Result<(), Box> { //! use aes_gcm_siv::{ -//! aead::{AeadInOut, KeyInit, rand_core::OsRng, heapless::Vec}, +//! aead::{AeadInOut, Buffer, KeyInit, rand_core::OsRng, arrayvec::ArrayVec}, //! Aes256GcmSiv, Nonce, // Or `Aes128GcmSiv` //! }; //! @@ -56,27 +59,21 @@ //! let cipher = Aes256GcmSiv::new(&key); //! let nonce = Nonce::from_slice(b"unique nonce"); // 96-bits; unique per message //! -//! let mut buffer: Vec = Vec::new(); // Note: buffer needs 16-bytes overhead for auth tag +//! let mut buffer: ArrayVec = ArrayVec::new(); // Note: buffer needs 16-bytes overhead for auth tag //! buffer.extend_from_slice(b"plaintext message"); //! //! // Encrypt `buffer` in-place, replacing the plaintext contents with ciphertext //! cipher.encrypt_in_place(nonce, b"", &mut buffer)?; //! //! // `buffer` now contains the message ciphertext -//! assert_ne!(&buffer, b"plaintext message"); +//! assert_ne!(buffer.as_ref(), b"plaintext message"); //! //! // Decrypt `buffer` in-place, replacing its ciphertext context with the original plaintext //! cipher.decrypt_in_place(nonce, b"", &mut buffer)?; -//! assert_eq!(&buffer, b"plaintext message"); +//! assert_eq!(buffer.as_ref(), b"plaintext message"); //! # Ok(()) //! # } //! ``` -//! -//! 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`]), 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, AeadInOut, Error, Key, KeyInit, KeySizeUser}; diff --git a/aes-gcm/Cargo.toml b/aes-gcm/Cargo.toml index fe75c3aa..48967dfb 100644 --- a/aes-gcm/Cargo.toml +++ b/aes-gcm/Cargo.toml @@ -35,7 +35,6 @@ alloc = ["aead/alloc"] arrayvec = ["aead/arrayvec"] bytes = ["aead/bytes"] os_rng = ["aead/os_rng", "rand_core"] -heapless = ["aead/heapless"] rand_core = ["aead/rand_core"] [package.metadata.docs.rs] diff --git a/aes-gcm/src/lib.rs b/aes-gcm/src/lib.rs index 90d41b64..def1bf4c 100644 --- a/aes-gcm/src/lib.rs +++ b/aes-gcm/src/lib.rs @@ -12,8 +12,8 @@ //! //! Simple usage (allocating, no associated data): //! -#![cfg_attr(all(feature = "os_rng", feature = "heapless"), doc = "```")] -#![cfg_attr(not(all(feature = "os_rng", feature = "heapless")), doc = "```ignore")] +#![cfg_attr(feature = "os_rng", doc = "```")] +#![cfg_attr(not(feature = "os_rng"), doc = "```ignore")] //! use aes_gcm::{ //! aead::{Aead, AeadCore, KeyInit, rand_core::OsRng}, //! Aes256Gcm, Nonce, Key // Or `Aes128Gcm` @@ -58,17 +58,20 @@ //! methods accept any type that impls the [`aead::Buffer`] trait which //! contains the plaintext for encryption or ciphertext for decryption. //! -//! Note that if you enable the `heapless` feature of this crate, -//! you will receive an impl of [`aead::Buffer`] for `heapless::Vec` -//! (re-exported from the [`aead`] crate as [`aead::heapless::Vec`]), -//! which can then be passed as the `buffer` parameter to the in-place encrypt +//! 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`]), 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`]). +//! +//! It can then be passed as the `buffer` parameter to the in-place encrypt //! and decrypt methods: //! -#![cfg_attr(all(feature = "os_rng", feature = "heapless"), doc = "```")] -#![cfg_attr(not(all(feature = "os_rng", feature = "heapless")), doc = "```ignore")] +#![cfg_attr(all(feature = "os_rng", feature = "arrayvec"), doc = "```")] +#![cfg_attr(not(all(feature = "os_rng", feature = "arrayvec")), doc = "```ignore")] //! # fn main() -> Result<(), Box> { //! use aes_gcm::{ -//! aead::{AeadCore, AeadInOut, KeyInit, rand_core::OsRng, heapless::Vec}, +//! aead::{AeadCore, AeadInOut, KeyInit, rand_core::OsRng, arrayvec::ArrayVec}, //! Aes256Gcm, Nonce, // Or `Aes128Gcm` //! }; //! @@ -76,27 +79,20 @@ //! let cipher = Aes256Gcm::new(&key); //! let nonce = Aes256Gcm::generate_nonce().expect("generate nonce"); // 96-bits; unique per message //! -//! let mut buffer: Vec = Vec::new(); // Note: buffer needs 16-bytes overhead for auth tag -//! buffer.extend_from_slice(b"plaintext message"); +//! let mut buffer: ArrayVec = ArrayVec::new(); // Note: buffer needs 16-bytes overhead for auth tag +//! buffer.try_extend_from_slice(b"plaintext message").unwrap(); //! //! // Encrypt `buffer` in-place, replacing the plaintext contents with ciphertext //! cipher.encrypt_in_place(&nonce, b"", &mut buffer)?; //! //! // `buffer` now contains the message ciphertext -//! assert_ne!(&buffer, b"plaintext message"); +//! assert_ne!(buffer.as_ref(), b"plaintext message"); //! //! // Decrypt `buffer` in-place, replacing its ciphertext context with the original plaintext //! cipher.decrypt_in_place(&nonce, b"", &mut buffer)?; -//! assert_eq!(&buffer, b"plaintext message"); +//! assert_eq!(buffer.as_ref(), b"plaintext message"); //! # Ok(()) //! # } -//! ``` -//! -//! 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`]), 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, AeadInOut, Error, Key, KeyInit, KeySizeUser}; diff --git a/aes-siv/Cargo.toml b/aes-siv/Cargo.toml index 83bc2169..0f196759 100644 --- a/aes-siv/Cargo.toml +++ b/aes-siv/Cargo.toml @@ -40,7 +40,6 @@ alloc = ["aead/alloc"] arrayvec = ["aead/arrayvec"] bytes = ["aead/bytes"] os_rng = ["aead/os_rng", "rand_core"] -heapless = ["aead/heapless"] rand_core = ["aead/rand_core"] [package.metadata.docs.rs] diff --git a/aes-siv/src/lib.rs b/aes-siv/src/lib.rs index dc05de90..391532dd 100644 --- a/aes-siv/src/lib.rs +++ b/aes-siv/src/lib.rs @@ -38,17 +38,20 @@ //! methods accept any type that impls the [`aead::Buffer`] trait which //! contains the plaintext for encryption or ciphertext for decryption. //! -//! Note that if you enable the `heapless` feature of this crate, -//! you will receive an impl of [`aead::Buffer`] for `heapless::Vec` -//! (re-exported from the [`aead`] crate as [`aead::heapless::Vec`]), -//! which can then be passed as the `buffer` parameter to the in-place encrypt +//! 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`]), 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`]). +//! +//! It can then be passed as the `buffer` parameter to the in-place encrypt //! and decrypt methods: //! -#![cfg_attr(all(feature = "os_rng", feature = "heapless"), doc = "```")] -#![cfg_attr(not(all(feature = "os_rng", feature = "heapless")), doc = "```ignore")] +#![cfg_attr(all(feature = "os_rng", feature = "arrayvec"), doc = "```")] +#![cfg_attr(not(all(feature = "os_rng", feature = "arrayvec")), doc = "```ignore")] //! # fn main() -> Result<(), Box> { //! use aes_siv::{ -//! aead::{AeadCore, AeadInOut, KeyInit, rand_core::OsRng, heapless::Vec}, +//! aead::{AeadCore, AeadInOut, KeyInit, rand_core::OsRng, arrayvec::ArrayVec}, //! Aes256SivAead, Nonce, // Or `Aes128SivAead` //! }; //! @@ -56,27 +59,21 @@ //! let cipher = Aes256SivAead::new(&key); //! let nonce = Aes256SivAead::generate_nonce().expect("Generate nonce"); // 128-bits; unique per message //! -//! let mut buffer: Vec = Vec::new(); // Note: buffer needs 16-bytes overhead for auth tag -//! buffer.extend_from_slice(b"plaintext message"); +//! let mut buffer: ArrayVec = ArrayVec::new(); // Note: buffer needs 16-bytes overhead for auth tag +//! buffer.try_extend_from_slice(b"plaintext message").unwrap(); //! //! // Encrypt `buffer` in-place, replacing the plaintext contents with ciphertext //! cipher.encrypt_in_place(&nonce, b"", &mut buffer)?; //! //! // `buffer` now contains the message ciphertext -//! assert_ne!(&buffer, b"plaintext message"); +//! assert_ne!(buffer.as_ref(), b"plaintext message"); //! //! // Decrypt `buffer` in-place, replacing its ciphertext context with the original plaintext //! cipher.decrypt_in_place(&nonce, b"", &mut buffer)?; -//! assert_eq!(&buffer, b"plaintext message"); +//! assert_eq!(buffer.as_ref(), b"plaintext message"); //! # Ok(()) //! # } //! ``` -//! -//! 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`]), 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; diff --git a/ascon-aead128/Cargo.toml b/ascon-aead128/Cargo.toml index 3fe2e48d..fe3762ff 100644 --- a/ascon-aead128/Cargo.toml +++ b/ascon-aead128/Cargo.toml @@ -26,7 +26,6 @@ alloc = ["aead/alloc"] arrayvec = ["aead/arrayvec"] bytes = ["aead/bytes"] os_rng = ["aead/os_rng", "rand_core"] -heapless = ["aead/heapless"] rand_core = ["aead/rand_core"] zeroize = ["dep:zeroize", "ascon/zeroize"] diff --git a/ascon-aead128/src/lib.rs b/ascon-aead128/src/lib.rs index 3cff18ac..62ab84e5 100644 --- a/ascon-aead128/src/lib.rs +++ b/ascon-aead128/src/lib.rs @@ -62,43 +62,40 @@ //! methods accept any type that impls the [`aead::Buffer`] trait which //! contains the plaintext for encryption or ciphertext for decryption. //! -//! Note that if you enable the `heapless` feature of this crate, -//! you will receive an impl of [`aead::Buffer`] for `heapless::Vec` -//! (re-exported from the [`aead`] crate as [`aead::heapless::Vec`]), -//! which can then be passed as the `buffer` parameter to the in-place encrypt +//! 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`]), 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`]). +//! +//! It can then be passed as the `buffer` parameter to the in-place encrypt //! and decrypt methods: //! //! ``` -//! # #[cfg(feature = "heapless")] { +//! # #[cfg(feature = "arrayvec")] { //! use ascon_aead128::{AsconAead128, Key, Nonce}; //! use ascon_aead128::aead::{AeadInOut, KeyInit}; -//! use ascon_aead128::aead::heapless::Vec; +//! use ascon_aead128::aead::arrayvec::ArrayVec; //! //! let key = Key::::from_slice(b"very secret key."); //! let cipher = AsconAead128::new(key); //! //! let nonce = Nonce::::from_slice(b"unique nonce 012"); // 128-bits; unique per message //! -//! let mut buffer: Vec = Vec::new(); // Buffer needs 16-bytes overhead for authentication tag -//! buffer.extend_from_slice(b"plaintext message"); +//! let mut buffer: ArrayVec = ArrayVec::new(); // Buffer needs 16-bytes overhead for authentication tag +//! buffer.try_extend_from_slice(b"plaintext message").unwrap(); //! //! // Encrypt `buffer` in-place, replacing the plaintext contents with ciphertext //! cipher.encrypt_in_place(nonce, b"", &mut buffer).expect("encryption failure!"); //! //! // `buffer` now contains the message ciphertext -//! assert_ne!(&buffer, b"plaintext message"); +//! assert_ne!(buffer.as_ref(), b"plaintext message"); //! //! // Decrypt `buffer` in-place, replacing its ciphertext context with the original plaintext //! cipher.decrypt_in_place(nonce, b"", &mut buffer).expect("decryption failure!"); -//! assert_eq!(&buffer, b"plaintext message"); +//! assert_eq!(buffer.as_ref(), b"plaintext message"); //! # } //! ``` -//! -//! 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`]), 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; diff --git a/belt-dwp/Cargo.toml b/belt-dwp/Cargo.toml index 1ef128e3..c3016ec9 100644 --- a/belt-dwp/Cargo.toml +++ b/belt-dwp/Cargo.toml @@ -29,7 +29,6 @@ alloc = ["aead/alloc"] arrayvec = ["aead/arrayvec"] bytes = ["aead/bytes"] os_rng = ["aead/os_rng", "rand_core"] -heapless = ["aead/heapless"] rand_core = ["aead/rand_core"] reduced-round = [] zeroize = ["dep:zeroize", "belt-ctr/zeroize"] diff --git a/belt-dwp/src/lib.rs b/belt-dwp/src/lib.rs index 0f404115..899263e6 100644 --- a/belt-dwp/src/lib.rs +++ b/belt-dwp/src/lib.rs @@ -13,7 +13,7 @@ //! //! ``` //! # fn main() -> Result<(), Box> { -//! # #[cfg(all(feature = "os_rng", feature = "heapless"))] { +//! # #[cfg(feature = "os_rng")] { //! use belt_dwp::{ //! aead::{Aead, AeadCore, KeyInit}, Nonce, BeltDwp //! }; @@ -36,17 +36,18 @@ //! methods accept any type that impls the [`aead::Buffer`] trait which //! contains the plaintext for encryption or ciphertext for decryption. //! -//! Note that if you enable the `heapless` feature of this crate, -//! you will receive an impl of [`aead::Buffer`] for `heapless::Vec` -//! (re-exported from the [`aead`] crate as [`aead::heapless::Vec`]), -//! which can then be passed as the `buffer` parameter to the in-place encrypt +//! 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`]). +//! +//! It can then be passed as the `buffer` parameter to the in-place encrypt //! and decrypt methods: //! //! ``` //! # fn main() -> Result<(), Box> { -//! # #[cfg(all(feature = "os_rng", feature = "heapless"))] { +//! # #[cfg(all(feature = "os_rng", feature = "arrayvec"))] { //! use belt_dwp::{ -//! aead::{AeadInOut, KeyInit, heapless::Vec}, +//! aead::{AeadInOut, KeyInit, arrayvec::ArrayVec}, //! Nonce, BeltDwp //! }; //! @@ -54,24 +55,20 @@ //! let cipher = BeltDwp::new(&key); //! let nonce = Nonce::try_from(&b"unique nonce1234"[..]).unwrap(); // 128-bits; unique per message //! -//! let mut buffer: Vec = Vec::new(); // Note: buffer needs 16-bytes overhead for auth tag -//! buffer.extend_from_slice(b"plaintext message"); +//! let mut buffer: ArrayVec = ArrayVec::new(); // Note: buffer needs 16-bytes overhead for auth tag +//! buffer.try_extend_from_slice(b"plaintext message").unwrap(); //! //! // Encrypt `buffer` in-place, replacing the plaintext contents with ciphertext //! cipher.encrypt_in_place(&nonce, b"", &mut buffer)?; //! //! // `buffer` now contains the message ciphertext -//! assert_ne!(&buffer, b"plaintext message"); +//! assert_ne!(buffer.as_ref(), b"plaintext message"); //! //! // Decrypt `buffer` in-place, replacing its ciphertext context with the original plaintext //! cipher.decrypt_in_place(&nonce, b"", &mut buffer)?; -//! assert_eq!(&buffer, b"plaintext message"); +//! assert_eq!(buffer.as_ref(), b"plaintext message"); //! # }; Ok(()) } //! ``` -//! -//! 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`]). pub use aead::{self, AeadCore, AeadInOut, Error, Key, KeyInit, KeySizeUser, Tag}; pub use belt_block::BeltBlock; diff --git a/ccm/Cargo.toml b/ccm/Cargo.toml index 21f71c31..ebe9a796 100644 --- a/ccm/Cargo.toml +++ b/ccm/Cargo.toml @@ -30,5 +30,4 @@ alloc = ["aead/alloc"] arrayvec = ["aead/arrayvec"] bytes = ["aead/bytes"] os_rng = ["aead/os_rng", "rand_core"] -heapless = ["aead/heapless"] rand_core = ["aead/rand_core"] diff --git a/chacha20poly1305/Cargo.toml b/chacha20poly1305/Cargo.toml index c0d01e47..79c0905d 100644 --- a/chacha20poly1305/Cargo.toml +++ b/chacha20poly1305/Cargo.toml @@ -35,7 +35,6 @@ alloc = ["aead/alloc"] arrayvec = ["aead/arrayvec"] bytes = ["aead/bytes"] os_rng = ["aead/os_rng", "rand_core"] -heapless = ["aead/heapless"] rand_core = ["aead/rand_core"] reduced-round = [] zeroize = ["dep:zeroize", "chacha20/zeroize"] diff --git a/chacha20poly1305/src/lib.rs b/chacha20poly1305/src/lib.rs index d829f8a7..7625356b 100644 --- a/chacha20poly1305/src/lib.rs +++ b/chacha20poly1305/src/lib.rs @@ -50,17 +50,20 @@ //! methods accept any type that impls the [`aead::Buffer`] trait which //! contains the plaintext for encryption or ciphertext for decryption. //! -//! Note that if you enable the `heapless` feature of this crate, -//! you will receive an impl of [`aead::Buffer`] for `heapless::Vec` -//! (re-exported from the [`aead`] crate as [`aead::heapless::Vec`]), -//! which can then be passed as the `buffer` parameter to the in-place encrypt +//! 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`]), 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`]). +//! +//! It can then be passed as the `buffer` parameter to the in-place encrypt //! and decrypt methods: //! -#![cfg_attr(all(feature = "os_rng", feature = "heapless"), doc = "```")] -#![cfg_attr(not(all(feature = "os_rng", feature = "heapless")), doc = "```ignore")] +#![cfg_attr(all(feature = "os_rng", feature = "arrayvec"), doc = "```")] +#![cfg_attr(not(all(feature = "os_rng", feature = "arrayvec")), doc = "```ignore")] //! # fn main() -> Result<(), Box> { //! use chacha20poly1305::{ -//! aead::{AeadCore, AeadInOut, KeyInit, rand_core::OsRng, heapless::Vec}, +//! aead::{AeadCore, AeadInOut, KeyInit, rand_core::OsRng, arrayvec::ArrayVec}, //! ChaCha20Poly1305, Nonce, //! }; //! @@ -68,28 +71,22 @@ //! let cipher = ChaCha20Poly1305::new(&key); //! let nonce = ChaCha20Poly1305::generate_nonce().expect("Generate nonce"); // 96-bits; unique per message //! -//! let mut buffer: Vec = Vec::new(); // Note: buffer needs 16-bytes overhead for auth tag -//! buffer.extend_from_slice(b"plaintext message"); +//! let mut buffer: ArrayVec = ArrayVec::new(); // Note: buffer needs 16-bytes overhead for auth tag +//! buffer.try_extend_from_slice(b"plaintext message").unwrap(); //! //! // Encrypt `buffer` in-place, replacing the plaintext contents with ciphertext //! cipher.encrypt_in_place(&nonce, b"", &mut buffer)?; //! //! // `buffer` now contains the message ciphertext -//! assert_ne!(&buffer, b"plaintext message"); +//! assert_ne!(buffer.as_ref(), b"plaintext message"); //! //! // Decrypt `buffer` in-place, replacing its ciphertext context with the original plaintext //! cipher.decrypt_in_place(&nonce, b"", &mut buffer)?; -//! assert_eq!(&buffer, b"plaintext message"); +//! assert_eq!(buffer.as_ref(), b"plaintext message"); //! # Ok(()) //! # } //! ``` //! -//! 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`]), 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`] //! //! ChaCha20Poly1305 variant with an extended 192-bit (24-byte) nonce. diff --git a/deoxys/Cargo.toml b/deoxys/Cargo.toml index 3c510a7b..070f910a 100644 --- a/deoxys/Cargo.toml +++ b/deoxys/Cargo.toml @@ -33,7 +33,6 @@ alloc = ["aead/alloc"] arrayvec = ["aead/arrayvec"] bytes = ["aead/bytes"] os_rng = ["aead/os_rng", "rand_core"] -heapless = ["aead/heapless"] rand_core = ["aead/rand_core"] [package.metadata.docs.rs] diff --git a/deoxys/src/lib.rs b/deoxys/src/lib.rs index 4d9f92c6..59a0eacd 100644 --- a/deoxys/src/lib.rs +++ b/deoxys/src/lib.rs @@ -66,43 +66,40 @@ //! methods accept any type that impls the [`aead::Buffer`] trait which //! contains the plaintext for encryption or ciphertext for decryption. //! -//! Note that if you enable the `heapless` feature of this crate, -//! you will receive an impl of [`aead::Buffer`] for `heapless::Vec` -//! (re-exported from the [`aead`] crate as [`aead::heapless::Vec`]), -//! which can then be passed as the `buffer` parameter to the in-place encrypt +//! 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`]), 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`]). +//! +//! It can then be passed as the `buffer` parameter to the in-place encrypt //! and decrypt methods: //! //! ``` -//! # #[cfg(feature = "heapless")] +//! # #[cfg(feature = "arrayvec")] //! # { //! use deoxys::{DeoxysII256, Nonce}; // Can be `DeoxysI128`, `DeoxysI256`, `DeoxysII128` of `DeoxysII256` -//! use deoxys::aead::{AeadCore, AeadInOut, KeyInit, rand_core::OsRng, heapless::Vec}; +//! use deoxys::aead::{AeadCore, AeadInOut, KeyInit, rand_core::OsRng, arrayvec::ArrayVec}; //! //! let key = DeoxysII256::generate_key().expect("generate key"); //! let cipher = DeoxysII256::new(&key); //! //! let nonce = DeoxysII256::generate_nonce().expect("generate nonce"); // 120-bits; unique per message //! -//! let mut buffer: Vec = Vec::new(); // Buffer needs 16-bytes overhead for tag -//! buffer.extend_from_slice(b"plaintext message"); +//! let mut buffer: ArrayVec = ArrayVec::new(); // Buffer needs 16-bytes overhead for tag +//! buffer.try_extend_from_slice(b"plaintext message").unwrap(); //! //! // Encrypt `buffer` in-place, replacing the plaintext contents with ciphertext //! cipher.encrypt_in_place(&nonce, b"", &mut buffer).expect("encryption failure!"); //! //! // `buffer` now contains the message ciphertext -//! assert_ne!(&buffer, b"plaintext message"); +//! assert_ne!(buffer.as_ref(), b"plaintext message"); //! //! // Decrypt `buffer` in-place, replacing its ciphertext context with the original plaintext //! cipher.decrypt_in_place(&nonce, b"", &mut buffer).expect("decryption failure!"); -//! assert_eq!(&buffer, b"plaintext message"); +//! assert_eq!(buffer.as_ref(), b"plaintext message"); //! # } //! ``` -//! -//! 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`]), 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; diff --git a/eax/Cargo.toml b/eax/Cargo.toml index 855bb269..aacba994 100644 --- a/eax/Cargo.toml +++ b/eax/Cargo.toml @@ -36,7 +36,6 @@ alloc = ["aead/alloc"] arrayvec = ["aead/arrayvec"] bytes = ["aead/bytes"] os_rng = ["aead/os_rng", "rand_core"] -heapless = ["aead/heapless"] rand_core = ["aead/rand_core"] [package.metadata.docs.rs] diff --git a/eax/src/lib.rs b/eax/src/lib.rs index 1abc7c64..0e11b16e 100644 --- a/eax/src/lib.rs +++ b/eax/src/lib.rs @@ -42,20 +42,23 @@ //! methods accept any type that impls the [`aead::Buffer`] trait which //! contains the plaintext for encryption or ciphertext for decryption. //! -//! Note that if you enable the `heapless` feature of this crate, -//! you will receive an impl of [`aead::Buffer`] for `heapless::Vec` -//! (re-exported from the [`aead`] crate as [`aead::heapless::Vec`]), -//! which can then be passed as the `buffer` parameter to the in-place encrypt +//! 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`]), 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`]). +//! +//! It can then be passed as the `buffer` parameter to the in-place encrypt //! and decrypt methods: //! //! ``` -//! # #[cfg(feature = "heapless")] +//! # #[cfg(feature = "arrayvec")] //! # { //! use aes::Aes256; //! use eax::Eax; //! use eax::aead::{ //! array::Array, -//! heapless::Vec, +//! arrayvec::ArrayVec, //! AeadCore, AeadInOut, KeyInit, rand_core::OsRng //! }; //! @@ -66,39 +69,33 @@ //! //! let nonce = Aes256Eax::generate_nonce().expect("generate nonce"); // 128-bits; unique per message //! -//! let mut buffer: Vec = Vec::new(); -//! buffer.extend_from_slice(b"plaintext message"); +//! let mut buffer: ArrayVec = ArrayVec::new(); +//! buffer.try_extend_from_slice(b"plaintext message").unwrap(); //! //! // Encrypt `buffer` in-place, replacing the plaintext contents with ciphertext //! cipher.encrypt_in_place(&nonce, b"", &mut buffer).expect("encryption failure!"); //! //! // `buffer` now contains the message ciphertext -//! assert_ne!(&buffer, b"plaintext message"); +//! assert_ne!(buffer.as_ref(), b"plaintext message"); //! //! // Decrypt `buffer` in-place, replacing its ciphertext context with the original plaintext //! cipher.decrypt_in_place(&nonce, b"", &mut buffer).expect("decryption failure!"); -//! assert_eq!(&buffer, b"plaintext message"); +//! assert_eq!(buffer.as_ref(), b"plaintext message"); //! # } //! ``` //! -//! 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`]), 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 //! //! The tag for eax is usually 16 bytes long but it can be shortened if needed. //! The second generic argument of `Eax` can be set to the tag length: //! //! ``` -//! # #[cfg(feature = "heapless")] +//! # #[cfg(feature = "arrayvec")] //! # { //! use aes::Aes256; //! use eax::Eax; //! use eax::aead::{AeadInOut, KeyInit, array::Array}; -//! use eax::aead::heapless::Vec; +//! use eax::aead::arrayvec::ArrayVec; //! use eax::aead::consts::{U8, U128}; //! //! let key = Array::from_slice(b"an example very very secret key."); @@ -106,8 +103,8 @@ //! //! let nonce = Array::from_slice(b"my unique nonces"); // 128-bits; unique per message //! -//! let mut buffer: Vec = Vec::new(); -//! buffer.extend_from_slice(b"plaintext message"); +//! let mut buffer: ArrayVec = ArrayVec::new(); +//! buffer.try_extend_from_slice(b"plaintext message").unwrap(); //! //! // Encrypt `buffer` in-place, replacing the plaintext contents with ciphertext //! let tag = cipher.encrypt_inout_detached(nonce, b"", buffer.as_mut_slice().into()).expect("encryption failure!"); @@ -116,11 +113,11 @@ //! assert_eq!(tag.len(), 8); //! //! // `buffer` now contains the message ciphertext -//! assert_ne!(&buffer, b"plaintext message"); +//! assert_ne!(buffer.as_ref(), b"plaintext message"); //! //! // Decrypt `buffer` in-place, replacing its ciphertext context with the original plaintext //! cipher.decrypt_inout_detached(nonce, b"", buffer.as_mut_slice().into(), &tag).expect("decryption failure!"); -//! assert_eq!(&buffer, b"plaintext message"); +//! assert_eq!(buffer.as_ref(), b"plaintext message"); //! # } //! ``` diff --git a/mgm/Cargo.toml b/mgm/Cargo.toml index c4dc2b3a..e5b5bfa9 100644 --- a/mgm/Cargo.toml +++ b/mgm/Cargo.toml @@ -37,7 +37,6 @@ alloc = ["aead/alloc"] arrayvec = ["aead/arrayvec"] bytes = ["aead/bytes"] getrandom = ["aead/getrandom", "rand_core"] -heapless = ["aead/heapless"] rand_core = ["aead/rand_core"] stream = ["aead/stream"] force-soft = [] # Disable support for hardware intrinsics diff --git a/ocb3/Cargo.toml b/ocb3/Cargo.toml index 0fc6323c..9e65f538 100644 --- a/ocb3/Cargo.toml +++ b/ocb3/Cargo.toml @@ -35,7 +35,6 @@ alloc = ["aead/alloc", "aead-stream?/alloc"] arrayvec = ["aead/arrayvec"] bytes = ["aead/bytes"] os_rng = ["aead/os_rng", "rand_core"] -heapless = ["aead/heapless"] rand_core = ["aead/rand_core"] [package.metadata.docs.rs] diff --git a/xaes-256-gcm/Cargo.toml b/xaes-256-gcm/Cargo.toml index c1a01c91..6e32dff9 100644 --- a/xaes-256-gcm/Cargo.toml +++ b/xaes-256-gcm/Cargo.toml @@ -31,7 +31,6 @@ default = ["alloc", "os_rng"] alloc = ["aead/alloc", "aead-stream?/alloc", "aes-gcm/alloc"] arrayvec = ["aead/arrayvec", "aes-gcm/arrayvec"] os_rng = ["aead/os_rng", "aes-gcm/os_rng", "rand_core"] -heapless = ["aead/heapless", "aes-gcm/heapless"] rand_core = ["aead/rand_core", "aes-gcm/rand_core"] [package.metadata.docs.rs] diff --git a/xaes-256-gcm/src/lib.rs b/xaes-256-gcm/src/lib.rs index d36c8fc3..c5af4ec5 100644 --- a/xaes-256-gcm/src/lib.rs +++ b/xaes-256-gcm/src/lib.rs @@ -12,8 +12,8 @@ //! //! Simple usage (allocating, no associated data): //! -#![cfg_attr(all(feature = "os_rng", feature = "heapless"), doc = "```")] -#![cfg_attr(not(all(feature = "os_rng", feature = "heapless")), doc = "```ignore")] +#![cfg_attr(feature = "os_rng", doc = "```")] +#![cfg_attr(not(feature = "os_rng"), doc = "```ignore")] //! use xaes_256_gcm::{ //! Xaes256Gcm, Nonce, Key, //! aead::{Aead, AeadCore, KeyInit, rand_core::OsRng},