......
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
//! Keys are 32 bytes in size.
|
||||
|
||||
use chacha20poly1305::{ChaCha20Poly1305, KeyInit, Nonce, aead::Aead};
|
||||
use getrandom::fill;
|
||||
|
||||
use crate::error::CryptoError;
|
||||
|
||||
@@ -18,7 +19,7 @@ impl SymmetricKey {
|
||||
/// Generate a new random SymmetricKey.
|
||||
pub fn new() -> Self {
|
||||
let mut key = [0u8; 32];
|
||||
rand::fill(&mut key);
|
||||
fill(&mut key);
|
||||
Self(key)
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ impl SymmetricKey {
|
||||
|
||||
// Generate random nonce
|
||||
let mut nonce_bytes = [0u8; NONCE_SIZE];
|
||||
rand::fill(&mut nonce_bytes);
|
||||
fill(&mut nonce_bytes);
|
||||
let nonce = Nonce::from_slice(&nonce_bytes);
|
||||
|
||||
// Encrypt message
|
||||
|
Reference in New Issue
Block a user