/// Decrypts the data using the xchacha20-poly1305 algorithm.
Decrypts the data using the xchacha20-poly1305 algorithm.
Decrypts the data using the xchacha20 - poly1305 algorithm .
fn box_open(key: &Key<Self>, ad: &[u8], data: &[u8]) -> engine::Result<Vec<u8>> {
        let (tag, ct) = data.split_at(Self::TAG_LEN);
        let (nonce, cipher) = ct.split_at(Self::NONCE_LEN);
        let mut plain = vec![0; cipher.len()];
        let key = key.bytes();
        XChaCha20Poly1305::try_decrypt(&key, nonce, ad, &mut plain, cipher, tag)
            .map_err(|_| engine::Error::ProviderError(String::from("Unable to unlock data")))?;
        Ok(plain)
    }
fn box_open ( key : & Key < Self > , ad : & [ u8 ] , data : & [ u8 ] ) -> engine :: Result < Vec < u8 > > { let ( tag , ct ) = data . split_at ( Self :: TAG_LEN ) ; let ( nonce , cipher ) = ct . split_at ( Self :: NONCE_LEN ) ; let mut plain = vec ! [ 0 cipher len ( ) ] ; let key = key . bytes ( ) ; XChaCha20Poly1305 :: try_decrypt ( & key , nonce , ad , & mut plain , cipher , tag ) . map_err ( | _ | engine :: Error :: ProviderError ( String :: from ( " " ) ) ) ? ; Ok ( plain ) }
Decrypts the data using the xchacha20-poly1305 algorithm.
Decrypts the data using the xchacha20 - poly1305 algorithm .
key
&Key<Self>
ad
&[u8]
data
&[u8]