Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Sync to trait object #5

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/v1/aeadcipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl_siv_cmac_cipher!(AesSivCmac384, AES_SIV_CMAC_384);
impl_siv_cmac_cipher!(AesSivCmac512, AES_SIV_CMAC_512);

pub struct AeadCipher {
cipher: Box<dyn AeadCipherInner + Send + 'static>,
cipher: Box<dyn AeadCipherInner + Send + Sync + 'static>,
nlen: usize,
nonce: [u8; Self::N_MAX],
}
Expand All @@ -149,7 +149,7 @@ impl AeadCipher {
pub fn new(kind: CipherKind, key: &[u8]) -> Self {
use self::CipherKind::*;

let cipher: Box<dyn AeadCipherInner + Send + 'static> = match kind {
let cipher: Box<dyn AeadCipherInner + Send + Sync + 'static> = match kind {
AES_128_CCM => Box::new(Aes128Ccm::new(key)),
AES_256_CCM => Box::new(Aes256Ccm::new(key)),
AES_128_OCB_TAGLEN128 => Box::new(Aes128OcbTag128::new(key)),
Expand Down
2 changes: 1 addition & 1 deletion src/v1/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl CipherInner for AeadCipher {

/// Unified interface of Ciphers
pub struct Cipher {
cipher: Box<dyn CipherInner + Send + 'static>,
cipher: Box<dyn CipherInner + Send + Sync + 'static>,
}

impl Cipher {
Expand Down
4 changes: 2 additions & 2 deletions src/v1/streamcipher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ impl_cipher!(Rc4, RC4);
impl_cipher!(Chacha20, CHACHA20);

pub struct StreamCipher {
cipher: Box<dyn StreamCipherInner + Send + 'static>,
cipher: Box<dyn StreamCipherInner + Send + Sync + 'static>,
}

impl StreamCipher {
pub fn new(kind: CipherKind, key: &[u8], iv: &[u8]) -> Self {
use self::CipherKind::*;

let cipher: Box<dyn StreamCipherInner + Send + 'static> = match kind {
let cipher: Box<dyn StreamCipherInner + Send + Sync + 'static> = match kind {
SS_TABLE => Box::new(Table::new(key, iv)),
SS_RC4_MD5 => Box::new(Rc4Md5::new(key, iv)),
AES_128_CTR => Box::new(Aes128Ctr::new(key, iv)),
Expand Down