Type Alias dryoc::dryocsecretbox::VecBox

source ·
pub type VecBox = DryocSecretBox<Mac, Vec<u8>>;
Expand description

Vec-based authenticated secret box.

Aliased Type§

struct VecBox { /* private fields */ }

Implementations

source§

impl<Mac: NewByteArray<CRYPTO_SECRETBOX_MACBYTES> + Zeroize, Data: NewBytes + ResizableBytes + Zeroize> DryocSecretBox<Mac, Data>

source

pub fn encrypt<Message: Bytes + ?Sized, Nonce: ByteArray<CRYPTO_SECRETBOX_NONCEBYTES>, SecretKey: ByteArray<CRYPTO_SECRETBOX_KEYBYTES>>( message: &Message, nonce: &Nonce, secret_key: &SecretKey ) -> Self

Encrypts a message using secret_key, and returns a new DryocSecretBox with ciphertext and tag

source§

impl<'a, Mac: ByteArray<CRYPTO_SECRETBOX_MACBYTES> + TryFrom<&'a [u8]> + Zeroize, Data: Bytes + From<&'a [u8]> + Zeroize> DryocSecretBox<Mac, Data>

source

pub fn from_bytes(bytes: &'a [u8]) -> Result<Self, Error>

Initializes a DryocSecretBox from a slice. Expects the first CRYPTO_SECRETBOX_MACBYTES bytes to contain the message authentication tag, with the remaining bytes containing the encrypted message.

source§

impl<Mac: ByteArray<CRYPTO_SECRETBOX_MACBYTES> + Zeroize, Data: Bytes + Zeroize> DryocSecretBox<Mac, Data>

source

pub fn from_parts(tag: Mac, data: Data) -> Self

Returns a new box with tag and data, consuming both

source

pub fn to_vec(&self) -> Vec<u8>

Copies self into a new Vec

source

pub fn into_parts(self) -> (Mac, Data)

Moves the tag and data out of this instance, returning them as a tuple.

source§

impl<Mac: ByteArray<CRYPTO_SECRETBOX_MACBYTES> + Zeroize, Data: Bytes + Zeroize> DryocSecretBox<Mac, Data>

source

pub fn decrypt<Output: ResizableBytes + NewBytes, Nonce: ByteArray<CRYPTO_SECRETBOX_NONCEBYTES>, SecretKey: ByteArray<CRYPTO_SECRETBOX_KEYBYTES>>( &self, nonce: &Nonce, secret_key: &SecretKey ) -> Result<Output, Error>

Decrypts ciphertext using secret_key, returning a new DryocSecretBox with decrypted message

source

pub fn to_bytes<Bytes: NewBytes + ResizableBytes>(&self) -> Bytes

Copies self into the target. Can be used with protected memory.

source§

impl<'a, Mac: NewByteArray<CRYPTO_SECRETBOX_MACBYTES> + Zeroize, Data: NewBytes + ResizableBytes + From<&'a [u8]> + Zeroize> DryocSecretBox<Mac, Data>

source

pub fn with_data(input: &'a [u8]) -> Self

Returns a box with data copied from slice input.

source§

impl<'a, Mac: ByteArray<CRYPTO_SECRETBOX_MACBYTES> + Zeroize, Data: Bytes + ResizableBytes + From<&'a [u8]> + Zeroize> DryocSecretBox<Mac, Data>

source

pub fn with_data_and_mac(tag: Mac, input: &'a [u8]) -> Self

Returns a new box with data and tag, with data copied from input and tag consumed.

source§

impl DryocSecretBox<Mac, Vec<u8>>

source

pub fn encrypt_to_vecbox<Message: Bytes + ?Sized, Nonce: ByteArray<CRYPTO_SECRETBOX_NONCEBYTES>, SecretKey: ByteArray<CRYPTO_SECRETBOX_KEYBYTES>>( message: &Message, nonce: &Nonce, secret_key: &SecretKey ) -> Self

Encrypts a message using secret_key, and returns a new DryocSecretBox with ciphertext and tag

source

pub fn decrypt_to_vec<Nonce: ByteArray<CRYPTO_SECRETBOX_NONCEBYTES>, SecretKey: ByteArray<CRYPTO_SECRETBOX_KEYBYTES>>( &self, nonce: &Nonce, secret_key: &SecretKey ) -> Result<Vec<u8>, Error>

Decrypts ciphertext using secret_key, returning a new DryocSecretBox with decrypted message

source

pub fn into_vec(self) -> Vec<u8>

Consumes this box and returns it as a Vec

Trait Implementations

source§

impl<Mac: Clone + ByteArray<CRYPTO_SECRETBOX_MACBYTES> + Zeroize, Data: Clone + Bytes + Zeroize> Clone for DryocSecretBox<Mac, Data>

source§

fn clone(&self) -> DryocSecretBox<Mac, Data>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Mac: Debug + ByteArray<CRYPTO_SECRETBOX_MACBYTES> + Zeroize, Data: Debug + Bytes + Zeroize> Debug for DryocSecretBox<Mac, Data>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, Mac, Data> Deserialize<'de> for DryocSecretBox<Mac, Data>
where Mac: Deserialize<'de> + ByteArray<CRYPTO_SECRETBOX_MACBYTES> + Zeroize, Data: Deserialize<'de> + Bytes + Zeroize,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<Mac: ByteArray<CRYPTO_SECRETBOX_MACBYTES> + Zeroize, Data: Bytes + Zeroize> PartialEq for DryocSecretBox<Mac, Data>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Mac, Data> Serialize for DryocSecretBox<Mac, Data>
where Mac: Serialize + ByteArray<CRYPTO_SECRETBOX_MACBYTES> + Zeroize, Data: Serialize + Bytes + Zeroize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<Mac, Data> Zeroize for DryocSecretBox<Mac, Data>
where Mac: Zeroize + ByteArray<CRYPTO_SECRETBOX_MACBYTES>, Data: Zeroize + Bytes,

source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.