pub struct CryptoBox<C> { /* private fields */ }
Expand description
Public-key encryption scheme based on the X25519 Elliptic Curve Diffie-Hellman function and the crypto_secretbox authenticated encryption cipher.
This type impls the aead::Aead
trait, and otherwise functions as a
symmetric Authenticated Encryption with Associated Data (AEAD) cipher
once instantiated.
Note that additional associated data (AAD) is not supported and encryption
operations will return aead::Error
if it is provided as an argument.
Implementations§
Trait Implementations§
source§impl<C> AeadCore for CryptoBox<C>
impl<C> AeadCore for CryptoBox<C>
source§type NonceSize = UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>, B0>
type NonceSize = UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>, B0>
The length of a nonce.
source§type TagSize = UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>
type TagSize = UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>
The maximum length of the nonce.
source§type CiphertextOverhead = UTerm
type CiphertextOverhead = UTerm
The upper bound amount of additional space required to support a
ciphertext vs. a plaintext.
source§fn generate_nonce(
rng: impl CryptoRng + RngCore,
) -> GenericArray<u8, Self::NonceSize>
fn generate_nonce( rng: impl CryptoRng + RngCore, ) -> GenericArray<u8, Self::NonceSize>
Generate a random nonce for this AEAD algorithm. Read more
source§impl<C> AeadInPlace for CryptoBox<C>
impl<C> AeadInPlace for CryptoBox<C>
source§fn encrypt_in_place(
&self,
nonce: &GenericArray<u8, Self::NonceSize>,
associated_data: &[u8],
buffer: &mut dyn Buffer,
) -> Result<(), Error>
fn encrypt_in_place( &self, nonce: &GenericArray<u8, Self::NonceSize>, associated_data: &[u8], buffer: &mut dyn Buffer, ) -> Result<(), Error>
Encrypt the given buffer containing a plaintext message in-place. Read more
source§fn encrypt_in_place_detached(
&self,
nonce: &GenericArray<u8, Self::NonceSize>,
associated_data: &[u8],
buffer: &mut [u8],
) -> Result<Tag, Error>
fn encrypt_in_place_detached( &self, nonce: &GenericArray<u8, Self::NonceSize>, associated_data: &[u8], buffer: &mut [u8], ) -> Result<Tag, Error>
Encrypt the data in-place, returning the authentication tag
source§fn decrypt_in_place(
&self,
nonce: &GenericArray<u8, Self::NonceSize>,
associated_data: &[u8],
buffer: &mut dyn Buffer,
) -> Result<(), Error>
fn decrypt_in_place( &self, nonce: &GenericArray<u8, Self::NonceSize>, associated_data: &[u8], buffer: &mut dyn Buffer, ) -> Result<(), Error>
Decrypt the message in-place, returning an error in the event the
provided authentication tag does not match the given ciphertext. Read more
source§fn decrypt_in_place_detached(
&self,
nonce: &GenericArray<u8, Self::NonceSize>,
associated_data: &[u8],
buffer: &mut [u8],
tag: &Tag,
) -> Result<(), Error>
fn decrypt_in_place_detached( &self, nonce: &GenericArray<u8, Self::NonceSize>, associated_data: &[u8], buffer: &mut [u8], tag: &Tag, ) -> Result<(), Error>
Decrypt the message in-place, returning an error in the event the provided
authentication tag does not match the given ciphertext (i.e. ciphertext
is modified/unauthentic)
Auto Trait Implementations§
impl<C> Freeze for CryptoBox<C>
impl<C> RefUnwindSafe for CryptoBox<C>where
C: RefUnwindSafe,
impl<C> Send for CryptoBox<C>where
C: Send,
impl<C> Sync for CryptoBox<C>where
C: Sync,
impl<C> Unpin for CryptoBox<C>where
C: Unpin,
impl<C> UnwindSafe for CryptoBox<C>where
C: UnwindSafe,
Blanket Implementations§
source§impl<Alg> Aead for Algwhere
Alg: AeadInPlace,
impl<Alg> Aead for Algwhere
Alg: AeadInPlace,
source§impl<Alg> AeadMut for Algwhere
Alg: AeadMutInPlace,
impl<Alg> AeadMut for Algwhere
Alg: AeadMutInPlace,
source§impl<Alg> AeadMutInPlace for Algwhere
Alg: AeadInPlace,
impl<Alg> AeadMutInPlace for Algwhere
Alg: AeadInPlace,
source§fn encrypt_in_place(
&mut self,
nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>,
associated_data: &[u8],
buffer: &mut impl Buffer,
) -> Result<(), Error>
fn encrypt_in_place( &mut self, nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>, associated_data: &[u8], buffer: &mut impl Buffer, ) -> Result<(), Error>
Encrypt the given buffer containing a plaintext message in-place. Read more
source§fn encrypt_in_place_detached(
&mut self,
nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>,
associated_data: &[u8],
buffer: &mut [u8],
) -> Result<GenericArray<u8, <Alg as AeadCore>::TagSize>, Error>
fn encrypt_in_place_detached( &mut self, nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>, associated_data: &[u8], buffer: &mut [u8], ) -> Result<GenericArray<u8, <Alg as AeadCore>::TagSize>, Error>
Encrypt the data in-place, returning the authentication tag
source§fn decrypt_in_place(
&mut self,
nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>,
associated_data: &[u8],
buffer: &mut impl Buffer,
) -> Result<(), Error>
fn decrypt_in_place( &mut self, nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>, associated_data: &[u8], buffer: &mut impl Buffer, ) -> Result<(), Error>
Decrypt the message in-place, returning an error in the event the
provided authentication tag does not match the given ciphertext. Read more
source§fn decrypt_in_place_detached(
&mut self,
nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>,
associated_data: &[u8],
buffer: &mut [u8],
tag: &GenericArray<u8, <Alg as AeadCore>::TagSize>,
) -> Result<(), Error>
fn decrypt_in_place_detached( &mut self, nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>, associated_data: &[u8], buffer: &mut [u8], tag: &GenericArray<u8, <Alg as AeadCore>::TagSize>, ) -> Result<(), Error>
Decrypt the data in-place, returning an error in the event the provided
authentication tag does not match the given ciphertext (i.e. ciphertext
is modified/unauthentic)
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)