pub struct Enclave<T> {
pub metadata: T,
pub encrypted_bytes: Box<[u8]>,
pub nonce: [u8; 12],
}Expand description
Enclave acts as a container for encrypted data, including metadata and the encrypted content itself.
Metadata is unencrypted and can be used to store information about the data, while the actual data is securely encrypted.
§Type Parameters
T: The type of metadata associated with the encrypted data.
Fields§
§metadata: TMetadata associated with the encrypted data.
encrypted_bytes: Box<[u8]>The encrypted data.
nonce: [u8; 12]The nonce used in the encryption process, 8 bytes long (ChaCha20).
Implementations§
Source§impl<T> Enclave<T>
impl<T> Enclave<T>
Sourcepub fn from_plain_bytes(
metadata: T,
key: [u8; 32],
plain_bytes: Vec<u8>,
) -> Result<Self, String>
pub fn from_plain_bytes( metadata: T, key: [u8; 32], plain_bytes: Vec<u8>, ) -> Result<Self, String>
Creates a new Enclave instance from unencrypted data.
§Arguments
metadata: The metadata to be associated with the encrypted data.key: A 32-byte cipher key used for encryption.plain_bytes: The data to be encrypted.
§Returns
A Result containing the newly created Enclave instance, or an error string if encryption fails.
Sourcepub fn recover_key(
encrypted_bytes: &[u8],
password: &[u8],
) -> Result<Key<KEY_SIZE, 16>, EnclaveError>
pub fn recover_key( encrypted_bytes: &[u8], password: &[u8], ) -> Result<Key<KEY_SIZE, 16>, EnclaveError>
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Enclave<T>where
T: Freeze,
impl<T> RefUnwindSafe for Enclave<T>where
T: RefUnwindSafe,
impl<T> Send for Enclave<T>where
T: Send,
impl<T> Sync for Enclave<T>where
T: Sync,
impl<T> Unpin for Enclave<T>where
T: Unpin,
impl<T> UnwindSafe for Enclave<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more