pub enum Cipher {
Dummy(DummyCipher),
Stream(StreamCipher),
Aead(AeadCipher),
}Available on crate feature
v1 only.Expand description
Unified interface of Ciphers
Variants§
Dummy(DummyCipher)
Stream(StreamCipher)
Available on crate feature
v1-stream only.Aead(AeadCipher)
Available on crate feature
v1-aead only.Implementations§
Source§impl Cipher
impl Cipher
Sourcepub fn new(kind: CipherKind, key: &[u8], iv_or_salt: &[u8]) -> Cipher
pub fn new(kind: CipherKind, key: &[u8], iv_or_salt: &[u8]) -> Cipher
Create a new Cipher of kind
- Stream Ciphers initialize with IV
- AEAD Ciphers initialize with SALT
Sourcepub fn category(&self) -> CipherCategory
pub fn category(&self) -> CipherCategory
Get the CipherCategory of the current cipher
Sourcepub fn kind(&self) -> CipherKind
pub fn kind(&self) -> CipherKind
Get the CipherKind of the current cipher
Sourcepub fn encrypt_packet(&mut self, pkt: &mut [u8])
pub fn encrypt_packet(&mut self, pkt: &mut [u8])
Encrypt a packet. Encrypted result will be written in pkt
- Stream Ciphers: the size of input and output packets are the same
- AEAD Ciphers: the size of output must be at least
input.len() + TAG_LEN
Sourcepub fn decrypt_packet(&mut self, pkt: &mut [u8]) -> bool
pub fn decrypt_packet(&mut self, pkt: &mut [u8]) -> bool
Decrypt a packet. Decrypted result will be written in pkt
- Stream Ciphers: the size of input and output packets are the same
- AEAD Ciphers: the size of output is
input.len() - TAG_LEN
Auto Trait Implementations§
impl Freeze for Cipher
impl RefUnwindSafe for Cipher
impl Send for Cipher
impl Sync for Cipher
impl Unpin for Cipher
impl UnwindSafe for Cipher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more