1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Provides a wrapper around a [`AsyncRead`](tokio::io::AsyncRead)
//!
//! ```rust
//! # use async_io_crypto::{CipherRead, DecipherRead};
//! # use tokio::io::{AsyncBufReadExt, AsyncReadExt, BufReader};
//! # use chacha20poly1305::{ChaCha20Poly1305, Key, KeyInit};
//! # use rand::SeedableRng;
//!
//! #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!
//! let key = b"my very super super secret key!!";
//! let plaintext = b"hello world!";
//!
//! let mut csprng = rand_chacha::ChaCha20Rng::from_entropy();
//! let cipher: ChaCha20Poly1305 = ChaCha20Poly1305::new(Key::from_slice(key));
//! let (mut ci_reader, nonce) = CipherRead::new(&plaintext[..], cipher.clone(), &mut csprng);
//!
//! let mut ciphered = Vec::new();
//! ci_reader.read_to_end(&mut ciphered).await.unwrap();
//!
//! let mut deci_reader = DecipherRead::new(&ciphered[..], cipher, nonce.as_slice());
//! let mut deciphered = Vec::new();
//! deci_reader.read_to_end(&mut deciphered).await.unwrap();
//! assert_eq!(deciphered, plaintext);
//! # Ok(())
//! # }
//! ```
const CHUNK_INFO_SIZE: usize = + ;
const CHUNK_SIZE: usize = 64 * 1024;
pub use CipherRead;
pub use DecipherRead;