pub struct EncryptedFile { /* private fields */ }Expand description
Represents a complete encrypted file with header and content.
This is the whole-bytes convenience over the streaming API in
crate::v3::stream; callers that cannot hold the content in memory
should drive StreamSealer/StreamOpener directly.
Implementations§
Source§impl EncryptedFile
impl EncryptedFile
pub fn new(header: FileHeader, ciphertext: Vec<u8>) -> Self
Sourcepub fn seal(
metadata: &FileMetadata,
content: &[u8],
key: &SecureKey,
kdf_params: KeyDerivationParams,
salt: [u8; 16],
nonce_prefix: [u8; 16],
metadata_nonce: [u8; 24],
) -> Result<Self, FileError>
pub fn seal( metadata: &FileMetadata, content: &[u8], key: &SecureKey, kdf_params: KeyDerivationParams, salt: [u8; 16], nonce_prefix: [u8; 16], metadata_nonce: [u8; 24], ) -> Result<Self, FileError>
Encrypts metadata and content into a complete v3 encrypted file.
The caller supplies the key (derived from kdf_params and salt) and
fresh random salt/nonces, keeping this function deterministic.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, HeaderError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, HeaderError>
Parses a serialized v3 file into its header and content ciphertext.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serializes the complete file (header followed by content ciphertext).
Sourcepub fn decrypt(&self, key: &SecureKey) -> Result<PlaintextFile, FileError>
pub fn decrypt(&self, key: &SecureKey) -> Result<PlaintextFile, FileError>
Decrypts the metadata and the full content stream. The inverse of
EncryptedFile::seal.
pub fn header(&self) -> &FileHeader
pub fn ciphertext(&self) -> &[u8] ⓘ
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EncryptedFile
impl RefUnwindSafe for EncryptedFile
impl Send for EncryptedFile
impl Sync for EncryptedFile
impl Unpin for EncryptedFile
impl UnsafeUnpin for EncryptedFile
impl UnwindSafe for EncryptedFile
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