From d2084f369e0ea9ea7f8f1c55393da7de9a47709b Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Sat, 30 Oct 2021 19:42:51 -0700 Subject: [PATCH] Fix split_off bug --- common/src/crypto.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/crypto.rs b/common/src/crypto.rs index d36782b..7d3d6a7 100644 --- a/common/src/crypto.rs +++ b/common/src/crypto.rs @@ -92,7 +92,7 @@ pub fn open_in_place(data: &mut Vec, key: &Key, password: Option<&str>) -> R None }; - let nonce = Nonce::from_slice(&data.split_off(Nonce::SIZE)); + let nonce = Nonce::from_slice(&data.split_off(buffer_len - Nonce::SIZE)); // At this point we should have a buffer that's only the ciphertext. @@ -111,7 +111,7 @@ pub fn open_in_place(data: &mut Vec, key: &Key, password: Option<&str>) -> R #[must_use] fn gen_key_nonce() -> (Key, Nonce) { let mut rng = thread_rng(); - let mut key: Key = GenericArray::default(); + let mut key = GenericArray::default(); rng.fill(key.as_mut_slice()); let mut nonce = Nonce::default(); rng.fill(nonce.as_mut_slice());