pub struct EncryptedFile {
header: FileHeader,
ciphertext: Vec<u8>,
}Expand description
Represents a complete encrypted file with header and content
Fields§
§header: FileHeader§ciphertext: Vec<u8>Implementations§
Source§impl EncryptedFile
impl EncryptedFile
pub fn new(header: FileHeader, ciphertext: Vec<u8>) -> EncryptedFile
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<EncryptedFile, HeaderError>
pub fn from_bytes(bytes: &[u8]) -> Result<EncryptedFile, HeaderError>
Parses a serialized v1 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 filename and content. v1 has no header authentication, so only the AEAD tags of the two ciphertexts are verified.
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
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