Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/belt-dwp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
43 changes: 5 additions & 38 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ 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" }
# https://github.com/RustCrypto/traits/pull/2019
aead = { git = "https://github.com/RustCrypto/traits.git" }
crypto-common = { git = "https://github.com/RustCrypto/traits.git" }
1 change: 0 additions & 1 deletion aes-gcm-siv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
29 changes: 13 additions & 16 deletions aes-gcm-siv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,45 +38,42 @@
//! 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<dyn std::error::Error>> {
//! 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`
//! };
//!
//! let key = Aes256GcmSiv::generate_key().expect("generate key");
//! let cipher = Aes256GcmSiv::new(&key);
//! let nonce = Nonce::from_slice(b"unique nonce"); // 96-bits; unique per message
//!
//! let mut buffer: Vec<u8, 128> = Vec::new(); // Note: buffer needs 16-bytes overhead for auth tag
//! let mut buffer: ArrayVec<u8, 128> = 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};

Expand Down
3 changes: 2 additions & 1 deletion aes-gcm-siv/tests/aes128gcmsiv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,5 @@ const TEST_VECTORS: &[TestVector<[u8; 16]>] = &[
tests!(Aes128GcmSiv, TEST_VECTORS);

// Test vectors from Wycheproof
aead::new_test!(wycheproof, "wycheproof-128", Aes128GcmSiv);
aead::new_pass_test!(wycheproof_pass, "wycheproof-128_pass", Aes128GcmSiv);
aead::new_fail_test!(wycheproof_fail, "wycheproof-128_fail", Aes128GcmSiv);
3 changes: 2 additions & 1 deletion aes-gcm-siv/tests/aes256gcmsiv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,5 @@ const TEST_VECTORS: &[TestVector<[u8; 32]>] = &[
tests!(Aes256GcmSiv, TEST_VECTORS);

// Test vectors from Wycheproof
aead::new_test!(wycheproof, "wycheproof-256", Aes256GcmSiv);
aead::new_pass_test!(wycheproof_pass, "wycheproof-256_pass", Aes256GcmSiv);
aead::new_fail_test!(wycheproof_fail, "wycheproof-256_fail", Aes256GcmSiv);
Binary file removed aes-gcm-siv/tests/data/wycheproof-128.blb
Binary file not shown.
Binary file added aes-gcm-siv/tests/data/wycheproof-128_fail.blb
Binary file not shown.
Binary file added aes-gcm-siv/tests/data/wycheproof-128_pass.blb
Binary file not shown.
Binary file removed aes-gcm-siv/tests/data/wycheproof-256.blb
Binary file not shown.
Binary file added aes-gcm-siv/tests/data/wycheproof-256_fail.blb
Binary file not shown.
Binary file added aes-gcm-siv/tests/data/wycheproof-256_pass.blb
Binary file not shown.
1 change: 0 additions & 1 deletion aes-gcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
36 changes: 16 additions & 20 deletions aes-gcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -58,45 +58,41 @@
//! 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<dyn core::error::Error>> {
//! 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`
//! };
//!
//! let key = Aes256Gcm::generate_key().expect("generate key");
//! let cipher = Aes256Gcm::new(&key);
//! let nonce = Aes256Gcm::generate_nonce().expect("generate nonce"); // 96-bits; unique per message
//!
//! let mut buffer: Vec<u8, 128> = Vec::new(); // Note: buffer needs 16-bytes overhead for auth tag
//! buffer.extend_from_slice(b"plaintext message");
//! let mut buffer: ArrayVec<u8, 128> = 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};

Expand Down
3 changes: 2 additions & 1 deletion aes-gcm/tests/aes128gcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3621,4 +3621,5 @@ const TEST_VECTORS: &[TestVector<[u8; 16], [u8; 12]>] = &[
tests!(Aes128Gcm, TEST_VECTORS);

// Test vectors from Wycheproof
aead::new_test!(wycheproof, "wycheproof-128", Aes128Gcm);
aead::new_pass_test!(wycheproof_pass, "wycheproof-128_pass", Aes128Gcm);
aead::new_fail_test!(wycheproof_fail, "wycheproof-128_fail", Aes128Gcm);
3 changes: 2 additions & 1 deletion aes-gcm/tests/aes256gcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3621,4 +3621,5 @@ const TEST_VECTORS: &[TestVector<[u8; 32], [u8; 12]>] = &[
tests!(Aes256Gcm, TEST_VECTORS);

// Test vectors from Wycheproof
aead::new_test!(wycheproof, "wycheproof-256", Aes256Gcm);
aead::new_pass_test!(wycheproof_pass, "wycheproof-256_pass", Aes256Gcm);
aead::new_fail_test!(wycheproof_fail, "wycheproof-256_fail", Aes256Gcm);
Binary file removed aes-gcm/tests/data/wycheproof-128.blb
Binary file not shown.
Binary file added aes-gcm/tests/data/wycheproof-128_fail.blb
Binary file not shown.
Binary file added aes-gcm/tests/data/wycheproof-128_pass.blb
Binary file not shown.
Binary file removed aes-gcm/tests/data/wycheproof-256.blb
Binary file not shown.
Binary file added aes-gcm/tests/data/wycheproof-256_fail.blb
Binary file not shown.
Binary file added aes-gcm/tests/data/wycheproof-256_pass.blb
Binary file not shown.
1 change: 0 additions & 1 deletion aes-siv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
31 changes: 14 additions & 17 deletions aes-siv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,45 +38,42 @@
//! 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<dyn core::error::Error>> {
//! 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`
//! };
//!
//! let key = Aes256SivAead::generate_key().expect("Generate key");
//! let cipher = Aes256SivAead::new(&key);
//! let nonce = Aes256SivAead::generate_nonce().expect("Generate nonce"); // 128-bits; unique per message
//!
//! let mut buffer: Vec<u8, 128> = Vec::new(); // Note: buffer needs 16-bytes overhead for auth tag
//! buffer.extend_from_slice(b"plaintext message");
//! let mut buffer: ArrayVec<u8, 128> = 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;
Expand Down
Binary file removed aes-siv/tests/data/wycheproof-256.blb
Binary file not shown.
Binary file added aes-siv/tests/data/wycheproof-256_fail.blb
Binary file not shown.
Binary file added aes-siv/tests/data/wycheproof-256_pass.blb
Binary file not shown.
Binary file removed aes-siv/tests/data/wycheproof-512.blb
Binary file not shown.
Binary file added aes-siv/tests/data/wycheproof-512_fail.blb
Binary file not shown.
Binary file added aes-siv/tests/data/wycheproof-512_pass.blb
Binary file not shown.
Loading