Fix split_off bug
This commit is contained in:
parent
a5b105f486
commit
d2084f369e
1 changed files with 2 additions and 2 deletions
|
@ -92,7 +92,7 @@ pub fn open_in_place(data: &mut Vec<u8>, 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<u8>, 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());
|
||||
|
|
Loading…
Reference in a new issue