1
0
Fork 0
mirror of https://gitlab.redox-os.org/CoffeeCode/redox-ssh.git synced 2025-12-28 15:22:18 +01:00
redox-ssh/src/encryption/aes_ctr.rs
C0ffeeCode 1103eb0eec
Fix warnings: trait objects without an explicit dyn are deprecated (not all of them)
Literally just inserts `dyn`  keywords.

This was deprecated but accepted in Rust 2015 but is a hard error in Rust 2021!
2024-09-26 13:37:16 +02:00

24 lines
576 B
Rust

use crypto::aes::{KeySize, ctr};
use crypto::symmetriccipher::SynchronousStreamCipher;
use encryption::Encryption;
pub struct AesCtr {
cipher: Box<dyn SynchronousStreamCipher + 'static>,
}
impl AesCtr {
pub fn new(key: &[u8], iv: &[u8]) -> AesCtr {
AesCtr { cipher: ctr(KeySize::KeySize256, key, &iv[0..16]) }
}
}
impl Encryption for AesCtr {
fn encrypt(&mut self, data: &[u8], buf: &mut [u8]) {
self.cipher.process(data, buf);
}
fn decrypt(&mut self, data: &[u8], buf: &mut [u8]) {
self.cipher.process(data, buf);
}
}