pub struct EncryptedMem { /* private fields */ }
Expand description

A struct that holds the encrypted secret and performs encryption and decryption on the secret.

Structure
pub struct EncryptedMem {
    ciphertext: ZeroizeBytes,
    nonce: AsconNonce,
}

Implementations§

source§

impl EncryptedMem

source

pub fn encrypt<T: Zeroize + AsRef<[u8]>>( &mut self, plaintext: &T ) -> MemSecurityResult<&mut Self>

Performs an encryption operation.

source

pub fn decrypt(&self) -> MemSecurityResult<ZeroizeBytes>

Performs an decryption operation.

source

pub fn blake3_hmac<T: Zeroize + AsRef<[u8]>>(plaintext: T) -> Hash

Hash some bytes with Blake3 using a key to create a HMAC

source

pub fn blake3_keyed_hash_with_array<T: Zeroize + AsRef<[u8]>>( plaintext_array: &[T] ) -> Hash

Hash some an array of bytes with Blake3 using a key to create a HMAC

source

pub fn blake3_hkdf(plaintext: &str) -> [u8; 32]

Hash a predetermined content with Blake3 using a secret key to derive a key (HKDF)

source

pub fn decrypt_16byte(&self) -> MemSecurityResult<ZeroizeArray<16>>

Performs an decryption operation expecting a 16 byte array that is zeroed when dropped.

source

pub fn decrypt_32byte(&self) -> MemSecurityResult<ZeroizeArray<32>>

Performs an decryption operation expecting a 32 byte array that is zeroed when dropped.

source§

impl EncryptedMem

source

pub fn new() -> Self

Initializes a new EncryptedMem

Usage
let data = EncryptedMem::new();
source

pub fn ciphertext(&self) -> &ZeroizeBytes

Expose the ciphertext

source

pub fn nonce(&self) -> &Nonce<Ascon128a>

Expose Nonce

Trait Implementations§

source§

impl Debug for EncryptedMem

source§

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

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

impl Default for EncryptedMem

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V