Skip to content

Commit

Permalink
chore: run rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesposito committed Dec 1, 2023
1 parent 2b02120 commit b3f9979
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cipher/src/chacha20/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
8 changes: 6 additions & 2 deletions enclave/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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.
///
Expand Down Expand Up @@ -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<u8> = enclave.clone().into();
let deserialized = Enclave::try_from(serialized).unwrap();
Expand Down
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b3f9979

Please sign in to comment.