pub struct AeadBox<Algorithm: AeadAlgorithm, Mac, Data> { /* private fields */ }Expand description
Authenticated encrypted data for a concrete AEAD algorithm.
The byte representation for the supported algorithms is ciphertext || tag.
Implementations§
Source§impl<Mac: NewByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES> + Zeroize, Data: NewBytes + ResizableBytes + Zeroize> AeadBox<XChaCha20Poly1305Ietf, Mac, Data>
impl<Mac: NewByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES> + Zeroize, Data: NewBytes + ResizableBytes + Zeroize> AeadBox<XChaCha20Poly1305Ietf, Mac, Data>
Sourcepub fn encrypt<Message: Bytes + ?Sized, Nonce: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES>, SecretKey: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES>>(
message: &Message,
associated_data: Option<&[u8]>,
nonce: &Nonce,
key: &SecretKey,
) -> Result<Self, Error>
pub fn encrypt<Message: Bytes + ?Sized, Nonce: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES>, SecretKey: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES>>( message: &Message, associated_data: Option<&[u8]>, nonce: &Nonce, key: &SecretKey, ) -> Result<Self, Error>
Encrypts a message using key, nonce, and optional associated data.
§Errors
Returns an error if the message exceeds the construction’s maximum length or the output storage does not resize to the message length.
Source§impl<'a, Mac: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES> + TryFrom<&'a [u8]> + Zeroize, Data: Bytes + From<&'a [u8]> + Zeroize> AeadBox<XChaCha20Poly1305Ietf, Mac, Data>
impl<'a, Mac: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES> + TryFrom<&'a [u8]> + Zeroize, Data: Bytes + From<&'a [u8]> + Zeroize> AeadBox<XChaCha20Poly1305Ietf, Mac, Data>
Source§impl<Mac: NewByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES> + Zeroize, Data: NewBytes + ResizableBytes + Zeroize> AeadBox<ChaCha20Poly1305Ietf, Mac, Data>
impl<Mac: NewByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES> + Zeroize, Data: NewBytes + ResizableBytes + Zeroize> AeadBox<ChaCha20Poly1305Ietf, Mac, Data>
Sourcepub fn encrypt<Message: Bytes + ?Sized, Nonce: ByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES>, SecretKey: ByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES>>(
message: &Message,
associated_data: Option<&[u8]>,
nonce: &Nonce,
key: &SecretKey,
) -> Result<Self, Error>
pub fn encrypt<Message: Bytes + ?Sized, Nonce: ByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES>, SecretKey: ByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES>>( message: &Message, associated_data: Option<&[u8]>, nonce: &Nonce, key: &SecretKey, ) -> Result<Self, Error>
Encrypts a message using key, nonce, and optional associated data.
§Errors
Returns an error if the message exceeds the construction’s maximum length or the output storage does not resize to the message length.
Source§impl<'a, Mac: ByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES> + TryFrom<&'a [u8]> + Zeroize, Data: Bytes + From<&'a [u8]> + Zeroize> AeadBox<ChaCha20Poly1305Ietf, Mac, Data>
impl<'a, Mac: ByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES> + TryFrom<&'a [u8]> + Zeroize, Data: Bytes + From<&'a [u8]> + Zeroize> AeadBox<ChaCha20Poly1305Ietf, Mac, Data>
Source§impl<Mac: ByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES>, Data: Bytes> AeadBox<ChaCha20Poly1305Ietf, Mac, Data>
impl<Mac: ByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES>, Data: Bytes> AeadBox<ChaCha20Poly1305Ietf, Mac, Data>
Sourcepub fn decrypt<Output: ResizableBytes + NewBytes, Nonce: ByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES>, SecretKey: ByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES>>(
&self,
associated_data: Option<&[u8]>,
nonce: &Nonce,
key: &SecretKey,
) -> Result<Output, Error>
pub fn decrypt<Output: ResizableBytes + NewBytes, Nonce: ByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES>, SecretKey: ByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES>>( &self, associated_data: Option<&[u8]>, nonce: &Nonce, key: &SecretKey, ) -> Result<Output, Error>
Decrypts this box using key, nonce, and optional associated data.
§Errors
Returns an error if the ciphertext exceeds the construction’s maximum length, the output storage has the wrong length, or authentication fails. Authentication fails when the key, nonce, associated data, ciphertext, or tag does not match the value used during encryption.
Source§impl AeadBox<ChaCha20Poly1305Ietf, Mac, Vec<u8>>
impl AeadBox<ChaCha20Poly1305Ietf, Mac, Vec<u8>>
Sourcepub fn encrypt_to_vecbox<Message: Bytes + ?Sized, SecretKey: ByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES>>(
message: &Message,
associated_data: Option<&[u8]>,
nonce: &Nonce,
key: &SecretKey,
) -> Result<Self, Error>
pub fn encrypt_to_vecbox<Message: Bytes + ?Sized, SecretKey: ByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES>>( message: &Message, associated_data: Option<&[u8]>, nonce: &Nonce, key: &SecretKey, ) -> Result<Self, Error>
Source§impl<Algorithm: AeadAlgorithm, Mac, Data> AeadBox<Algorithm, Mac, Data>
impl<Algorithm: AeadAlgorithm, Mac, Data> AeadBox<Algorithm, Mac, Data>
Sourcepub fn from_parts(tag: Mac, data: Data) -> Self
pub fn from_parts(tag: Mac, data: Data) -> Self
Returns a new AEAD box from tag and ciphertext data.
Sourcepub fn into_parts(self) -> (Mac, Data)
pub fn into_parts(self) -> (Mac, Data)
Moves the tag and ciphertext out of this instance.
Source§impl<Mac: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES>, Data: Bytes> AeadBox<XChaCha20Poly1305Ietf, Mac, Data>
impl<Mac: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES>, Data: Bytes> AeadBox<XChaCha20Poly1305Ietf, Mac, Data>
Sourcepub fn decrypt<Output: ResizableBytes + NewBytes, Nonce: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES>, SecretKey: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES>>(
&self,
associated_data: Option<&[u8]>,
nonce: &Nonce,
key: &SecretKey,
) -> Result<Output, Error>
pub fn decrypt<Output: ResizableBytes + NewBytes, Nonce: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES>, SecretKey: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES>>( &self, associated_data: Option<&[u8]>, nonce: &Nonce, key: &SecretKey, ) -> Result<Output, Error>
Decrypts this box using key, nonce, and optional associated data.
§Errors
Returns an error if the ciphertext exceeds the construction’s maximum length, the output storage has the wrong length, or authentication fails. Authentication fails when the key, nonce, associated data, ciphertext, or tag does not match the value used during encryption.
Source§impl AeadBox<XChaCha20Poly1305Ietf, StackByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES>, Vec<u8>>
impl AeadBox<XChaCha20Poly1305Ietf, StackByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES>, Vec<u8>>
Sourcepub fn encrypt_to_vecbox<Message: Bytes + ?Sized, SecretKey: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES>>(
message: &Message,
associated_data: Option<&[u8]>,
nonce: &Nonce,
key: &SecretKey,
) -> Result<Self, Error>
pub fn encrypt_to_vecbox<Message: Bytes + ?Sized, SecretKey: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES>>( message: &Message, associated_data: Option<&[u8]>, nonce: &Nonce, key: &SecretKey, ) -> Result<Self, Error>
Source§impl<'a, Algorithm: AeadAlgorithm, Mac, Data: From<&'a [u8]>> AeadBox<Algorithm, Mac, Data>
impl<'a, Algorithm: AeadAlgorithm, Mac, Data: From<&'a [u8]>> AeadBox<Algorithm, Mac, Data>
Sourcepub fn with_data_and_mac(tag: Mac, input: &'a [u8]) -> Self
pub fn with_data_and_mac(tag: Mac, input: &'a [u8]) -> Self
Returns a new box with ciphertext copied from input and tag
consumed.