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: 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, 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>
Available on crate feature alloc only.
pub fn encrypt_to_vecbox<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>
alloc only.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, StackByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES>, Vec<u8>>
impl AeadBox<ChaCha20Poly1305Ietf, StackByteArray<CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES>, Vec<u8>>
Sourcepub fn encrypt_to_vecbox<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>
Available on crate feature alloc only.
pub fn encrypt_to_vecbox<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>
alloc only.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<Algorithm: AeadAlgorithm, Mac: Bytes, Data: Bytes> AeadBox<Algorithm, Mac, Data>
impl<Algorithm: AeadAlgorithm, Mac: Bytes, Data: Bytes> AeadBox<Algorithm, Mac, Data>
Sourcepub fn to_vec(&self) -> Vec<u8> ⓘ
Available on crate feature alloc only.
pub fn to_vec(&self) -> Vec<u8> ⓘ
alloc only.Copies self into a new Vec.
Sourcepub fn to_bytes<Output: NewBytes + ResizableBytes>(&self) -> Output
pub fn to_bytes<Output: NewBytes + ResizableBytes>(&self) -> Output
Copies self into the target as ciphertext || tag, where the tag is
the first tag-size bytes of Mac.
§Panics
Panics if the tag is shorter than the algorithm’s tag size.
Trait Implementations§
Source§impl<Algorithm: Clone + AeadAlgorithm, Mac: Clone, Data: Clone> Clone for AeadBox<Algorithm, Mac, Data>
impl<Algorithm: Clone + AeadAlgorithm, Mac: Clone, Data: Clone> Clone for AeadBox<Algorithm, Mac, Data>
Source§impl<Algorithm: Debug + AeadAlgorithm, Mac: Debug, Data: Debug> Debug for AeadBox<Algorithm, Mac, Data>
impl<Algorithm: Debug + AeadAlgorithm, Mac: Debug, Data: Debug> Debug for AeadBox<Algorithm, Mac, Data>
Source§impl<'de, Algorithm: AeadAlgorithm, Mac, Data> Deserialize<'de> for AeadBox<Algorithm, Mac, Data>where
Mac: Deserialize<'de>,
Data: Deserialize<'de>,
Available on crate feature serde only.
impl<'de, Algorithm: AeadAlgorithm, Mac, Data> Deserialize<'de> for AeadBox<Algorithm, Mac, Data>where
Mac: Deserialize<'de>,
Data: Deserialize<'de>,
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<Algorithm: AeadAlgorithm, Mac: Bytes, Data: Bytes> PartialEq for AeadBox<Algorithm, Mac, Data>
impl<Algorithm: AeadAlgorithm, Mac: Bytes, Data: Bytes> PartialEq for AeadBox<Algorithm, Mac, Data>
Source§impl<Algorithm: AeadAlgorithm, Mac, Data> Serialize for AeadBox<Algorithm, Mac, Data>
Available on crate feature serde only.
impl<Algorithm: AeadAlgorithm, Mac, Data> Serialize for AeadBox<Algorithm, Mac, Data>
serde only.Auto Trait Implementations§
impl<Algorithm, Mac, Data> Freeze for AeadBox<Algorithm, Mac, Data>
impl<Algorithm, Mac, Data> RefUnwindSafe for AeadBox<Algorithm, Mac, Data>
impl<Algorithm, Mac, Data> Send for AeadBox<Algorithm, Mac, Data>
impl<Algorithm, Mac, Data> Sync for AeadBox<Algorithm, Mac, Data>
impl<Algorithm, Mac, Data> Unpin for AeadBox<Algorithm, Mac, Data>
impl<Algorithm, Mac, Data> UnsafeUnpin for AeadBox<Algorithm, Mac, Data>
impl<Algorithm, Mac, Data> UnwindSafe for AeadBox<Algorithm, Mac, Data>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
Source§impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
Source§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Reader into a new Self::Dst.Source§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Reader into dst.Source§impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
Source§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Reader into a new Self::Dst.Source§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Reader into dst.impl<T, C> SchemaReadOwned<C> for Twhere
C: ConfigCore,
T: for<'de> SchemaRead<'de, C>,
Source§impl<T> Serialize for T
impl<T> Serialize for T
Source§fn serialize(src: &Self::Src) -> Result<Vec<u8>, WriteError>
fn serialize(src: &Self::Src) -> Result<Vec<u8>, WriteError>
alloc only.Vec of bytes.Source§fn serialize_into(dst: impl Writer, src: &Self::Src) -> Result<(), WriteError>
fn serialize_into(dst: impl Writer, src: &Self::Src) -> Result<(), WriteError>
Source§fn serialized_size(src: &Self::Src) -> Result<u64, WriteError>
fn serialized_size(src: &Self::Src) -> Result<u64, WriteError>
Source§impl<T, C> Serialize<C> for T
impl<T, C> Serialize<C> for T
Source§fn serialize(src: &Self::Src, config: C) -> Result<Vec<u8>, WriteError>
fn serialize(src: &Self::Src, config: C) -> Result<Vec<u8>, WriteError>
alloc only.Vec of bytes.Source§fn serialize_into(
dst: impl Writer,
src: &Self::Src,
config: C,
) -> Result<(), WriteError>
fn serialize_into( dst: impl Writer, src: &Self::Src, config: C, ) -> Result<(), WriteError>
Source§fn serialized_size(src: &Self::Src, config: C) -> Result<u64, WriteError>
fn serialized_size(src: &Self::Src, config: C) -> Result<u64, WriteError>
Source§impl<T, Target, C> TagEncoding<C> for Twhere
C: ConfigCore,
T: for<'de> SchemaRead<'de, C, Dst = Target> + SchemaWrite<C, Src = Target> + 'static,
Target: TryFrom<u32>,
u32: TryFrom<Target>,
impl<T, Target, C> TagEncoding<C> for Twhere
C: ConfigCore,
T: for<'de> SchemaRead<'de, C, Dst = Target> + SchemaWrite<C, Src = Target> + 'static,
Target: TryFrom<u32>,
u32: TryFrom<Target>,
type Target = Target
Source§fn try_from_u32(
value: u32,
) -> Result<<T as TagEncoding<C>>::Target, TagEncodingOverflow>
fn try_from_u32( value: u32, ) -> Result<<T as TagEncoding<C>>::Target, TagEncodingOverflow>
u32 to the encoding target.Source§fn try_into_u32(
x: <T as TagEncoding<C>>::Target,
) -> Result<u32, TagEncodingOverflow>
fn try_into_u32( x: <T as TagEncoding<C>>::Target, ) -> Result<u32, TagEncodingOverflow>
u32.Source§fn size_of_from_u32(value: u32) -> Result<usize, WriteError>
fn size_of_from_u32(value: u32) -> Result<usize, WriteError>
u32. Read more