Struct ssh_cipher::ChaCha20Poly1305
source · pub struct ChaCha20Poly1305 { /* private fields */ }Available on crate feature
chacha20poly1305 only.Expand description
OpenSSH variant of ChaCha20Poly1305: chacha20-poly1305@openssh.com
as described in PROTOCOL.chacha20poly1305.
Differences from ChaCha20Poly1305-IETF as described in RFC8439:
- The input of Poly1305 is not padded.
- AAD is unsupported.
- The lengths of ciphertext (and AAD) are not authenticated using Poly1305.
Implementations§
source§impl ChaCha20Poly1305
impl ChaCha20Poly1305
sourcepub fn new(key: &[u8], nonce: &[u8]) -> Result<Self>
pub fn new(key: &[u8], nonce: &[u8]) -> Result<Self>
Create a new ChaCha20Poly1305 instance with a 32-byte key.
sourcepub fn encrypt(self, buffer: &mut [u8]) -> Tag
pub fn encrypt(self, buffer: &mut [u8]) -> Tag
Encrypt the provided buffer in-place, returning the Poly1305 authentication tag.
sourcepub fn decrypt(self, buffer: &mut [u8], tag: Tag) -> Result<()>
pub fn decrypt(self, buffer: &mut [u8], tag: Tag) -> Result<()>
Decrypt the provided buffer in-place, verifying it against the provided Poly1305
authentication tag.
In the event tag verification fails, Error::Crypto is returned, and buffer is not
modified.
Upon success, Ok(()) is returned and buffer is rewritten with the decrypted plaintext.
Auto Trait Implementations§
impl Freeze for ChaCha20Poly1305
impl RefUnwindSafe for ChaCha20Poly1305
impl Send for ChaCha20Poly1305
impl Sync for ChaCha20Poly1305
impl Unpin for ChaCha20Poly1305
impl UnwindSafe for ChaCha20Poly1305
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