Skip to content

Commit

Permalink
fixes issue with 'KeyIvInit' and 'KeyInit' trait overlap
Browse files Browse the repository at this point in the history
  • Loading branch information
seanwatters committed Feb 10, 2024
1 parent 6a24022 commit 6103ed9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ pub mod content {
use std::thread;

use chacha20::{cipher::StreamCipher, XChaCha20 as ChaCha};
use chacha20poly1305::{
aead::{Aead, AeadCore, KeyInit},
XChaCha20Poly1305 as ChaChaAEAD,
};
use chacha20poly1305::{aead::Aead, AeadCore, XChaCha20Poly1305 as ChaChaAEAD};

use x25519_dalek::{PublicKey, StaticSecret};

Expand All @@ -126,12 +123,17 @@ pub mod content {

// generate components
let nonce = ChaChaAEAD::generate_nonce(&mut rand_core::OsRng);
let content_key = ChaChaAEAD::generate_key(&mut rand_core::OsRng);
let content_key = {
use chacha20poly1305::KeyInit;
ChaChaAEAD::generate_key(&mut rand_core::OsRng)
};

// sign/encrypt content

#[cfg(feature = "multi-thread")]
let sign_and_encrypt_handle = thread::spawn(move || {
use chacha20poly1305::KeyInit;

let signature = super::signature::sign(&fingerprint, &content);
content.extend(signature);

Expand Down Expand Up @@ -329,7 +331,10 @@ pub mod content {
Err(_) => return Err("failed to convert content key to bytes"),
};

let content_cipher = ChaChaAEAD::new(&content_key.into());
let content_cipher = {
use chacha20poly1305::KeyInit;
ChaChaAEAD::new(&content_key.into())
};

match content_cipher.decrypt(
&nonce.into(),
Expand Down

0 comments on commit 6103ed9

Please sign in to comment.