From 3f35c449404957d4ed96ffcff7327f7f55d75c9e Mon Sep 17 00:00:00 2001 From: Avril Date: Wed, 30 Sep 2020 14:52:13 +0100 Subject: [PATCH] re --- Cargo.toml | 2 +- src/aes.rs | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 71fc82e..1bf7ace 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cryptohelpers" -version = "1.3.1" +version = "1.4" license= "MIT" description = "Collection of helpers and simplifying functions for cryptography things" authors = ["Avril "] diff --git a/src/aes.rs b/src/aes.rs index 86ee078..d046ca4 100644 --- a/src/aes.rs +++ b/src/aes.rs @@ -151,14 +151,14 @@ where F: AsyncRead + Unpin + ?Sized, let mut crypt_buffer = [0u8; BUFFER_SIZE + BLOCKSIZE]; while {read = from.read(&mut buffer[..]).await?; read!=0} { let bytes_encrypted = crypter.update(&buffer[..read], &mut crypt_buffer)?; - to.write(&crypt_buffer[..bytes_encrypted]).await?; - done += read; + to.write_all(&crypt_buffer[..bytes_encrypted]).await?; + done += bytes_encrypted; } let bytes_encrypted = crypter.finalize(&mut crypt_buffer)?; - to.write(&crypt_buffer[..bytes_encrypted]).await?; + to.write_all(&crypt_buffer[..bytes_encrypted]).await?; - Ok(done) + Ok(done + bytes_encrypted) } /// Encrypt a stream into another using a key @@ -174,14 +174,14 @@ where F: io::Read + ?Sized, let mut crypt_buffer = [0u8; BUFFER_SIZE + BLOCKSIZE]; while {read = from.read(&mut buffer[..])?; read!=0} { let bytes_encrypted = crypter.update(&buffer[..read], &mut crypt_buffer)?; - to.write(&crypt_buffer[..bytes_encrypted])?; - done += read; + to.write_all(&crypt_buffer[..bytes_encrypted])?; + done += bytes_encrypted; } let bytes_encrypted = crypter.finalize(&mut crypt_buffer)?; - to.write(&crypt_buffer[..bytes_encrypted])?; + to.write_all(&crypt_buffer[..bytes_encrypted])?; - Ok(done) + Ok(done + bytes_encrypted) } /// Decrypt a stream into another using a key @@ -198,14 +198,14 @@ where F: AsyncRead + Unpin + ?Sized, let mut crypt_buffer = [0u8; BUFFER_SIZE + BLOCKSIZE]; while {read = from.read(&mut buffer[..]).await?; read!=0} { let bytes_encrypted = crypter.update(&buffer[..read], &mut crypt_buffer)?; - to.write(&crypt_buffer[..bytes_encrypted]).await?; - done += read; + to.write_all(&crypt_buffer[..bytes_encrypted]).await?; + done += bytes_encrypted; } let bytes_encrypted = crypter.finalize(&mut crypt_buffer)?; - to.write(&crypt_buffer[..bytes_encrypted]).await?; + to.write_all(&crypt_buffer[..bytes_encrypted]).await?; - Ok(done) + Ok(done + bytes_encrypted) } /// Decrypt a stream into another using a key @@ -221,14 +221,14 @@ where F: io::Read + ?Sized, let mut crypt_buffer = [0u8; BUFFER_SIZE + BLOCKSIZE]; while {read = from.read(&mut buffer[..])?; read!=0} { let bytes_encrypted = crypter.update(&buffer[..read], &mut crypt_buffer)?; - to.write(&crypt_buffer[..bytes_encrypted])?; - done += read; + to.write_all(&crypt_buffer[..bytes_encrypted])?; + done += bytes_encrypted; } let bytes_encrypted = crypter.finalize(&mut crypt_buffer)?; - to.write(&crypt_buffer[..bytes_encrypted])?; + to.write_all(&crypt_buffer[..bytes_encrypted])?; - Ok(done) + Ok(done + bytes_encrypted) } pub use crate::error::aes::Error;