fn decrypt_in_place(
        &self,
        buffer: &mut dyn ResizeBuffer,
        nonce: &[u8],
        aad: &[u8],
    ) -> Result<(), Error> {
        if nonce.len() != NonceSize::<T>::USIZE {
            return Err(err_msg!(InvalidNonce));
        }
        let nonce = GenericArray::from_slice(nonce);
        let buf_len = buffer.as_ref().len();
        if buf_len < TagSize::<T>::USIZE {
            return Err(err_msg!(Invalid, "Invalid size for encrypted data"));
        }
        let tag_start = buf_len - TagSize::<T>::USIZE;
        let mut tag = GenericArray::default();
        tag.clone_from_slice(&buffer.as_ref()[tag_start..]);
        let chacha = T::Aead::new(self.0.as_ref());
        chacha
            .decrypt_in_place_detached(nonce, aad, &mut buffer.as_mut()[..tag_start], &tag)
            .map_err(|_| err_msg!(Encryption, "AEAD decryption error"))?;
        buffer.buffer_resize(tag_start)?;
        Ok(())
    }
/// Decrypt an encrypted (verification tag appended) value in place
Decrypt an encrypted (verification tag appended) value in place
Decrypt an encrypted ( verification tag appended ) value in place
fn decrypt_in_place(
        &self,
        buffer: &mut dyn ResizeBuffer,
        nonce: &[u8],
        aad: &[u8],
    ) -> Result<(), Error> {
        if nonce.len() != NonceSize::<T>::USIZE {
            return Err(err_msg!(InvalidNonce));
        }
        let nonce = GenericArray::from_slice(nonce);
        let buf_len = buffer.as_ref().len();
        if buf_len < TagSize::<T>::USIZE {
            return Err(err_msg!(Invalid, "Invalid size for encrypted data"));
        }
        let tag_start = buf_len - TagSize::<T>::USIZE;
        let mut tag = GenericArray::default();
        tag.clone_from_slice(&buffer.as_ref()[tag_start..]);
        let chacha = T::Aead::new(self.0.as_ref());
        chacha
            .decrypt_in_place_detached(nonce, aad, &mut buffer.as_mut()[..tag_start], &tag)
            .map_err(|_| err_msg!(Encryption, "AEAD decryption error"))?;
        buffer.buffer_resize(tag_start)?;
        Ok(())
    }
fn decrypt_in_place ( & self , buffer : & mut dyn ResizeBuffer , nonce : & [ u8 ] , aad : & [ u8 ] , ) -> Result < ( ) , Error > { if nonce . len ( ) != NonceSize :: < T > :: USIZE { return Err ( err_msg ! ( InvalidNonce ) ) ; } let nonce = GenericArray :: from_slice ( nonce ) ; let buf_len = buffer . as_ref ( ) . len ( ) ; if buf_len < TagSize :: < T > :: USIZE { return Err ( err_msg ! ( Invalid " " ) ) ; } let tag_start = buf_len - TagSize :: < T > :: USIZE ; let mut tag = GenericArray :: default ( ) ; tag . clone_from_slice ( & buffer . as_ref ( ) [ tag_start .. ] ) ; let chacha = T :: Aead :: new ( self . 0 . as_ref ( ) ) ; chacha . decrypt_in_place_detached ( nonce , aad , & mut buffer . as_mut ( ) [ .. tag_start ] , & tag ) . map_err ( | _ | err_msg ! ( Encryption " " ) ) ? ; buffer . buffer_resize ( tag_start ) ? ; Ok ( ( ) ) }
Decrypt an encrypted (verification tag appended) value in place
Decrypt an encrypted ( verification tag appended ) value in place
&self
buffer
&mut dyn ResizeBuffer
nonce
&[u8]
aad
&[u8]