[−][src]Struct ssb_crypto::secretbox::Key
A key used to seal and open an encrypted box.
The underlying memory is zeroed on drop.
Implementations
impl Key[src]
pub const SIZE: usize[src]
The size of a key, in bytes (32).
pub fn from_slice(s: &[u8]) -> Option<Self>[src]
Deserialize a key from a byte slice.
Returns None if the slice length is not 32.
pub fn generate_with_rng<R>(r: &mut R) -> Key where
R: CryptoRng + RngCore, [src]
R: CryptoRng + RngCore,
Generate a new random key using the given cryptographically-secure random number generator.
pub fn generate() -> Key[src]
Generate a new random key.
impl Key[src]
pub fn seal(&self, msg: &mut [u8], n: &Nonce) -> Hmac[src]
Encrypt a message in place, returning the authentication code.
#[must_use]pub fn open(&self, c: &mut [u8], hmac: &Hmac, n: &Nonce) -> bool[src]
Decrypt an encrypted message in place.
#[must_use]pub fn open_attached_into(
&self,
input: &[u8],
n: &Nonce,
out: &mut [u8]
) -> bool[src]
&self,
input: &[u8],
n: &Nonce,
out: &mut [u8]
) -> bool
Decrypt an encrypted message with attached authentication code, writing the decrypted message into the provided buffer.
If the decryption fails, out will contain a copy of the encrypted message.
Panics
Panics if the output buffer length isn't big enough to hold the plaintext message.
The output buffer length should be at least input.len() - Hmac::SIZE.
pub fn seal_attached_into(&self, msg: &[u8], nonce: &Nonce, out: &mut [u8])[src]
Encrypt a message, writing the resulting Hmac and ciphertext into the
given output buffer. The output buffer size must be at least msg.len() + Hmac::SIZE.
Trait Implementations
impl AsBytes for Key[src]
fn only_derive_is_allowed_to_implement_this_trait() where
Self: Sized, [src]
Self: Sized,
fn as_bytes(&self) -> &[u8][src]
fn as_bytes_mut(&mut self) -> &mut [u8] where
Self: FromBytes, [src]
Self: FromBytes,
impl Clone for Key[src]
impl Drop for Key[src]
impl FromBytes for Key[src]
fn only_derive_is_allowed_to_implement_this_trait() where
Self: Sized, [src]
Self: Sized,
impl Zeroize for Key[src]
Auto Trait Implementations
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnwindSafe for Key
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<Z> Zeroize for Z where
Z: DefaultIsZeroes, [src]
Z: DefaultIsZeroes,