Skip to content

Commit

Permalink
Move use into test mod
Browse files Browse the repository at this point in the history
  • Loading branch information
brndnmtthws committed Dec 7, 2024
1 parent cc096ad commit e0e0ef0
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/classic/crypto_secretstream_xchacha20poly1305.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ use crate::constants::{
CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_REKEY, CRYPTO_STREAM_CHACHA20_IETF_KEYBYTES,
CRYPTO_STREAM_CHACHA20_IETF_NONCEBYTES,
};
use crate::dryocstream::Tag;
use crate::error::*;
use crate::rng::copy_randombytes;
use crate::types::*;
Expand Down Expand Up @@ -458,6 +457,7 @@ pub fn crypto_secretstream_xchacha20poly1305_pull(
#[cfg(test)]
mod tests {
use super::*;
use crate::dryocstream::Tag;

#[test]
fn test_sizes() {
Expand Down Expand Up @@ -1005,14 +1005,16 @@ mod tests {
let mut decrypted = vec![0u8; message.len()];
let mut tag = 0u8;

assert!(crypto_secretstream_xchacha20poly1305_pull(
&mut pull_state,
&mut decrypted,
&mut tag,
&ciphertext,
Some(&wrong_aad),
)
.is_err());
assert!(
crypto_secretstream_xchacha20poly1305_pull(
&mut pull_state,
&mut decrypted,
&mut tag,
&ciphertext,
Some(&wrong_aad),
)
.is_err()
);
}

#[test]
Expand Down Expand Up @@ -1062,13 +1064,15 @@ mod tests {
let mut decrypted = vec![0u8; message.len()];
let mut tag = 0u8;

assert!(crypto_secretstream_xchacha20poly1305_pull(
&mut pull_state,
&mut decrypted,
&mut tag,
&ciphertext,
Some(wrong_aad),
)
.is_err());
assert!(
crypto_secretstream_xchacha20poly1305_pull(
&mut pull_state,
&mut decrypted,
&mut tag,
&ciphertext,
Some(wrong_aad),
)
.is_err()
);
}
}

0 comments on commit e0e0ef0

Please sign in to comment.