diff --git a/cipher/src/chacha20/mod.rs b/cipher/src/chacha20/mod.rs index 0e30c7a..e370b64 100644 --- a/cipher/src/chacha20/mod.rs +++ b/cipher/src/chacha20/mod.rs @@ -5,9 +5,9 @@ pub mod core; pub mod stream; +pub use self::core::{KEY_SIZE, NONCE_SIZE}; use crate::{Bytes, Cipher, Slice}; pub use stream::ChaChaStream; -pub use self::core::{NONCE_SIZE, KEY_SIZE}; /// Represents the ChaCha20 encryption/decryption cipher. /// diff --git a/enclave/src/lib.rs b/enclave/src/lib.rs index 4af5059..2861399 100644 --- a/enclave/src/lib.rs +++ b/enclave/src/lib.rs @@ -1,7 +1,10 @@ pub mod errors; pub use errors::EnclaveError; -use secured_cipher::{chacha20::{ChaCha20, core::KEY_SIZE}, random_bytes, Cipher}; +use secured_cipher::{ + chacha20::{core::KEY_SIZE, ChaCha20}, + random_bytes, Cipher, +}; /// `Enclave` acts as a container for encrypted data, including metadata and the encrypted content itself. /// @@ -187,7 +190,8 @@ mod tests { fn it_should_serialize_and_deserialize_to_bytes() { let key: Key<32, 16> = Key::new(b"my password", 10_000); let bytes = [0u8, 1u8, 2u8, 3u8, 4u8].to_vec(); - let enclave = Enclave::<[u8; 2], 8>::from_plain_bytes([0_u8, 1_u8], key.pubk, bytes.clone()).unwrap(); + let enclave = + Enclave::<[u8; 2], 8>::from_plain_bytes([0_u8, 1_u8], key.pubk, bytes.clone()).unwrap(); let serialized: Vec = enclave.clone().into(); let deserialized = Enclave::try_from(serialized).unwrap(); diff --git a/src/main.rs b/src/main.rs index abce2f4..877d7ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,8 +3,8 @@ use rpassword::prompt_password; use std::fs::{metadata, File}; use std::io::{Read, Write}; +use cipher::{chacha20::NONCE_SIZE, Key}; use enclave::Enclave; -use cipher::{Key, chacha20::NONCE_SIZE}; /// Defines command line subcommands for the application. #[derive(Debug, Subcommand)] @@ -80,7 +80,8 @@ fn encrypt_file(password: &String, filename: &String) { /// * `filename` - The name of the file to be decrypted. fn decrypt_file(password: &String, filename: &String) { let encrypted_bytes = get_file_as_byte_vec(filename); - let enclave = Enclave::<[u8; 16], NONCE_SIZE>::try_from(encrypted_bytes).expect("Unable to deserialize enclave"); + let enclave = Enclave::<[u8; 16], NONCE_SIZE>::try_from(encrypted_bytes) + .expect("Unable to deserialize enclave"); let encryption_key: Key<32, 16> = Key::with_salt(password.as_bytes(), enclave.metadata, 900_000); let recovered_bytes = enclave .decrypt(encryption_key.pubk)