Skip to content

Commit 3970b3e

Browse files
authored
split tests into new_pass_test and new_fail_test, remove heapless crate features (#723)
1 parent ca7e6aa commit 3970b3e

File tree

199 files changed

+279
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+279
-263
lines changed

.github/workflows/belt-dwp.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,4 @@ jobs:
7878
- run: ${{ matrix.deps }}
7979
- run: cargo test --target ${{ matrix.target }} --release --no-default-features --lib
8080
- run: cargo test --target ${{ matrix.target }} --release
81-
- run: cargo test --target ${{ matrix.target }} --release --features heapless
8281
- run: cargo test --target ${{ matrix.target }} --release --all-features

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ members = [
1919
aead-stream = { path = "aead-stream" }
2020
aes-gcm = { path = "aes-gcm" }
2121

22-
# https://github.com/RustCrypto/utils/pull/1187
23-
blobby = { git = "https://github.com/RustCrypto/utils" }
22+
# https://github.com/RustCrypto/traits/pull/2019
23+
aead = { git = "https://github.com/RustCrypto/traits.git" }
24+
crypto-common = { git = "https://github.com/RustCrypto/traits.git" }

aes-gcm-siv/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ alloc = ["aead/alloc"]
3434
arrayvec = ["aead/arrayvec"]
3535
bytes = ["aead/bytes"]
3636
os_rng = ["aead/os_rng", "rand_core"]
37-
heapless = ["aead/heapless"]
3837
rand_core = ["aead/rand_core"]
3938

4039
[package.metadata.docs.rs]

aes-gcm-siv/src/lib.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,45 +38,42 @@
3838
//! methods accept any type that impls the [`aead::Buffer`] trait which
3939
//! contains the plaintext for encryption or ciphertext for decryption.
4040
//!
41-
//! Note that if you enable the `heapless` feature of this crate,
42-
//! you will receive an impl of [`aead::Buffer`] for `heapless::Vec`
43-
//! (re-exported from the [`aead`] crate as [`aead::heapless::Vec`]),
44-
//! which can then be passed as the `buffer` parameter to the in-place encrypt
41+
//! Enabling the `arrayvec` feature of this crate will provide an impl of
42+
//! [`aead::Buffer`] for `arrayvec::ArrayVec` (re-exported from the [`aead`] crate as
43+
//! [`aead::arrayvec::ArrayVec`]), and enabling the `bytes` feature of this crate will
44+
//! provide an impl of [`aead::Buffer`] for `bytes::BytesMut` (re-exported from the
45+
//! [`aead`] crate as [`aead::bytes::BytesMut`]).
46+
//!
47+
//! It can then be passed as the `buffer` parameter to the in-place encrypt
4548
//! and decrypt methods:
4649
//!
47-
#![cfg_attr(all(feature = "os_rng", feature = "heapless"), doc = "```")]
48-
#![cfg_attr(not(all(feature = "os_rng", feature = "heapless")), doc = "```ignore")]
50+
#![cfg_attr(all(feature = "os_rng", feature = "arrayvec"), doc = "```")]
51+
#![cfg_attr(not(all(feature = "os_rng", feature = "arrayvec")), doc = "```ignore")]
4952
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
5053
//! use aes_gcm_siv::{
51-
//! aead::{AeadInOut, KeyInit, rand_core::OsRng, heapless::Vec},
54+
//! aead::{AeadInOut, Buffer, KeyInit, rand_core::OsRng, arrayvec::ArrayVec},
5255
//! Aes256GcmSiv, Nonce, // Or `Aes128GcmSiv`
5356
//! };
5457
//!
5558
//! let key = Aes256GcmSiv::generate_key().expect("generate key");
5659
//! let cipher = Aes256GcmSiv::new(&key);
5760
//! let nonce = Nonce::from_slice(b"unique nonce"); // 96-bits; unique per message
5861
//!
59-
//! let mut buffer: Vec<u8, 128> = Vec::new(); // Note: buffer needs 16-bytes overhead for auth tag
62+
//! let mut buffer: ArrayVec<u8, 128> = ArrayVec::new(); // Note: buffer needs 16-bytes overhead for auth tag
6063
//! buffer.extend_from_slice(b"plaintext message");
6164
//!
6265
//! // Encrypt `buffer` in-place, replacing the plaintext contents with ciphertext
6366
//! cipher.encrypt_in_place(nonce, b"", &mut buffer)?;
6467
//!
6568
//! // `buffer` now contains the message ciphertext
66-
//! assert_ne!(&buffer, b"plaintext message");
69+
//! assert_ne!(buffer.as_ref(), b"plaintext message");
6770
//!
6871
//! // Decrypt `buffer` in-place, replacing its ciphertext context with the original plaintext
6972
//! cipher.decrypt_in_place(nonce, b"", &mut buffer)?;
70-
//! assert_eq!(&buffer, b"plaintext message");
73+
//! assert_eq!(buffer.as_ref(), b"plaintext message");
7174
//! # Ok(())
7275
//! # }
7376
//! ```
74-
//!
75-
//! Similarly, enabling the `arrayvec` feature of this crate will provide an impl of
76-
//! [`aead::Buffer`] for `arrayvec::ArrayVec` (re-exported from the [`aead`] crate as
77-
//! [`aead::arrayvec::ArrayVec`]), and enabling the `bytes` feature of this crate will
78-
//! provide an impl of [`aead::Buffer`] for `bytes::BytesMut` (re-exported from the
79-
//! [`aead`] crate as [`aead::bytes::BytesMut`]).
8077
8178
pub use aead::{self, AeadCore, AeadInOut, Error, Key, KeyInit, KeySizeUser};
8279

aes-gcm-siv/tests/aes128gcmsiv.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,5 @@ const TEST_VECTORS: &[TestVector<[u8; 16]>] = &[
185185
tests!(Aes128GcmSiv, TEST_VECTORS);
186186

187187
// Test vectors from Wycheproof
188-
aead::new_test!(wycheproof, "wycheproof-128", Aes128GcmSiv);
188+
aead::new_pass_test!(wycheproof_pass, "wycheproof-128_pass", Aes128GcmSiv);
189+
aead::new_fail_test!(wycheproof_fail, "wycheproof-128_fail", Aes128GcmSiv);

aes-gcm-siv/tests/aes256gcmsiv.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,5 @@ const TEST_VECTORS: &[TestVector<[u8; 32]>] = &[
185185
tests!(Aes256GcmSiv, TEST_VECTORS);
186186

187187
// Test vectors from Wycheproof
188-
aead::new_test!(wycheproof, "wycheproof-256", Aes256GcmSiv);
188+
aead::new_pass_test!(wycheproof_pass, "wycheproof-256_pass", Aes256GcmSiv);
189+
aead::new_fail_test!(wycheproof_fail, "wycheproof-256_fail", Aes256GcmSiv);
-4.6 KB
Binary file not shown.
840 Bytes
Binary file not shown.
3.74 KB
Binary file not shown.

0 commit comments

Comments
 (0)