Cleaned up code

TODO: Duplex test
no-dual
Avril 4 years ago
parent 136dc5f102
commit 1eb8012240
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -1,5 +1,6 @@
//! Container for switching between un/encrypted stream
use super::*;
use std::mem;
use chacha20stream::{
AsyncSink,
@ -257,7 +258,6 @@ mod tests
use chacha20stream::keygen;
#[tokio::test]
/// Write the whole `input` buffer encrypted, switch to plain, then write the first 5 bytes of `input` again.
// TODO: Read the `written` buffer back in the same way and order, and check for identity.
async fn wrapper_construct()
{
let input = "Hello world!";
@ -268,11 +268,11 @@ mod tests
let written = {
let mut wrapper = super::DualStream::Plain(backing);
// Encrypted
// Encrypting
wrapper.to_crypt(super::Encryption::Encrypt, key, iv).await.unwrap();
wrapper.write_all(input.as_bytes()).await.unwrap();
// Unencrypted
// Plain
wrapper.to_plain().await.unwrap();
wrapper.write_all(&input.as_bytes()[..5]).await.unwrap();
@ -286,4 +286,7 @@ mod tests
eprintln!("Output bytes: {:?}", written);
eprintln!("Output attempted string: {:?}", String::from_utf8_lossy(&written[..]));
}
// TODO: Write a test using Tokio's `duplex` to read and write encrypted bytes on 2 tasks, then compare the output to the input afterwards
}

@ -1,4 +1,4 @@
use super::*;
//! Extensions and macros
#[macro_export] macro_rules! basic_enum {
($(#[$meta:meta])* $vis:vis $name:ident $(; $tcomment:literal)?: $($var:ident $(=> $comment:literal)?),+ $(,)?) => {

@ -1,5 +1,9 @@
#![allow(dead_code)]
mod ext; #[macro_use] use ext::*;
// Extensions & macros
#[macro_use] mod ext;
#[allow(unused_imports)] use ext::*;
// Wrapper for plain/symm-enc stream swapping
mod dual;

Loading…
Cancel
Save